From f00e26b9ca52c3261c270a22d3fda6a38e786c30 Mon Sep 17 00:00:00 2001 From: "pankita shah (Open ERP)" Date: Thu, 4 Oct 2012 18:36:06 +0530 Subject: [PATCH 01/72] [FIX] weekly,monthly report problem in hr module bzr revid: shp@tinyerp.com-20121004130606-ju9ahpnk20qxeeyr --- addons/hr_attendance/report/attendance_by_month.py | 4 +++- addons/hr_attendance/report/timesheet.py | 2 +- addons/hr_attendance/wizard/hr_attendance_byweek.py | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/hr_attendance/report/attendance_by_month.py b/addons/hr_attendance/report/attendance_by_month.py index 17cf548345e..ab6ba3ce609 100644 --- a/addons/hr_attendance/report/attendance_by_month.py +++ b/addons/hr_attendance/report/attendance_by_month.py @@ -84,8 +84,10 @@ class report_custom(report_rml): # sum up the attendances' durations ldt = None for att in attendences: - dt = datetime.strptime(att['name'], '%Y-%m-%d %H:%M:%S') + dt = datetime.strptime(att['name'], '%Y-%m-%d %H:%M:%S') if ldt and att['action'] == 'sign_out': + if dt.date() > ldt.date(): + dt = ldt wh += (float((dt - ldt).seconds)/60/60) else: ldt = dt diff --git a/addons/hr_attendance/report/timesheet.py b/addons/hr_attendance/report/timesheet.py index 900f982dc74..fdb2569b4a2 100644 --- a/addons/hr_attendance/report/timesheet.py +++ b/addons/hr_attendance/report/timesheet.py @@ -38,7 +38,7 @@ class report_custom(report_rml): def create_xml(self, cr, uid, ids, datas, context=None): obj_emp = pooler.get_pool(cr.dbname).get('hr.employee') - + ids = datas['active_ids'] start_date = datetime.strptime(datas['form']['init_date'], '%Y-%m-%d') end_date = datetime.strptime(datas['form']['end_date'], '%Y-%m-%d') first_monday = start_date - relativedelta(days=start_date.date().weekday()) diff --git a/addons/hr_attendance/wizard/hr_attendance_byweek.py b/addons/hr_attendance/wizard/hr_attendance_byweek.py index 9ee69a937d1..454ba7764da 100644 --- a/addons/hr_attendance/wizard/hr_attendance_byweek.py +++ b/addons/hr_attendance/wizard/hr_attendance_byweek.py @@ -37,6 +37,7 @@ class hr_attendance_byweek(osv.osv_memory): def print_report(self, cr, uid, ids, context=None): datas = { 'ids': [], + 'active_ids': context['active_ids'], 'model': 'hr.employee', 'form': self.read(cr, uid, ids)[0] } From 529b8c9e64c8bce4f628cbc89ef4b3cb5e5c6b9f Mon Sep 17 00:00:00 2001 From: "pankita shah (Open ERP)" Date: Fri, 5 Oct 2012 12:25:08 +0530 Subject: [PATCH 02/72] [FIX] widget is undefined when press cost and revenus bzr revid: shp@tinyerp.com-20121005065508-4axokyk4llathg21 --- addons/account/project/project_view.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml index 70db95425b1..342663e700f 100644 --- a/addons/account/project/project_view.xml +++ b/addons/account/project/project_view.xml @@ -160,7 +160,7 @@ account.analytic.line.tree account.analytic.line - + From 12c0f14d3916dc79aa1d1a13521b2589f311bdb6 Mon Sep 17 00:00:00 2001 From: "pankita shah (Open ERP)" Date: Fri, 5 Oct 2012 14:12:13 +0530 Subject: [PATCH 03/72] [FIX] remove duplicate name when click sign in/out project bzr revid: shp@tinyerp.com-20121005084213-d4qkc25iyy5maq0m --- addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py b/addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py index e92e88bdcbd..031a17baee0 100644 --- a/addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py +++ b/addons/hr_timesheet/wizard/hr_timesheet_sign_in_out.py @@ -147,7 +147,7 @@ class hr_si_project(osv.osv_memory): 'view_type': 'form', 'view_mode': 'tree,form', 'res_model': 'hr.sign.%s.project' % in_out, - 'views': [(False,'tree'), (resource_id,'form')], + 'views': [(resource_id,'form')], 'type': 'ir.actions.act_window', 'target': 'new' } From 6761871c4ea8427da90703d942f553b7334d6043 Mon Sep 17 00:00:00 2001 From: "pankita shah (Open ERP)" Date: Mon, 8 Oct 2012 10:40:14 +0530 Subject: [PATCH 04/72] [IMP] indentation of active ids of timesheet.py bzr revid: shp@tinyerp.com-20121008051014-fvftsi2mt44abyyn --- addons/hr_attendance/report/timesheet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_attendance/report/timesheet.py b/addons/hr_attendance/report/timesheet.py index fdb2569b4a2..326ffce63e0 100644 --- a/addons/hr_attendance/report/timesheet.py +++ b/addons/hr_attendance/report/timesheet.py @@ -38,7 +38,7 @@ class report_custom(report_rml): def create_xml(self, cr, uid, ids, datas, context=None): obj_emp = pooler.get_pool(cr.dbname).get('hr.employee') - ids = datas['active_ids'] + ids = datas['active_ids'] start_date = datetime.strptime(datas['form']['init_date'], '%Y-%m-%d') end_date = datetime.strptime(datas['form']['end_date'], '%Y-%m-%d') first_monday = start_date - relativedelta(days=start_date.date().weekday()) From 667da9253fd647a7888d7986d996b9c66f4797e7 Mon Sep 17 00:00:00 2001 From: "pankita shah (Open ERP)" Date: Mon, 8 Oct 2012 15:04:56 +0530 Subject: [PATCH 05/72] [IMP] Exprience instead of Experience bzr revid: shp@tinyerp.com-20121008093456-ff27x03xt89v4og3 --- addons/hr_recruitment/hr_recruitment_data.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_recruitment/hr_recruitment_data.xml b/addons/hr_recruitment/hr_recruitment_data.xml index 21f4e48e42d..1bedd411cf2 100644 --- a/addons/hr_recruitment/hr_recruitment_data.xml +++ b/addons/hr_recruitment/hr_recruitment_data.xml @@ -312,7 +312,7 @@ You can automatically create application records from an email gateway, that you This question requires an answer. - Exprience + Experience comment The comment you entered is in an invalid format. From 82138688a2d27337fc30d0143d00bd7275754e00 Mon Sep 17 00:00:00 2001 From: "Atul Patel (OpenERP)" Date: Mon, 8 Oct 2012 21:16:47 +0530 Subject: [PATCH 06/72] [FIX]: Fix analytic line shown. bzr revid: atp@tinyerp.com-20121008154647-bdxw4ajq5hgb7jsk --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index cd58f52f959..76c6ac7ca35 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -468,7 +468,7 @@ class hr_timesheet_line(osv.osv): for ts_line in self.browse(cursor, user, ids, context=context): sheet_ids = sheet_obj.search(cursor, user, [('date_to', '>=', ts_line.date), ('date_from', '<=', ts_line.date), - ('employee_id.user_id', '=', ts_line.user_id.id)], + ('employee_id.user_id', '=', ts_line.sheet_id and ts_line.sheet_id.employee_id.user_id.id)], context=context) if sheet_ids: # [0] because only one sheet possible for an employee between 2 dates From fbe1e7f913571f8dbbaddeceb5d877d09bc5f6df Mon Sep 17 00:00:00 2001 From: "Atul Patel (OpenERP)" Date: Tue, 9 Oct 2012 16:18:42 +0530 Subject: [PATCH 07/72] [FIX]: analytic account onchange problem. bzr revid: atp@tinyerp.com-20121009104842-njdr868dtc4ly1w9 --- addons/analytic_user_function/analytic_user_function.py | 2 +- addons/hr_timesheet_invoice/hr_timesheet_invoice_view.xml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/analytic_user_function/analytic_user_function.py b/addons/analytic_user_function/analytic_user_function.py index 9233845f7eb..7ac947981fc 100644 --- a/addons/analytic_user_function/analytic_user_function.py +++ b/addons/analytic_user_function/analytic_user_function.py @@ -65,7 +65,7 @@ class hr_analytic_timesheet(osv.osv): return False - def on_change_account_id(self, cr, uid, ids, account_id, user_id=False, unit_amount=0): + def on_change_account_id(self, cr, uid, ids, account_id, user_id, unit_amount=0): res = {} if not (account_id): #avoid a useless call to super diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice_view.xml b/addons/hr_timesheet_invoice/hr_timesheet_invoice_view.xml index b752ade8da0..95fa39a6eda 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice_view.xml +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice_view.xml @@ -50,7 +50,7 @@ - + @@ -72,7 +72,7 @@ - + From 28bc19896dbed07842923a43bc52ccc267014195 Mon Sep 17 00:00:00 2001 From: "pankita shah (Open ERP)" Date: Wed, 10 Oct 2012 10:54:49 +0530 Subject: [PATCH 08/72] [MERGE] merged with lp:openobject-addons bzr revid: shp@tinyerp.com-20121010052449-hvnp0e53d1sp6xs2 --- addons/analytic_user_function/analytic_user_function.py | 2 ++ addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/addons/analytic_user_function/analytic_user_function.py b/addons/analytic_user_function/analytic_user_function.py index 7ac947981fc..fdf8b7eb94a 100644 --- a/addons/analytic_user_function/analytic_user_function.py +++ b/addons/analytic_user_function/analytic_user_function.py @@ -65,6 +65,7 @@ class hr_analytic_timesheet(osv.osv): return False + def on_change_account_id(self, cr, uid, ids, account_id, user_id, unit_amount=0): res = {} if not (account_id): @@ -106,6 +107,7 @@ class hr_analytic_timesheet(osv.osv): return res def on_change_user_id(self, cr, uid, ids, user_id, account_id, unit_amount=0): + print "---------------onchageuser id",user_id res = {} if not (user_id): #avoid a useless call to super diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 097568a391d..383f837ac32 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -155,6 +155,7 @@ class hr_timesheet_sheet(osv.osv): return super(hr_timesheet_sheet, self).create(cr, uid, vals, *args, **argv) def write(self, cr, uid, ids, vals, *args, **argv): + print "------------vvvvvvvvvals",vals if 'employee_id' in vals: new_user_id = self.pool.get('hr.employee').browse(cr, uid, vals['employee_id']).user_id.id or False if not new_user_id: @@ -308,6 +309,7 @@ hr_timesheet_sheet() class hr_timesheet_line(osv.osv): _inherit = "hr.analytic.timesheet" + def _get_default_date(self, cr, uid, context=None): if context is None: context = {} @@ -404,6 +406,7 @@ class hr_attendance(osv.osv): return time.strftime('%Y-%m-%d %H:%M:%S') def _get_hr_timesheet_sheet(self, cr, uid, ids, context=None): + print "-----------get_hr_time sheet" attendance_ids = [] for ts in self.browse(cr, uid, ids, context=context): cr.execute(""" @@ -470,6 +473,7 @@ class hr_attendance(osv.osv): return super(hr_attendance,self).unlink(cr, uid, ids,*args, **kwargs) def write(self, cr, uid, ids, vals, context=None): + print "------------write " if context is None: context = {} if isinstance(ids, (int, long)): From e65a9208b8bf04b39b2a0499b5e1a3da3bccf50c Mon Sep 17 00:00:00 2001 From: "pankita shah (Open ERP)" Date: Wed, 10 Oct 2012 14:39:13 +0530 Subject: [PATCH 09/72] [Fix] when click time sheet timesheet sheet analysis in reporting bzr revid: shp@tinyerp.com-20121010090913-lugvm9jwb43hdmmq --- addons/hr_timesheet_sheet/report/hr_timesheet_report.py | 4 ++-- addons/hr_timesheet_sheet/report/timesheet_report.py | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/hr_timesheet_sheet/report/hr_timesheet_report.py b/addons/hr_timesheet_sheet/report/hr_timesheet_report.py index 1fdcac9f7c6..bdb0ddbb116 100644 --- a/addons/hr_timesheet_sheet/report/hr_timesheet_report.py +++ b/addons/hr_timesheet_sheet/report/hr_timesheet_report.py @@ -54,8 +54,8 @@ class hr_timesheet_report(osv.osv): min(t.id) as id, l.date as date, to_char(l.date, 'YYYY-MM-DD') as day, - to_char(l.date,'YYYY') as year, - to_char(l.date,'MM') as month, + to_char(l.date, 'YYYY') as year, + to_char(l.date, 'MM') as month, sum(l.amount) as cost, sum(l.unit_amount) as quantity, l.account_id as account_id, diff --git a/addons/hr_timesheet_sheet/report/timesheet_report.py b/addons/hr_timesheet_sheet/report/timesheet_report.py index 497fe8da117..0b541f18b3f 100644 --- a/addons/hr_timesheet_sheet/report/timesheet_report.py +++ b/addons/hr_timesheet_sheet/report/timesheet_report.py @@ -46,6 +46,7 @@ class timesheet_report(osv.osv): 'department_id':fields.many2one('hr.department','Department',readonly=True), 'date_from': fields.date('Date from',readonly=True,), 'date_to': fields.date('Date to',readonly=True), + 'date_current': fields.date('Current date', required=True), 'state' : fields.selection([ ('new', 'New'), ('draft','Draft'), @@ -64,6 +65,9 @@ class timesheet_report(osv.osv): htss.name, htss.date_from, htss.date_to, + to_char(htss.date_from, 'YYYY-MM-DD') as day, + to_char(htss.date_from, 'YYYY') as year, + to_char(htss.date_from, 'MM') as month, count(*) as nbr, aal.unit_amount as quantity, aal.amount as cost, @@ -105,6 +109,7 @@ class timesheet_report(osv.osv): htss.id, htss.department_id, htss.user_id + ) """) timesheet_report() From 98eaf2c2bc96055d32f5f6d2fa54c2698d61efe6 Mon Sep 17 00:00:00 2001 From: "Atul Patel (OpenERP)" Date: Wed, 10 Oct 2012 16:04:50 +0530 Subject: [PATCH 10/72] [FIX]: Fix on_change_account_id() argument problem bzr revid: atp@tinyerp.com-20121010103450-n4gt4ikp05t6b8yu --- addons/hr_timesheet_invoice/hr_timesheet_invoice.py | 2 +- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 3 +-- addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index b9574b553d1..d4950708294 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -174,7 +174,7 @@ account_analytic_line() class hr_analytic_timesheet(osv.osv): _inherit = "hr.analytic.timesheet" - def on_change_account_id(self, cr, uid, ids, account_id): + def on_change_account_id(self, cr, uid, ids, account_id, user_id): res = {} if not account_id: return res diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 383f837ac32..65ad4ce5905 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -155,7 +155,6 @@ class hr_timesheet_sheet(osv.osv): return super(hr_timesheet_sheet, self).create(cr, uid, vals, *args, **argv) def write(self, cr, uid, ids, vals, *args, **argv): - print "------------vvvvvvvvvals",vals if 'employee_id' in vals: new_user_id = self.pool.get('hr.employee').browse(cr, uid, vals['employee_id']).user_id.id or False if not new_user_id: @@ -390,7 +389,7 @@ class hr_timesheet_line(osv.osv): return True def multi_on_change_account_id(self, cr, uid, ids, account_ids, context=None): - return dict([(el, self.on_change_account_id(cr, uid, ids, el)) for el in account_ids]) + return dict([(el, self.on_change_account_id(cr, uid, ids, el, context.get('user_id', uid))) for el in account_ids]) hr_timesheet_line() diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml index 7dd2b9a1b88..28e886b779f 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml @@ -97,7 +97,7 @@ - + @@ -110,7 +110,7 @@
- + From eb20086d59b5dc06df721b774e50de326a646e4f Mon Sep 17 00:00:00 2001 From: "Atul Patel (OpenERP)" Date: Wed, 10 Oct 2012 16:41:51 +0530 Subject: [PATCH 11/72] [REM]: Remove print statement bzr revid: atp@tinyerp.com-20121010111151-cgylp0roe61vhzs9 --- addons/analytic_user_function/analytic_user_function.py | 1 - addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/addons/analytic_user_function/analytic_user_function.py b/addons/analytic_user_function/analytic_user_function.py index fdf8b7eb94a..7e4d00ef095 100644 --- a/addons/analytic_user_function/analytic_user_function.py +++ b/addons/analytic_user_function/analytic_user_function.py @@ -107,7 +107,6 @@ class hr_analytic_timesheet(osv.osv): return res def on_change_user_id(self, cr, uid, ids, user_id, account_id, unit_amount=0): - print "---------------onchageuser id",user_id res = {} if not (user_id): #avoid a useless call to super diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 65ad4ce5905..0fb98e142ec 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -405,7 +405,6 @@ class hr_attendance(osv.osv): return time.strftime('%Y-%m-%d %H:%M:%S') def _get_hr_timesheet_sheet(self, cr, uid, ids, context=None): - print "-----------get_hr_time sheet" attendance_ids = [] for ts in self.browse(cr, uid, ids, context=context): cr.execute(""" @@ -472,7 +471,6 @@ class hr_attendance(osv.osv): return super(hr_attendance,self).unlink(cr, uid, ids,*args, **kwargs) def write(self, cr, uid, ids, vals, context=None): - print "------------write " if context is None: context = {} if isinstance(ids, (int, long)): From f935c9e4823ddf126369359b4eb720bac5505df7 Mon Sep 17 00:00:00 2001 From: "Atul Patel (OpenERP)" Date: Wed, 10 Oct 2012 18:17:16 +0530 Subject: [PATCH 12/72] [FIX]: get sheet id using timesheet line user id bzr revid: atp@tinyerp.com-20121010124716-hdaebwpsowpowhl7 --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 0fb98e142ec..32fbf978175 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -322,7 +322,7 @@ class hr_timesheet_line(osv.osv): for ts_line in self.browse(cursor, user, ids, context=context): sheet_ids = sheet_obj.search(cursor, user, [('date_to', '>=', ts_line.date), ('date_from', '<=', ts_line.date), - ('employee_id.user_id', '=', ts_line.sheet_id and ts_line.sheet_id.employee_id.user_id.id)], + ('employee_id.user_id', '=', ts_line.user_id.id)], context=context) if sheet_ids: # [0] because only one sheet possible for an employee between 2 dates From e2a28b011ad70ad3cfb1c8d4ba6c65ac5df89201 Mon Sep 17 00:00:00 2001 From: "Atul Patel (OpenERP)" Date: Wed, 10 Oct 2012 20:38:49 +0530 Subject: [PATCH 13/72] [FIX]: Fix on_change_analytic_id problem bzr revid: atp@tinyerp.com-20121010150849-u4cldadvfjzmw8mj --- addons/analytic_user_function/analytic_user_function.py | 2 +- addons/hr_timesheet_invoice/hr_timesheet_invoice.py | 2 +- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 2 +- addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/analytic_user_function/analytic_user_function.py b/addons/analytic_user_function/analytic_user_function.py index 7e4d00ef095..9c84b75b293 100644 --- a/addons/analytic_user_function/analytic_user_function.py +++ b/addons/analytic_user_function/analytic_user_function.py @@ -66,7 +66,7 @@ class hr_analytic_timesheet(osv.osv): - def on_change_account_id(self, cr, uid, ids, account_id, user_id, unit_amount=0): + def on_change_account_id(self, cr, uid, ids, account_id, user_id=False, unit_amount=0): res = {} if not (account_id): #avoid a useless call to super diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index d4950708294..b9574b553d1 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -174,7 +174,7 @@ account_analytic_line() class hr_analytic_timesheet(osv.osv): _inherit = "hr.analytic.timesheet" - def on_change_account_id(self, cr, uid, ids, account_id, user_id): + def on_change_account_id(self, cr, uid, ids, account_id): res = {} if not account_id: return res diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 32fbf978175..bec3c641776 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -389,7 +389,7 @@ class hr_timesheet_line(osv.osv): return True def multi_on_change_account_id(self, cr, uid, ids, account_ids, context=None): - return dict([(el, self.on_change_account_id(cr, uid, ids, el, context.get('user_id', uid))) for el in account_ids]) + return dict([(el, self.on_change_account_id(cr, uid, ids, el)) for el in account_ids]) hr_timesheet_line() diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml index 28e886b779f..7dd2b9a1b88 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml @@ -97,7 +97,7 @@ - + @@ -110,7 +110,7 @@ - + From 23a0926efd757cd7850d619a63b02d8c0c4c874a Mon Sep 17 00:00:00 2001 From: "Atul Patel (OpenERP)" Date: Wed, 10 Oct 2012 20:52:58 +0530 Subject: [PATCH 14/72] [FIX]: Fix for analytic account in hr timesheet sheet line. bzr revid: atp@tinyerp.com-20121010152258-997mxrukpjeawcpb --- addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml index 7dd2b9a1b88..28e886b779f 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml @@ -97,7 +97,7 @@ - + @@ -110,7 +110,7 @@ - + From 540248ed9ea38846a417bee3c7d08966e1ae6e6a Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Thu, 11 Oct 2012 12:40:48 +0200 Subject: [PATCH 15/72] [IMP] mail: cleaner code bzr revid: chm@openerp.com-20121011104048-4vy0k8pp1rrjug1k --- addons/mail/mail_message.py | 2 +- addons/mail/mail_thread.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 9631918050a..975e7fc1aaf 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -509,7 +509,7 @@ class mail_message(osv.Model): Call mail_notification.notify to manage the email sending """ message = self.browse(cr, uid, newid, context=context) - if message and (message.is_private!=False and message.is_private!=None): + if not message: self._notify_followers(cr, uid, newid, message, context=context) # add myself if I wrote on my wall, diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index e5b93ac4000..cb69b08a86d 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -708,7 +708,7 @@ class mail_thread(osv.AbstractModel): attachment_ids=[] if attachments: ir_attachment = self.pool.get('ir.attachment') - attachment_ids = ir_attachment.search(cr, 1, [('res_model', '=', ""), ('res_id', '=', ""), ('user_id', '=', uid), ('id', 'in', attachments)], context=context) + attachment_ids = ir_attachment.search(cr, 1, [('res_model', '=', False), ('res_id', '=', False), ('user_id', '=', uid), ('id', 'in', attachments)], context=context) if attachment_ids: self.pool.get('ir.attachment').write(cr, 1, attachment_ids, { 'res_model': self._name, 'res_id': thread_id }, context=context) self.pool.get('mail.message').write(cr, 1, [added_message_id], {'attachment_ids': [(6, 0, [pid for pid in attachment_ids])]} ) From b27b12db1ba97ee029ced20436fd31547501aa51 Mon Sep 17 00:00:00 2001 From: "Atul Patel (OpenERP)" Date: Thu, 11 Oct 2012 17:42:01 +0530 Subject: [PATCH 16/72] [FIX]: Fix onchange account id problem bzr revid: atp@tinyerp.com-20121011121201-h6030emuz00t55nv --- addons/hr_timesheet/hr_timesheet.py | 2 +- addons/hr_timesheet_invoice/hr_timesheet_invoice.py | 2 +- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/hr_timesheet/hr_timesheet.py b/addons/hr_timesheet/hr_timesheet.py index a28508be4db..cd0f873ccfd 100644 --- a/addons/hr_timesheet/hr_timesheet.py +++ b/addons/hr_timesheet/hr_timesheet.py @@ -154,7 +154,7 @@ class hr_analytic_timesheet(osv.osv): 'date': lambda self, cr, uid, ctx: ctx.get('date', fields.date.context_today(self,cr,uid,context=ctx)), 'user_id': lambda obj, cr, uid, ctx: ctx.get('user_id', uid), } - def on_change_account_id(self, cr, uid, ids, account_id): + def on_change_account_id(self, cr, uid, ids, account_id, user_id): return {'value':{}} def on_change_date(self, cr, uid, ids, date): diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index b9574b553d1..d4950708294 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -174,7 +174,7 @@ account_analytic_line() class hr_analytic_timesheet(osv.osv): _inherit = "hr.analytic.timesheet" - def on_change_account_id(self, cr, uid, ids, account_id): + def on_change_account_id(self, cr, uid, ids, account_id, user_id): res = {} if not account_id: return res diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index bec3c641776..887ce15a741 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -389,7 +389,7 @@ class hr_timesheet_line(osv.osv): return True def multi_on_change_account_id(self, cr, uid, ids, account_ids, context=None): - return dict([(el, self.on_change_account_id(cr, uid, ids, el)) for el in account_ids]) + return dict([(el, self.on_change_account_id(cr, uid, ids, el, context.get('user_id', False) or uid)) for el in account_ids]) hr_timesheet_line() From de0023a14f723f21edbd8a2d41d4a4b7e458392e Mon Sep 17 00:00:00 2001 From: "Atul Patel (OpenERP)" Date: Thu, 11 Oct 2012 18:04:41 +0530 Subject: [PATCH 17/72] [FIX]: Fix default user timesheetline problem bzr revid: atp@tinyerp.com-20121011123441-5zg1nm394d0b45ky --- addons/hr_timesheet/hr_timesheet.py | 4 ++-- addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/hr_timesheet/hr_timesheet.py b/addons/hr_timesheet/hr_timesheet.py index cd0f873ccfd..7934b8e5be1 100644 --- a/addons/hr_timesheet/hr_timesheet.py +++ b/addons/hr_timesheet/hr_timesheet.py @@ -136,7 +136,7 @@ class hr_analytic_timesheet(osv.osv): emp_obj = self.pool.get('hr.employee') if context is None: context = {} - emp_id = emp_obj.search(cr, uid, [('user_id', '=', context.get('user_id', uid))], context=context) + emp_id = emp_obj.search(cr, uid, [('user_id', '=', context.get('user_id', False) or uid)], context=context) if not emp_id : raise osv.except_osv(_('Warning!'), _('Please create an employee for this user, using the menu: Human Resources > Employees.')) emp = emp_obj.browse(cr, uid, emp_id[0], context=context) @@ -152,7 +152,7 @@ class hr_analytic_timesheet(osv.osv): 'general_account_id': _getGeneralAccount, 'journal_id': _getAnalyticJournal, 'date': lambda self, cr, uid, ctx: ctx.get('date', fields.date.context_today(self,cr,uid,context=ctx)), - 'user_id': lambda obj, cr, uid, ctx: ctx.get('user_id', uid), + 'user_id': lambda obj, cr, uid, ctx: ctx.get('user_id', False) or uid, } def on_change_account_id(self, cr, uid, ids, account_id, user_id): return {'value':{}} diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml index 28e886b779f..c96d256b7e2 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml @@ -106,7 +106,7 @@ - + From 4a77345f634b6f419f4d2da919b091ab92abb980 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Thu, 11 Oct 2012 18:16:14 +0200 Subject: [PATCH 18/72] [IMP] mail, following: access bzr revid: chm@openerp.com-20121011161614-k72bm2f6gw451u5g --- addons/mail/mail_followers.py | 2 +- addons/mail/mail_message.py | 60 +++++++++++---------- addons/mail/mail_message_view.xml | 14 +++-- addons/mail/mail_thread.py | 4 +- addons/mail/mail_thread_view.xml | 8 ++- addons/mail/static/src/js/mail.js | 3 ++ addons/mail/static/src/js/mail_followers.js | 18 +++---- addons/mail/static/src/xml/mail.xml | 3 +- addons/mrp/procurement.py | 2 +- 9 files changed, 66 insertions(+), 48 deletions(-) diff --git a/addons/mail/mail_followers.py b/addons/mail/mail_followers.py index 6f122a87ba5..e0883988cd8 100644 --- a/addons/mail/mail_followers.py +++ b/addons/mail/mail_followers.py @@ -92,7 +92,7 @@ class mail_notification(osv.Model): partner_id = self.pool.get('res.users').browse(cr, uid, uid, context=context).partner_id.id notif_ids = self.search(cr, uid, [('partner_id', '=', partner_id), ('message_id', 'in', msg_ids)], context=context) - return self.write(cr, uid, notif_ids, {'read': read}, context=context) + return self.write(cr, 1, notif_ids, {'read': read}, context=context) def get_partners_to_notify(self, cr, uid, message, context=None): """ Return the list of partners to notify, based on their preferences. diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 975e7fc1aaf..9ea826c84a7 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -163,7 +163,7 @@ class mail_message(osv.Model): mail.message not always granted. ''' if not user_ids: user_ids = [uid] - for message in self.read(cr, uid, ids, ['vote_user_ids'], context=context): + for message in self.read(cr, SUPERUSER_ID, ids, ['vote_user_ids'], context=context): for user_id in user_ids: has_voted = user_id in message.get('vote_user_ids') if not has_voted: @@ -189,17 +189,17 @@ class mail_message(osv.Model): has_voted = True break try: - attachment_ids = [{'id': attach[0], 'name': attach[1]} for attach in self.pool.get('ir.attachment').name_get(cr, uid, [x.id for x in msg.attachment_ids], context=context)] + attachment_ids = [{'id': attach[0], 'name': attach[1]} for attach in self.pool.get('ir.attachment').name_get(cr, SUPERUSER_ID, [x.id for x in msg.attachment_ids], context=context)] except (orm.except_orm, osv.except_osv): attachment_ids = [] try: - author_id = self.pool.get('res.partner').name_get(cr, uid, [msg.author_id.id], context=context)[0] + author_id = self.pool.get('res.partner').name_get(cr, SUPERUSER_ID, [msg.author_id.id], context=context)[0] is_author = uid == msg.author_id.user_ids[0].id except Exception: author_id = False is_author = False try: - partner_ids = self.pool.get('res.partner').name_get(cr, uid, [x.id for x in msg.partner_ids], context=context) + partner_ids = self.pool.get('res.partner').name_get(cr, SUPERUSER_ID, [x.id for x in msg.partner_ids], context=context) except (orm.except_orm, osv.except_osv): partner_ids = [] @@ -222,7 +222,7 @@ class mail_message(osv.Model): 'unread': msg.unread and msg.unread['unread'] or False } - def _message_read_expandable(self, cr, uid, tree, result, message_loaded, domain, context, parent_id, limit): + def _message_read_expandable(self, cr, uid, tree, result, message_loaded_ids, domain, context, parent_id, limit): """ create the expandable message for all parent message read this function is used by message_read @@ -230,28 +230,28 @@ class mail_message(osv.Model): tree_not = [] # expandable for not show message - for id_msg in tree: + for msg in tree: # get all childs - not_loaded_ids = self.search(cr, SUPERUSER_ID, [['parent_id','=',id_msg],['id','not in',message_loaded]], None, limit=1000) + not_loaded_ids = self.search(cr, SUPERUSER_ID, [['parent_id','=',msg.id],['id','not in',message_loaded_ids]], None, limit=1000) # group childs not read id_min=None id_max=None nb=0 - for not_loaded_id in not_loaded_ids: - if not_loaded_id not in tree: + for not_loaded in self.browse(cr, SUPERUSER_ID, not_loaded_ids, context=context): + if not_loaded not in tree: nb+=1 - if id_min==None or id_min>not_loaded_id: - id_min=not_loaded_id - if id_max==None or id_maxnot_loaded.id: + id_min=not_loaded.id + if id_max==None or id_max0: result.append({ - 'domain': [['id','>=',id_min],['id','<=',id_max],['parent_id','=',id_msg]], + 'domain': [['id','>=',id_min],['id','<=',id_max],['parent_id','=',msg.id]], 'nb_messages': nb, 'type': 'expandable', - 'parent_id': id_msg, + 'parent_id': msg.id, 'id': id_min }) id_min=None @@ -259,16 +259,18 @@ class mail_message(osv.Model): nb=0 if nb>0: result.append({ - 'domain': [['id','>=',id_min],['id','<=',id_max],['parent_id','=',id_msg]], + 'domain': [['id','>=',id_min],['id','<=',id_max],['parent_id','=',msg.id]], 'nb_messages': nb, 'type': 'expandable', - 'parent_id': id_msg, + 'parent_id': msg.id, 'id': id_min }) + for msg in tree+tree_not: + message_loaded_ids.append( msg.id ) # expandable for limit max - ids = self.search(cr, SUPERUSER_ID, domain+[['id','not in',message_loaded+tree+tree_not]], context=context, limit=1) + ids = self.search(cr, SUPERUSER_ID, domain+[['id','not in',message_loaded_ids]], context=context, limit=1) if len(ids) > 0: result.append( { @@ -297,11 +299,11 @@ class mail_message(osv.Model): further parents :return list: list of trees of messages """ - message_loaded = context and context.get('message_loaded') or [0] + message_loaded_ids = context and context.get('message_loaded') or [0] # don't read the message display by .js, in context message_loaded list if context and context.get('message_loaded'): - domain += [ ['id','not in',message_loaded] ]; + domain += [ ['id','not in',message_loaded_ids] ]; limit = limit or self._message_read_limit context = context or {} @@ -317,27 +319,27 @@ class mail_message(osv.Model): return result # key: ID, value: record - ids = self.search(cr, SUPERUSER_ID, domain, context=context, limit=limit) + ids = self.search(cr, uid, domain, context=context, limit=limit) for msg in self.browse(cr, uid, ids, context=context): # if not in record and not in message_loded list - if msg.id not in tree and msg.id not in message_loaded : + if msg not in tree and msg.id not in message_loaded_ids : record = self._message_dict_get(cr, uid, msg, context=context) - tree.append(msg.id) + tree.append(msg) result.append(record) while msg.parent_id and msg.parent_id.id != parent_id: parent_id = msg.parent_id.id if msg.parent_id.id not in tree: msg = msg.parent_id - tree.append(msg.id) + tree.append(msg) # if not in record and not in message_loded list - if msg.id not in message_loaded : + if msg.id not in message_loaded_ids : record = self._message_dict_get(cr, uid, msg, context=context) result.append(record) result = sorted(result, key=lambda k: k['id']) - result = self._message_read_expandable(cr, uid, tree, result, message_loaded, domain, context, parent_id, limit) + result = self._message_read_expandable(cr, uid, tree, result, message_loaded_ids, domain, context, parent_id, limit) return result @@ -465,13 +467,14 @@ class mail_message(osv.Model): def read(self, cr, uid, ids, fields=None, context=None, load='_classic_read'): """ Override to explicitely call check_access_rule, that is not called by the ORM. It instead directly fetches ir.rules and apply them. """ - res = super(mail_message, self).read(cr, uid, ids, fields=fields, context=context, load=load) self.check_access_rule(cr, uid, ids, 'read', context=context) + res = super(mail_message, self).read(cr, uid, ids, fields=fields, context=context, load=load) return res def unlink(self, cr, uid, ids, context=None): # cascade-delete attachments that are directly attached to the message (should only happen # for mail.messages that act as parent for a standalone mail.mail record). + self.check_access_rule(cr, uid, ids, 'unlink', context=context) attachments_to_delete = [] for message in self.browse(cr, uid, ids, context=context): for attach in message.attachment_ids: @@ -499,7 +502,6 @@ class mail_message(osv.Model): fol_objs = fol_obj.browse(cr, uid, fol_ids, context=context) extra_notified = set(fol.partner_id.id for fol in fol_objs) missing_notified = extra_notified - partners_to_notify - missing_notified = missing_notified if missing_notified: self.write(cr, SUPERUSER_ID, [newid], {'partner_ids': [(4, p_id) for p_id in missing_notified]}, context=context) partners_to_notify |= extra_notified diff --git a/addons/mail/mail_message_view.xml b/addons/mail/mail_message_view.xml index 0c572384bb4..fd304a309af 100644 --- a/addons/mail/mail_message_view.xml +++ b/addons/mail/mail_message_view.xml @@ -56,6 +56,7 @@ + @@ -87,21 +88,28 @@ Inbox mail.wall - + + + + To: me + mail.wall + Archives mail.wall - Sent mail.wall - diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index cb69b08a86d..d00f132f1c8 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -102,12 +102,12 @@ class mail_thread(osv.AbstractModel): # find the document followers, update the data fol_obj = self.pool.get('mail.followers') - fol_ids = fol_obj.search(cr, uid, [ + fol_ids = fol_obj.search(cr, SUPERUSER_ID, [ ('partner_id', '=', user_pid), ('res_id', 'in', ids), ('res_model', '=', self._name), ], context=context) - for fol in fol_obj.browse(cr, uid, fol_ids, context=context): + for fol in fol_obj.browse(cr, SUPERUSER_ID, fol_ids, context=context): thread_subtype_dict = res[fol.res_id]['message_subtype_data'] res[fol.res_id]['message_is_follower'] = True for subtype in fol.subtype_ids: diff --git a/addons/mail/mail_thread_view.xml b/addons/mail/mail_thread_view.xml index 696edde0e15..65ad477042c 100644 --- a/addons/mail/mail_thread_view.xml +++ b/addons/mail/mail_thread_view.xml @@ -3,7 +3,7 @@ - @@ -18,6 +18,12 @@ + + To: me + + + + Archives diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 15a81be4c54..a9a9bc5429d 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -1115,6 +1115,9 @@ openerp.mail = function(session) { /* Send the records to his parent thread */ switch_new_message: function(records) { + + console.log(records); + var self=this; _(records).each(function(record){ self.browse_thread({ diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 236e3081136..d69c46e0242 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -74,7 +74,7 @@ openerp_mail_followers = function(session, mail) { target: 'new', context: { 'default_res_model': self.view.dataset.model, - 'default_res_id': self.view.datarecord.id + 'default_res_id': self.view.dataset.ids[0] }, } self.do_action(action, function() { self.read_value(); }); @@ -83,7 +83,7 @@ openerp_mail_followers = function(session, mail) { read_value: function() { var self = this; - return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids']).pipe(function (results) { + return this.ds_model.read_ids([this.view.dataset.ids[0]], ['message_follower_ids']).pipe(function (results) { self.set_value(results[0].message_follower_ids); }); }, @@ -158,7 +158,7 @@ openerp_mail_followers = function(session, mail) { set_subtypes:function(data){ var self = this; - var records = (data[this.view.datarecord.id] || data[null]).message_subtype_data; + var records = data[this.view.dataset.ids[0]].message_subtype_data; _(records).each(function (record, record_name) { record.name = record_name; @@ -168,14 +168,14 @@ openerp_mail_followers = function(session, mail) { }, /** Display subtypes: {'name': default, followed} */ - display_subtypes: function (visible) { + display_subtypes: function () { var self = this; var recthread_subtypes = self.$('.oe_recthread_subtypes'); subtype_list_ul = self.$('ul.oe_subtypes'); if(subtype_list_ul.is(":empty")) { var context = new session.web.CompoundContext(this.build_context(), {}); - this.ds_model.call('get_message_subtypes',[[self.view.datarecord.id], context]).pipe(this.proxy('set_subtypes')); + this.ds_model.call('get_message_subtypes',[[self.view.dataset.ids[0]], context]).pipe(this.proxy('set_subtypes')); } }, @@ -191,7 +191,7 @@ openerp_mail_followers = function(session, mail) { $(record).attr('checked',false); }); var context = new session.web.CompoundContext(this.build_context(), {}); - return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], [this.session.uid], context]).pipe(this.proxy('read_value')); + return this.ds_model.call('message_unsubscribe_users', [[this.view.dataset.ids[0]], [this.session.uid], context]).pipe(this.proxy('read_value')); }, do_update_subscription: function (event) { @@ -207,9 +207,9 @@ openerp_mail_followers = function(session, mail) { return this.do_unfollow(); else{ var context = new session.web.CompoundContext(this.build_context(), {}); - return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], [this.session.uid], undefined, context]).pipe(function(value_){ - self.read_value(value_); - self.display_subtypes(true); + return this.ds_model.call('message_subscribe_users', [[this.view.dataset.ids[0]], [this.session.uid], undefined, context]).pipe(function(){ + self.read_value(); + self.display_subtypes(); }); } diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index 2fc97154e33..734a2395d24 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -111,8 +111,7 @@ wall main template Template used to display the communication history in the wall. --> -
+
diff --git a/addons/mrp/procurement.py b/addons/mrp/procurement.py index 8c7068c7fa0..ee9ad9e1905 100644 --- a/addons/mrp/procurement.py +++ b/addons/mrp/procurement.py @@ -112,7 +112,7 @@ class procurement_order(osv.osv): def production_order_create_note(self, cr, uid, ids, context=None): for procurement in self.browse(cr, uid, ids, context=context): - body = "Manufacturing Order %s created." % ( procurement.production_id.name,) + body = _("Manufacturing Order %s created.") % ( procurement.production_id.name,) self.message_post(cr, uid, [procurement.id], body=body, context=context) procurement_order() From 87e89592056f5290f64c28fdfe72dc9b1aa93fb6 Mon Sep 17 00:00:00 2001 From: "Atul Patel (OpenERP)" Date: Thu, 11 Oct 2012 23:11:26 +0530 Subject: [PATCH 19/72] [FIX] bzr revid: atp@tinyerp.com-20121011174126-lii90i9fnfhfsy9v --- addons/hr_timesheet/hr_timesheet.py | 2 +- addons/hr_timesheet_invoice/hr_timesheet_invoice.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/hr_timesheet/hr_timesheet.py b/addons/hr_timesheet/hr_timesheet.py index 7934b8e5be1..0345ca6c06b 100644 --- a/addons/hr_timesheet/hr_timesheet.py +++ b/addons/hr_timesheet/hr_timesheet.py @@ -154,7 +154,7 @@ class hr_analytic_timesheet(osv.osv): 'date': lambda self, cr, uid, ctx: ctx.get('date', fields.date.context_today(self,cr,uid,context=ctx)), 'user_id': lambda obj, cr, uid, ctx: ctx.get('user_id', False) or uid, } - def on_change_account_id(self, cr, uid, ids, account_id, user_id): + def on_change_account_id(self, cr, uid, ids, account_id): return {'value':{}} def on_change_date(self, cr, uid, ids, date): diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index f7a490c4604..30e4ff40885 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -176,7 +176,7 @@ account_analytic_line() class hr_analytic_timesheet(osv.osv): _inherit = "hr.analytic.timesheet" - def on_change_account_id(self, cr, uid, ids, account_id, user_id): + def on_change_account_id(self, cr, uid, ids, account_id, user_id=False): res = {} if not account_id: return res From adc318837a86c72c1a9f490f56305a941c638e88 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Fri, 12 Oct 2012 14:40:03 +0200 Subject: [PATCH 20/72] [IMP]mail: secu bzr revid: chm@openerp.com-20121012124003-zs8uj68gr1upgc57 --- addons/mail/mail_message.py | 73 ++++++++++++++------- addons/mail/mail_thread.py | 9 +-- addons/mail/static/src/js/mail.js | 56 ++++++++++------ addons/mail/static/src/js/mail_followers.js | 3 + 4 files changed, 91 insertions(+), 50 deletions(-) diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index 9ea826c84a7..f6db94f3b75 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -232,12 +232,12 @@ class mail_message(osv.Model): # expandable for not show message for msg in tree: # get all childs - not_loaded_ids = self.search(cr, SUPERUSER_ID, [['parent_id','=',msg.id],['id','not in',message_loaded_ids]], None, limit=1000) + not_loaded_ids = self.search(cr, uid, [['parent_id','=',msg.id],['id','not in',message_loaded_ids]], None, limit=1000) # group childs not read id_min=None id_max=None nb=0 - for not_loaded in self.browse(cr, SUPERUSER_ID, not_loaded_ids, context=context): + for not_loaded in self.browse(cr, uid, not_loaded_ids, context=context): if not_loaded not in tree: nb+=1 if id_min==None or id_min>not_loaded.id: @@ -270,7 +270,7 @@ class mail_message(osv.Model): message_loaded_ids.append( msg.id ) # expandable for limit max - ids = self.search(cr, SUPERUSER_ID, domain+[['id','not in',message_loaded_ids]], context=context, limit=1) + ids = self.search(cr, uid, domain+[['id','not in',message_loaded_ids]], context=context, limit=1) if len(ids) > 0: result.append( { @@ -309,33 +309,47 @@ class mail_message(osv.Model): context = context or {} tree = [] - result = [] + message_ids = [] record = None # select ids if ids and ids!=[None]: for msg in self.browse(cr, uid, ids, context=context): - result.append(self._message_dict_get(cr, uid, msg, context=context)) - return result + message_ids.append(msg.id) - # key: ID, value: record - ids = self.search(cr, uid, domain, context=context, limit=limit) - for msg in self.browse(cr, uid, ids, context=context): - # if not in record and not in message_loded list - if msg not in tree and msg.id not in message_loaded_ids : - record = self._message_dict_get(cr, uid, msg, context=context) - tree.append(msg) - result.append(record) - - while msg.parent_id and msg.parent_id.id != parent_id: - parent_id = msg.parent_id.id - if msg.parent_id.id not in tree: - msg = msg.parent_id + # key: ID, value: tree + if not ids: + ids = self.search(cr, uid, domain, context=context, limit=limit) + for msg in self.browse(cr, uid, ids, context=context): + # if not in tree and not in message_loded list + if msg not in tree and msg.id not in message_loaded_ids : + message_ids.append(msg.id) tree.append(msg) - # if not in record and not in message_loded list - if msg.id not in message_loaded_ids : - record = self._message_dict_get(cr, uid, msg, context=context) - result.append(record) + + try: + parent = msg.parent_id + except orm.except_orm, inst: + print inst + parent = False + + while parent and parent.id != parent_id: + parent_id = msg.parent_id.id + if msg.parent_id.id not in tree: + tree.append(parent) + # if not in tree and not in message_loded list + if parent.id not in message_loaded_ids : + message_ids.append(parent.id) + + try: + parent = msg.parent_id + except orm.except_orm, inst: + print inst + parent = False + + result = [] + for msg in self.browse(cr, uid, message_ids, context=context): + record = self._message_dict_get(cr, uid, msg, context=context) + result.append( record ) result = sorted(result, key=lambda k: k['id']) @@ -371,7 +385,8 @@ class mail_message(osv.Model): - Otherwise: raise - create: if - I am in the document message_follower_ids OR - - I can write on the related document if res_model, res_id + - I can write on the related document if res_model, res_id OR + - I write a mail to another user (no res_model) - Otherwise: raise - write: if - I can write on the related document if res_model, res_id @@ -412,7 +427,7 @@ class mail_message(osv.Model): else: author_ids = [] - # Create: Check message_follower_ids + # Create: Check message_follower_ids and author_ids if operation == 'create': doc_follower_ids = [] for model, mids in model_record_ids.items(): @@ -428,6 +443,12 @@ class mail_message(osv.Model): else: doc_follower_ids = [] + # Create/write: Check author_ids + if operation == 'create' or operation == 'write': + author_ids = author_ids+[mid for mid, message in message_values.iteritems() + if message.get('author_id') and message.get('author_id') == partner_id and not message.get('res_model')] + + # Calculate remaining ids, and related model/res_ids model_record_ids = {} other_ids = set(ids).difference(set(notified_ids), set(author_ids), set(doc_follower_ids)) @@ -511,6 +532,8 @@ class mail_message(osv.Model): Call mail_notification.notify to manage the email sending """ message = self.browse(cr, uid, newid, context=context) + + print message.partner_ids if not message: self._notify_followers(cr, uid, newid, message, context=context) diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index d00f132f1c8..81846258921 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -221,8 +221,8 @@ class mail_thread(osv.AbstractModel): def create(self, cr, uid, vals, context=None): """ Override to subscribe the current user. """ - thread_id = super(mail_thread, self).create(cr, uid, vals, context=context) - self.message_subscribe_users(cr, uid, [thread_id], [uid], context=context) + thread_id = super(mail_thread, self).create(cr, SUPERUSER_ID, vals, context=context) + self.message_subscribe_users(cr, SUPERUSER_ID, [thread_id], [uid], context=context) return thread_id def unlink(self, cr, uid, ids, context=None): @@ -682,9 +682,10 @@ class mail_thread(osv.AbstractModel): # if the parent is private, the message must be private if parent_id: msg = messages.browse(cr, uid, parent_id, context=context) - if msg.is_private: - values["is_private"] = msg.is_private + values["is_private"] = msg.is_private or False + values["partner_ids"] = [(4, partner.id) for partner in msg.partner_ids] + print values # Avoid warnings about non-existing fields for x in ('from', 'to', 'cc'): values.pop(x, None) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index a9a9bc5429d..468b628ab5a 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -27,6 +27,7 @@ openerp.mail = function(session) { if( key!='default_template_id' && key!='default_use_template' && key!='default_is_private' && + key!='default_partner_ids' && key!='default_model' && key!='default_res_id' && key!='default_subtype' && @@ -331,6 +332,11 @@ openerp.mail = function(session) { for(var i in this.attachment_ids){ attachments.push(this.attachment_ids[i].id); } + var partner_ids=[]; + for(var i in this.partner_ids){ + partner_ids.push(this.partner_ids[i][0]); + } + var action = { type: 'ir.actions.act_window', res_model: 'mail.compose.message', @@ -346,14 +352,15 @@ openerp.mail = function(session) { 'default_is_private': true, 'default_parent_id': this.id, 'default_body': mail.ChatterUtils.get_text2html(this.$('textarea').val() || ''), - 'default_attachment_ids': attachments + 'default_attachment_ids': attachments, + 'default_partner_ids': partner_ids }, }; this.do_action(action); }, - on_cancel: function(){ - event.stopPropagation(); + on_cancel: function(event){ + if(event) event.stopPropagation(); this.$('textarea').val(""); this.$('input[data-id]').remove(); //this.attachment_ids=[]; @@ -365,6 +372,7 @@ openerp.mail = function(session) { /*post a message and fetch the message*/ on_message_post: function (body) { + var self = this; if (! body) { var comment_node = this.$('textarea'); @@ -390,9 +398,11 @@ openerp.mail = function(session) { false, this.context.default_parent_id, attachments] - ).then(this.parent_thread.proxy('switch_new_message')); - this.attachment_ids=[]; - this.on_cancel(); + ).then(function(records){ + self.parent_thread.switch_new_message(records); + self.attachment_ids=[]; + self.on_cancel(); + }); return true; } }, @@ -451,8 +461,12 @@ openerp.mail = function(session) { */ on_expandable: function (event) { if(event)event.stopPropagation(); + var self = this; this.parent_thread.message_fetch(false, this.domain, this.context); - this.destroy(); + this.$el.fadeOut(300, function(){ + self.destroy(); + }); + this.$('*').unbind(); return false; }, }); @@ -841,7 +855,7 @@ openerp.mail = function(session) { this.messages = []; - this.ds_thread = new session.web.DataSetSearch(this, this.context.default_model); + this.ds_thread = new session.web.DataSetSearch(this, this.context.default_model || 'mail.thread'); this.ds_message = new session.web.DataSetSearch(this, 'mail.message'); }, @@ -1002,7 +1016,7 @@ openerp.mail = function(session) { * @param {Array} replace_domain: added to this.domain * @param {Object} replace_context: added to this.context */ - message_fetch: function (initial_mode, replace_domain, replace_context, ids) { + message_fetch: function (initial_mode, replace_domain, replace_context, ids, callback) { var self = this; // initial mode: try to use message_data or message_ids @@ -1015,7 +1029,7 @@ openerp.mail = function(session) { fetch_context.message_loaded= [this.id||0].concat( self.options.thread._parents[0].get_child_ids() ); return this.ds_message.call('message_read', [ids, fetch_domain, fetch_context, 0, this.context.default_parent_id || undefined] - ).then(this.proxy('switch_new_message')); + ).then(function (records) { self.switch_new_message(records); }); }, /* create record object and linked him @@ -1072,13 +1086,15 @@ openerp.mail = function(session) { // check older and newer message for insert var parent_newer = false; var parent_older = false; - for(var i in thread_messages){ - if(thread_messages[i].id > message.id){ - if(!parent_newer || parent_newer.id>=thread_messages[i].id) - parent_newer = thread_messages[i]; - } else if(thread_messages[i].id>0 && thread_messages[i].id < message.id) { - if(!parent_older || parent_older.id 0 ){ + for(var i in thread_messages){ + if(thread_messages[i].id > message.id){ + if(!parent_newer || parent_newer.id>=thread_messages[i].id) + parent_newer = thread_messages[i]; + } else if(thread_messages[i].id>0 && thread_messages[i].id < message.id) { + if(!parent_older || parent_older.id 0){ message.prependTo(thread.list_ul); } else { message.appendTo(thread.list_ul); } } + return message }, @@ -1115,9 +1132,6 @@ openerp.mail = function(session) { /* Send the records to his parent thread */ switch_new_message: function(records) { - - console.log(records); - var self=this; _(records).each(function(record){ self.browse_thread({ diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index d69c46e0242..1a7f16d6987 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -158,6 +158,9 @@ openerp_mail_followers = function(session, mail) { set_subtypes:function(data){ var self = this; + if (!data[this.view.dataset.ids[0]]) { + return false; + } var records = data[this.view.dataset.ids[0]].message_subtype_data; _(records).each(function (record, record_name) { From 41c039a0a0bdea8014d314ffd8b290e4b361aa92 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Fri, 12 Oct 2012 14:40:39 +0200 Subject: [PATCH 21/72] [IMP]mail: suppress ajax attachment bzr revid: chm@openerp.com-20121012124039-x2b2kojr8935ro1e --- addons/mail/static/src/js/mail.js | 47 ----------------------------- addons/mail/static/src/xml/mail.xml | 5 --- 2 files changed, 52 deletions(-) diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 468b628ab5a..395f1a6dc2c 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -199,7 +199,6 @@ openerp.mail = function(session) { // submit file //session.web.blockUI(); self.$('form.oe_form_binary_form').submit(); - //self.submit_ajax_attachment(); this.$(".oe_attachment_file").hide(); @@ -214,52 +213,6 @@ openerp.mail = function(session) { } }, - submit_ajax_attachment: function(){ - var self=this; - var $form = self.$('form.oe_form_binary_form'); - var filename = this.$('input.oe_form_binary_file').val().replace(/.*[\\\/]/,''); - - // create form data - var fomdata = new FormData(); - $.each($form.find('input'), function(i, field) { - var $field=$(field); - if($field.attr('type')!='file'){ - fomdata.append($field.attr('name'), $field.val()); - } else { - fomdata.append($field.attr('name'), field.files[0]); - } - }); - - var progress=function(event) { - self.$("span[name='"+filename+"'] div:lt("+Math.floor(event.loaded / event.total*5)+")").show(); - }; - - $.ajax({ - url: $form.attr("action"), - data: fomdata, - cache: false, - contentType: false, - processData: false, - type: 'POST', - enctype: 'multipart/form-data', - xhr: function() { - // custom xhr - myXhr = $.ajaxSettings.xhr(); - if(myXhr.upload){ - // for handling the progress of the upload - myXhr.upload.addEventListener('progress', progress, false); - } - myXhr.addEventListener('progress', progress, false); - return myXhr; - }, - success: function(data){ - $iframe=$('