From 66d96e0cf15863c22da41a424d8fb383b0c2a7a3 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Wed, 23 Mar 2011 17:11:12 +0530 Subject: [PATCH 1/7] [IMP] hr_payroll: add contract id on onchange on contract on payslip bzr revid: mra@mra-laptop-20110323114112-2q1bvj1db1qtnpwz --- addons/hr_payroll/hr_payroll.py | 33 +++++++++++++++------------ addons/hr_payroll/hr_payroll_view.xml | 2 +- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 7988b592013..d359002eb13 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -204,7 +204,7 @@ class payroll_register(osv.osv): 'date': vals.date, } slip_id = slip_pool.create(cr, uid, res, context=context) - data = slip_pool.onchange_employee_id(cr, uid, [slip_id], vals.date, emp.id, context=context) + data = slip_pool.onchange_employee_id(cr, uid, [slip_id], vals.date, emp.id, contract_id=False, context=context) # fix me can we pass contract_id ? for line in data['value']['line_ids']: line.update({'slip_id': slip_id}) slip_line_pool.create(cr, uid, line, context=context) @@ -890,7 +890,7 @@ class hr_payslip(osv.osv): self.write(cr, uid, [slip.id], update, context=context) return True - def onchange_employee_id(self, cr, uid, ids, ddate, employee_id=False, context=None): + def onchange_employee_id(self, cr, uid, ids, ddate, employee_id=False, contract_id=False, context=None): func_pool = self.pool.get('hr.payroll.structure') slip_line_pool = self.pool.get('hr.payslip.line') salary_rule_pool = self.pool.get('hr.salary.rule') @@ -911,21 +911,24 @@ class hr_payslip(osv.osv): return update employee_id = empolyee_obj.browse(cr, uid, employee_id, context=context) - ttyme = datetime.fromtimestamp(time.mktime(time.strptime(ddate,"%Y-%m-%d"))) - contracts = self.get_contract(cr, uid, employee_id, ddate, context=context) - if not contracts.get('id', False): - update['value'].update({ - 'basic_amount': 0.0, - 'basic_before_leaves': 0.0, - 'name':'Salary Slip of %s for %s' % (employee_id.name, tools.ustr(ttyme.strftime('%B-%Y'))), - 'contract_id':False, - 'company_id':employee_id.company_id.id - }) - return update + ttyme = datetime.fromtimestamp(time.mktime(time.strptime(ddate, "%Y-%m-%d"))) + if not contract_id: + contracts = self.get_contract(cr, uid, employee_id, ddate, context=context) + if not contracts.get('id', False): + update['value'].update({ + 'basic_amount': 0.0, + 'basic_before_leaves': 0.0, + 'name':'Salary Slip of %s for %s' % (employee_id.name, tools.ustr(ttyme.strftime('%B-%Y'))), + 'contract_id':False, + 'company_id':employee_id.company_id.id + }) + return update + contract = employee_id.contract_id + else: + contract = self.pool.get('hr.contract').browse(cr, uid, contract_id, context=context) - contract = employee_id.contract_id - sal_structure = [] function = contract.struct_id.id + sal_structure = [] if function: sal_structure = self._get_parent_structure(cr, uid, [function], context=context) diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index 0afc3516f24..75beacfa62e 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -208,7 +208,7 @@
- + From 36ab36f29057aabd7cdbf626cdd1bbaa41897019 Mon Sep 17 00:00:00 2001 From: mtr Date: Wed, 23 Mar 2011 18:38:24 +0530 Subject: [PATCH 2/7] [IMP] hr_payroll:removed 'display_child_rules' from the code bzr revid: mtr@mtr-20110323130824-dcafcx8t85fm0wou --- addons/hr_payroll/hr_payroll.py | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index d359002eb13..3800de0d3bc 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -779,8 +779,7 @@ class hr_payslip(osv.osv): if line.appears_on_payslip: if line.parent_rule_id: for l in salary_rule_pool.browse(cr, uid, [line.parent_rule_id.id], context=context): - if l.display_child_rules == True: - slip_line_pool.create(cr, uid, vals, {}) + slip_line_pool.create(cr, uid, vals, {}) else: if line.condition_range_min or line.condition_range_max: if not ((value < line.condition_range_min) or (value > line.condition_range_max)): @@ -1030,16 +1029,11 @@ class hr_payslip(osv.osv): 'base': line.computational_expression } if line.appears_on_payslip: - if line.parent_rule_id: - for l in salary_rule_pool.browse(cr, uid, [line.parent_rule_id.id], context=context): - if l.display_child_rules == True: - update['value']['line_ids'].append(vals) - else: - if line.condition_range_min or line.condition_range_max: - if not ((value < line.condition_range_min) or (value > line.condition_range_max)): - update['value']['line_ids'].append(vals) - else: + if line.condition_range_min or line.condition_range_max: + if not ((value < line.condition_range_min) or (value > line.condition_range_max)): update['value']['line_ids'].append(vals) + else: + update['value']['line_ids'].append(vals) basic = contract.wage number = sequence_obj.get(cr, uid, 'salary.slip') @@ -1160,23 +1154,18 @@ class hr_payslip(osv.osv): value = val else: value = val - res['amount'] = salary_rule.amount res['type'] = salary_rule.type.id leave += days total += value res['total'] = value if salary_rule.appears_on_payslip: - if salary_rule.parent_rule_id: - for l in salary_rule_pool.browse(cr, uid, [salary_rule.parent_rule_id.id], context=context): - if l.display_child_rules == True: - update['value']['line_ids'].append(res) - else: - if salary_rule.condition_range_min or salary_rule.condition_range_max: - if not ((value < salary_rule.condition_range_min) or (value > salary_rule.condition_range_max)): - update['value']['line_ids'].append(res) - else: + if salary_rule.condition_range_min or salary_rule.condition_range_max: + if not ((value < salary_rule.condition_range_min) or (value > salary_rule.condition_range_max)): update['value']['line_ids'].append(res) + else: + update['value']['line_ids'].append(res) + update['value'].update({ 'basic_amount': basic, 'basic_before_leaves': round(basic_before_leaves), From e80c3728f3ccdc84f08a1e1b4cd7b0233ea38afe Mon Sep 17 00:00:00 2001 From: mtr Date: Wed, 23 Mar 2011 18:59:59 +0530 Subject: [PATCH 3/7] [IMP] hr_payroll:made 'struct_id' fields.related on hr.payslip bzr revid: mtr@mtr-20110323132959-qklty03qyl35ytpt --- addons/hr_payroll/hr_payroll.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 3800de0d3bc..c3ef38bf0a7 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -474,7 +474,7 @@ class hr_payslip(osv.osv): return 0.0 _columns = { - 'struct_id':fields.many2one('hr.payroll.structure', 'Designation', readonly=True, states={'draft': [('readonly', False)]}), + 'struct_id':fields.related('contract_id', 'struct_id', type='many2one', relation='hr.payroll.structure', string='Structure', store=True, ), 'register_id':fields.many2one('hr.payroll.register', 'Register', required=False, readonly=True, states={'draft': [('readonly', False)]}), 'name':fields.char('Name', size=64, required=False, readonly=True, states={'draft': [('readonly', False)]}), 'number':fields.char('Number', size=64, required=False, readonly=True, states={'draft': [('readonly', False)]}), @@ -1038,7 +1038,7 @@ class hr_payslip(osv.osv): basic = contract.wage number = sequence_obj.get(cr, uid, 'salary.slip') update['value'].update({ - 'struct_id': function, +# 'struct_id': function, 'number': number, 'basic_amount': round(basic), 'basic_before_leaves': round(basic), From 49ed5e133660192433c9aa83cd5ec77bfc68d075 Mon Sep 17 00:00:00 2001 From: Osenda <> Date: Thu, 24 Mar 2011 10:11:03 +0100 Subject: [PATCH 4/7] [IMP] hr_payroll: changes on payslip bzr revid: osenda-20110324091103-1krcvxhz38lf5bup --- addons/hr_payroll/hr_payroll.py | 13 ++++++++++++- addons/hr_payroll/hr_payroll_view.xml | 12 ++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index 7a56463401a..ac26b901df8 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -1177,6 +1177,17 @@ class hr_payslip(osv.osv): }) return update + def onchange_contract_id(self, cr, uid, ids, contract_id=False, struct_id=False, context=None): + if not contract_id: + return {} + res = {} + contract = self.pool.get('hr.contract').browse(cr,uid, contract_id) + res.update({ + 'struct_id':contract.struct_id.id + }) + + return {'value': res} + hr_payslip() class hr_holidays(osv.osv): @@ -1363,4 +1374,4 @@ class hr_employee(osv.osv): hr_employee() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index 75beacfa62e..65b229f40d0 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -212,6 +212,9 @@ + + + @@ -275,13 +278,18 @@ - - + + + + + + + From b97e5ce8f75bf31fde329c2037a25f1c6faf3d58 Mon Sep 17 00:00:00 2001 From: Osenda <> Date: Thu, 24 Mar 2011 09:40:09 +0100 Subject: [PATCH 6/7] [IMP]Changes on payslip from aos bzr revid: osenda-20110324084009-0xldm7gnnkayctza --- addons/hr_payroll/hr_payroll_view.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/hr_payroll/hr_payroll_view.xml b/addons/hr_payroll/hr_payroll_view.xml index 65b229f40d0..13fd6ed9260 100644 --- a/addons/hr_payroll/hr_payroll_view.xml +++ b/addons/hr_payroll/hr_payroll_view.xml @@ -605,7 +605,7 @@ - + @@ -648,9 +648,9 @@ - - - + + + From 9f43efede6031adbf4c48feec6844aff1a69a81e Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Thu, 24 Mar 2011 15:02:58 +0530 Subject: [PATCH 7/7] [FIX] small fix bzr revid: mra@mra-laptop-20110324093258-s8ykye3eatn23o09 --- addons/hr_payroll/hr_payroll.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/hr_payroll/hr_payroll.py b/addons/hr_payroll/hr_payroll.py index ac26b901df8..e4f59e083f7 100644 --- a/addons/hr_payroll/hr_payroll.py +++ b/addons/hr_payroll/hr_payroll.py @@ -689,6 +689,7 @@ class hr_payslip(osv.osv): contract = slip.employee_id.contract_id function = contract.struct_id.id + sal_structure = [] if function: sal_structure = self._get_parent_structure(cr, uid, [function], context=context) lines = [] @@ -1165,7 +1166,7 @@ class hr_payslip(osv.osv): update['value']['line_ids'].append(res) else: update['value']['line_ids'].append(res) - + update['value'].update({ 'basic_amount': basic, 'basic_before_leaves': basic_before_leaves,