From aeb88e76755a16339c549b2ba8592feee6ced3a4 Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Thu, 17 Mar 2011 17:05:35 +0530 Subject: [PATCH 1/3] [IMP] change for amount_type='code' on hr.salary.rule object improve the calculation for the same bzr revid: psi@tinyerp.co.in-20110317113535-7o5j9gz8bf3g8zmx --- addons/hr_payroll/hr_payroll.py | 16 ++++++++-------- addons/hr_payroll/hr_payroll_view.xml | 12 +++++------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 9ef2b13c53c..abcbd0b6af0 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -991,8 +991,8 @@ class hr_payslip(osv.osv): else: value = line.amount elif line.amount_type=='code': - localdict = {'basic':amt} - exec line.python_code in localdict + localdict = {'basic':amt, 'employee':employee_id, 'contract':contract} + exec line.python_compute in localdict value = localdict['result'] total += value vals = { @@ -1172,16 +1172,17 @@ class hr_payslip_line(osv.osv): ('per','Percentage (%)'), ('fix','Fixed Amount'), ('code','Python Code'), - ],'Amount Type', select=True, required=True), - 'amount': fields.float('Amount / Percentage', digits=(16, 4)), + ],'Amount Type', select=True, required=True, help="The computation method for the rule amount."), + 'amount': fields.float('Amount / Percentage', digits_compute=dp.get_precision('Account'), help="For rule of type percentage, enter % ratio between 0-1."), 'total': fields.float('Sub Total', digits_compute=dp.get_precision('Account')), - 'company_contrib': fields.float('Company Contribution', readonly=True, digits=(16, 4)), + 'company_contrib': fields.float('Company Contribution', readonly=True, digits_compute=dp.get_precision('Account')), 'sequence': fields.integer('Sequence'), 'note':fields.text('Description'), } _order = 'sequence' _defaults = { - 'amount_type': 'per' + 'amount_type': 'per', + 'amount': 0.0, } hr_payslip_line() @@ -1213,11 +1214,10 @@ class hr_salary_rule(osv.osv): 'conditions':fields.char('Condition', size=1024, required=True, readonly=False, help='Applied this head for calculation if condition is true'), 'sequence': fields.integer('Sequence', required=True, help='Use to arrange calculation sequence'), 'active':fields.boolean('Active'), - 'python_code': fields.text('Python code'), 'python_compute':fields.text('Python Code'), } _defaults = { - 'python_compute': '''# basic\n\nresult = basic * 0.10''', + 'python_compute': '''# basic\n# employee: hr.employee object or None\n# contract: hr.contract object or None\n\nresult = basic * 0.10''', 'conditions': 'True', 'computational_expression': 'basic', 'sequence': 5, diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index 74bc26ac4ef..2aa50d9ab5b 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -162,7 +162,7 @@ - + @@ -233,7 +233,7 @@ - + @@ -605,12 +605,10 @@ - + - - @@ -623,8 +621,8 @@ - - + + From a3d4555688f173973088606b586f5033933bafad Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Thu, 17 Mar 2011 18:25:47 +0530 Subject: [PATCH 2/3] [IMP] payslip line created by holidays will also consider the amount_type=code bzr revid: psi@tinyerp.co.in-20110317125547-lj532yj9wy79uz2a --- addons/hr_payroll/hr_payroll.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index abcbd0b6af0..350c899ddeb 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -1105,6 +1105,10 @@ class hr_payslip(osv.osv): raise osv.except_osv(_('Variable Error !'), _('Variable Error: %s ') % (e)) elif salary_rule.amount_type == 'fix': value = salary_rule.amount * days + elif salary_rule.amount_type=='code': + localdict = {'basic':amt, 'employee':employee_id, 'contract':contract} + exec salary_rule.python_compute in localdict + value = localdict['result'] * days res['amount'] = salary_rule.amount res['type'] = salary_rule.type.id leave += days From db4327dd2d8fdf5ed925cf28af1ccc16debc7dea Mon Sep 17 00:00:00 2001 From: "psi (Open ERP)" Date: Fri, 18 Mar 2011 18:43:13 +0530 Subject: [PATCH 3/3] [IMP] add company on hr.payroll.register form and tree view bzr revid: psi@tinyerp.co.in-20110318131313-gd7o475deqaooyo3 --- addons/hr_payroll/hr_payroll_view.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index 2aa50d9ab5b..e9622625efd 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -153,6 +153,7 @@ + @@ -227,6 +228,7 @@ + @@ -408,6 +410,7 @@ + @@ -422,6 +425,7 @@ +