From 63b6ec6050abd49262b25b84f93a5e7228817962 Mon Sep 17 00:00:00 2001 From: "olt@tinyerp.com" <> Date: Fri, 24 Sep 2010 10:46:36 +0200 Subject: [PATCH 1/7] [FIX] project_planning: revision 4965 added a bug: removed field 'child_ids' was used in project_planning module bzr revid: olt@tinyerp.com-20100924084636-czxo56j2ck1nwutj --- addons/project_planning/project_planning.py | 37 +++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/addons/project_planning/project_planning.py b/addons/project_planning/project_planning.py index e248fe1c050..2044772e6cc 100644 --- a/addons/project_planning/project_planning.py +++ b/addons/project_planning/project_planning.py @@ -25,6 +25,7 @@ import mx.DateTime from osv import fields, osv from tools.translate import _ +import tools class one2many_mod3(fields.one2many): @@ -35,8 +36,9 @@ class one2many_mod3(fields.one2many): for obj in obj.browse(cr, user, ids, context=context): res[obj.id] = [] list_ids = [] - for item in obj.user_id.child_ids: - list_ids.append(item.id) + children = obj.pool.get('report_account_analytic.planning')._child_compute(cr, user, [obj.user_id.id], '', []) + for u_id in children.get(obj.user_id.id, []): + list_ids.append(u_id) list_ids.append(obj.user_id.id) ids2 = obj.pool.get(self._obj).search(cr, user, ['&',(self._fields_id,'=',obj.id),'|',('user_id','in',list_ids),('user_id','=',False)], limit=self._limit) for r in obj.pool.get(self._obj)._read_flat(cr, user, ids2, [self._fields_id], context=context, load='_classic_write'): @@ -49,6 +51,35 @@ class report_account_analytic_planning(osv.osv): _name = "report_account_analytic.planning" _description = "Planning" + def _child_compute(self, cr, uid, ids, name, args, context=None): + if context is None: + context = {} + obj_dept = self.pool.get('hr.department') + obj_user = self.pool.get('res.users') + result = {} + for user_id in ids: + child_ids = [] + cr.execute('SELECT dept.id FROM hr_department AS dept \ + LEFT JOIN hr_employee AS emp ON dept.manager_id = emp.id \ + WHERE emp.id IN \ + (SELECT emp.id FROM hr_employee \ + JOIN resource_resource r ON r.id = emp.resource_id WHERE r.user_id=' + str(user_id) + ') ') + mgnt_dept_ids = [x[0] for x in cr.fetchall()] + ids_dept = obj_dept.search(cr, uid, [('id', 'child_of', mgnt_dept_ids)], context=context) + if ids_dept: + data_dept = obj_dept.read(cr, uid, ids_dept, ['member_ids'], context=context) + childs = map(lambda x: x['member_ids'], data_dept) + childs = tools.flatten(childs) + childs = obj_user.search(cr, uid, [('id', 'in', childs),('active', '=', True)], context=context) + if user_id in childs: + childs.remove(user_id) + child_ids.extend(tools.flatten(childs)) + set = {} + map(set.__setitem__, child_ids, []) + child_ids = set.keys() + result[user_id] = child_ids + return result + def _get_total_planned(self, cr, uid, ids, name, args, context=None): result = {} for plan in self.browse(cr, uid, ids, context): @@ -583,4 +614,4 @@ class res_company(osv.osv): } res_company() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 31c545ac6f31931f57bfb686058fe65f34ac0cda Mon Sep 17 00:00:00 2001 From: "RME(OpenERP)" <> Date: Fri, 24 Sep 2010 15:42:04 +0530 Subject: [PATCH 2/7] [FIX] Account_payment : Demo corrected bzr revid: jvo@tinyerp.com-20100924101204-enl5v3b417t6o4u0 --- addons/account_payment/account_payment_demo.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/account_payment/account_payment_demo.xml b/addons/account_payment/account_payment_demo.xml index 25fe4a2c55b..37705a05b07 100644 --- a/addons/account_payment/account_payment_demo.xml +++ b/addons/account_payment/account_payment_demo.xml @@ -5,7 +5,7 @@ Reserve Bank 00987654321 - + bank Direct Payment From d7ed28f534b42c198e2595b1cde400d83d23596a Mon Sep 17 00:00:00 2001 From: "Jay (OpenERP)" Date: Fri, 24 Sep 2010 15:43:44 +0530 Subject: [PATCH 3/7] [FIX] POS : Correction in wizard,NEVER ever return None,it can break xmlrpc request. bzr revid: jvo@tinyerp.com-20100924101344-7eu0pcp6y8cql8hw --- addons/point_of_sale/wizard/pos_payment.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/addons/point_of_sale/wizard/pos_payment.py b/addons/point_of_sale/wizard/pos_payment.py index 27c04a6dfba..5b6c5f167fb 100644 --- a/addons/point_of_sale/wizard/pos_payment.py +++ b/addons/point_of_sale/wizard/pos_payment.py @@ -43,7 +43,6 @@ class pos_make_payment(osv.osv_memory): @return: A dictionary which of fields with values. """ res = super(pos_make_payment, self).default_get(cr, uid, fields, context=context) - active_id = context and context.get('active_id',False) if active_id: j_obj = self.pool.get('account.journal') @@ -51,10 +50,7 @@ class pos_make_payment(osv.osv_memory): j_ids = map(lambda x1: x1[0], cr.fetchall()) journal = j_obj.search(cr, uid, [('type', '=', 'cash'), ('id', 'in', j_ids)]) - if journal: - journal = journal[0] - else: - journal = None + journal = journal and journal[0] or False wf_service = netsvc.LocalService("workflow") order_obj=self.pool.get('pos.order') From a525b4733ca5159827d8bedf23748df8d4205d24 Mon Sep 17 00:00:00 2001 From: "RME(OpenERP)" <> Date: Fri, 24 Sep 2010 15:50:33 +0530 Subject: [PATCH 4/7] [FIX] account_payment : Corrections lp bug: https://launchpad.net/bugs/608412 fixed bzr revid: jvo@tinyerp.com-20100924102033-sw8cjvew49bhzcnd --- addons/account_payment/account_payment_view.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account_payment/account_payment_view.xml b/addons/account_payment/account_payment_view.xml index 93ba4b85de0..b7cef21f8e0 100644 --- a/addons/account_payment/account_payment_view.xml +++ b/addons/account_payment/account_payment_view.xml @@ -38,7 +38,7 @@ - + payment.mode.tree @@ -203,7 +203,7 @@ - + New Payment Order From 214960b36e9a3bf83ed20f8209c62fbc339d792e Mon Sep 17 00:00:00 2001 From: "Jay (OpenERP)" Date: Fri, 24 Sep 2010 16:09:46 +0530 Subject: [PATCH 5/7] [FIX] pos : pylint test passed. Thanks to buildbot bzr revid: jvo@tinyerp.com-20100924103946-8fj8ksrzyu00kxpi --- addons/point_of_sale/wizard/pos_payment.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/addons/point_of_sale/wizard/pos_payment.py b/addons/point_of_sale/wizard/pos_payment.py index 5b6c5f167fb..8330be2772c 100644 --- a/addons/point_of_sale/wizard/pos_payment.py +++ b/addons/point_of_sale/wizard/pos_payment.py @@ -19,14 +19,10 @@ # ############################################################################## -import netsvc from osv import osv,fields from tools.translate import _ import pos_box_entries import time -from decimal import Decimal -from tools.translate import _ -import pos_receipt class pos_make_payment(osv.osv_memory): _name = 'pos.make.payment' @@ -51,7 +47,6 @@ class pos_make_payment(osv.osv_memory): journal = j_obj.search(cr, uid, [('type', '=', 'cash'), ('id', 'in', j_ids)]) journal = journal and journal[0] or False - wf_service = netsvc.LocalService("workflow") order_obj=self.pool.get('pos.order') order = order_obj.browse(cr, uid, active_id, context) @@ -88,7 +83,7 @@ class pos_make_payment(osv.osv_memory): if active_id: order = self.pool.get('pos.order').browse(cr, uid, active_id) if not order.lines: - raise osv.except_osv('Error!','No order lines defined for this sale ') + raise osv.except_osv(_('Error!'),_('No order lines defined for this sale ')) return True def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): From c3d7dedf07424c5272383e5d1ebeec66e89cd6bf Mon Sep 17 00:00:00 2001 From: "Jay (OpenERP)" Date: Fri, 24 Sep 2010 16:11:24 +0530 Subject: [PATCH 6/7] [REF] hr_timesheet : Better readable messages bzr revid: jvo@tinyerp.com-20100924104124-s0dtgin32s4ezyef --- addons/hr_timesheet/test/hr_timesheet_report.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/hr_timesheet/test/hr_timesheet_report.yml b/addons/hr_timesheet/test/hr_timesheet_report.yml index 811858eb7f2..2f19f75618f 100644 --- a/addons/hr_timesheet/test/hr_timesheet_report.yml +++ b/addons/hr_timesheet/test/hr_timesheet_report.yml @@ -1,5 +1,5 @@ - - In order to test the PDF reports defined on HR Timesheet User Report, we will print a HR Timesheet User Report + In order to test the PDF reports defined on Employee, we will print Timesheet of a User - !python {model: hr.employee}: | import netsvc, tools, os, time @@ -11,7 +11,7 @@ file(os.path.join(tools.config['test_report_directory'], 'hr_timesheet-user_report.'+format), 'wb+').write(data) - - In order to test the PDF reports defined on HR Timesheet Users Report, we will print a HR Timesheet Users Report + In order to test the PDF reports defined on Employee, we will print Timesheet of Users - !python {model: hr.employee}: | import netsvc, tools, os, time From 14d55ddd6dbcb00cf23237a91a9467a89d232e55 Mon Sep 17 00:00:00 2001 From: "SAZ(OpenERP)" <> Date: Fri, 24 Sep 2010 16:13:20 +0530 Subject: [PATCH 7/7] [FIX] hr_timesheet_invoice : Passed the yaml report test bzr revid: jvo@tinyerp.com-20100924104320-2f7dgfk43rp1i6l1 --- .../report/account_analytic_profit.rml | 118 +++++++++--------- .../test/hr_timesheet_invoice_report.yml | 2 +- 2 files changed, 62 insertions(+), 58 deletions(-) diff --git a/addons/hr_timesheet_invoice/report/account_analytic_profit.rml b/addons/hr_timesheet_invoice/report/account_analytic_profit.rml index 3cb4b150395..b6d9f155cab 100644 --- a/addons/hr_timesheet_invoice/report/account_analytic_profit.rml +++ b/addons/hr_timesheet_invoice/report/account_analytic_profit.rml @@ -74,24 +74,24 @@ - + - - + + - - - - - + + + + + - - + + @@ -115,8 +115,8 @@ + - @@ -157,12 +157,10 @@ - [[ formatLang (data['form']['date_from'],date=True) -]] + [[ formatLang(data['form']['date_from'],date=True) ]] - [[ formatLang (data['form']['date_to'],date=True) - ]] + [[ formatLang (data['form']['date_to'] ,date=True)]] [[ company.currency_id.name ]] @@ -209,7 +207,7 @@ Totals: - [[ reduce(lambda x, y: x+y['unit_amount'], line(data['form'], data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]] + [[ reduce(lambda x, y: x+y['unit_amount'], line(data['form'], data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]] @@ -217,47 +215,47 @@ - [[ reduce(lambda x, y: x+y['amount'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]] + [[ reduce(lambda x, y: x+y['amount'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]] - [[ reduce(lambda x, y: x+y['cost'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]] + [[ reduce(lambda x, y: x+y['cost'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]] - [[ reduce(lambda x, y: x+y['profit'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]] + [[ reduce(lambda x, y: x+y['profit'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) ]] - [[ reduce(lambda x, y: x+y['cost'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) and round(reduce(lambda x, y: x+y['amount'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0)/reduce(lambda x, y: x+y['cost'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0)* -100, 2)]] % + [[ reduce(lambda x, y: x+y['cost'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0) and round(reduce(lambda x, y: x+y['amount'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0)/reduce(lambda x, y: x+y['cost'], line(data['form'],data['form']['journal_ids'][0][2], data['form']['employee_ids'][0][2]), 0)* -100, 2)]] %
[[ repeatIn(user_ids(lines(data['form'])), 'e') ]] - + [[ e.name ]] - [[ repeatIn(journal_ids(data['form'], e.id), 'j') ]] + [[ repeatIn(journal_ids(data['form'], [e.id]), 'j') ]] - [[ reduce(lambda x, y: x+y['unit_amount'], line(data['form'], [j.id], [e.id]), 0) ]] + [[ reduce(lambda x, y: x+y['unit_amount'], line(data['form'], [j.id], [e.id]), 0) ]] - [[ reduce(lambda x, y: x+y['amount_th'], line(data['form'], [j.id], [e.id]), 0) ]] + [[ reduce(lambda x, y: x+y['amount_th'], line(data['form'], [j.id], [e.id]), 0) ]] - [[ reduce(lambda x, y: x+y['amount'], line(data['form'], [j.id], [e.id]), 0) ]] + [[ reduce(lambda x, y: x+y['amount'], line(data['form'], [j.id], [e.id]), 0) ]] - [[ reduce(lambda x, y: x+y['cost'], line(data['form'], [j.id], [e.id]), 0) ]] + [[ reduce(lambda x, y: x+y['cost'], line(data['form'], [j.id], [e.id]), 0) ]] - [[ reduce(lambda x, y: x+y['profit'], line(data['form'], [j.id], [e.id]), 0) ]] + [[ reduce(lambda x, y: x+y['profit'], line(data['form'], [j.id], [e.id]), 0) ]] - [[ reduce(lambda x, y: x+y['cost'], line(data['form'], [j.id], [e.id]), 0) and (reduce(lambda x, y: x+y['amount'], line(data['form'], [j.id], [e.id]), 0) / reduce(lambda x, y: x+y['cost'], line(data['form'], [j.id], [e.id]), 0) * 100.0)]] % + [[reduce(lambda x, y: x+y['cost'], line(data['form'], [j.id], [e.id]), 0) and '%d' % (reduce(lambda x, y: x+y['amount'], line(data['form'], [j.id], [e.id]), 0) / reduce(lambda x, y: x+y['cost'], line(data['form'], [j.id], [e.id]), 0) * 100.0, 2)]] % @@ -298,35 +296,41 @@ -
+ + +
- [[ repeatIn(line(data['form'], [j.id],[e.id]), 'l') ]] - - - - [[ l['name'] ]] - - - [[ l['unit_amount'] ]] - - - [[ l['amount_th'] ]] - - - [[ l['amount'] ]] - - - [[ l['cost'] ]] - - - [[ l['profit'] ]] - - - [[ l['eff'] ]] % - - - - + [[ repeatIn(line(data['form'], [j.id],[e.id]), 'l') ]] + + + + [[ l['name'] ]] + + + [[ l['unit_amount'] ]] + + + [[ l['amount_th'] ]] + + + [[ l['amount'] ]] + + + [[ l['cost'] ]] + + + [[ l['profit'] ]] + + + [[ l['eff'] ]] % + + + + + + +
+ @@ -334,4 +338,4 @@
- \ No newline at end of file + diff --git a/addons/hr_timesheet_invoice/test/hr_timesheet_invoice_report.yml b/addons/hr_timesheet_invoice/test/hr_timesheet_invoice_report.yml index ecdd486a65e..32f22e7eb4b 100644 --- a/addons/hr_timesheet_invoice/test/hr_timesheet_invoice_report.yml +++ b/addons/hr_timesheet_invoice/test/hr_timesheet_invoice_report.yml @@ -3,7 +3,7 @@ - !python {model: account.analytic.line}: | import netsvc, tools, os, time - data_dict = {'model': 'ir.ui.menu', 'form': {'date_from': time.strftime('%Y-%m-01'), 'employee_ids': [[6,0,[ref('hr.employee1'), ref('hr.employee2'),ref('hr.employee3')]]], 'journal_ids': [[6,0,[ref('account.cose_journal_sale'),ref('account.exp'),ref('account.sit')]]], 'date_to': time.strftime('%Y-%m-%d')}} + data_dict = {'model': 'ir.ui.menu', 'form': {'date_from': time.strftime('%Y-%m-01'), 'employee_ids': [[6,0,[ref('hr.employee1'), ref('hr.employee2'),ref('hr.employee3')]]], 'journal_ids': [[6,0,[ref('hr_timesheet.analytic_journal')]]], 'date_to': time.strftime('%Y-%m-%d')}} (data, format) = netsvc.LocalService('report.account.analytic.profit').create(cr, uid, [], data_dict, {}) if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'hr_timesheet_invoice-account_analytic_profit_report.'+format), 'wb+').write(data)