From 3a79d2cf2e02a2337b7dcc0a8a54dff32c6eb2b9 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 22 Dec 2017 12:09:13 +0100 Subject: [PATCH] [FIX] hr_payroll: salary structure - Create payslip - Add a contract with any structure - Add a structure in payslip, different from the one defined in step 2 - Confirm or compute sheet Payslip is computed using the contract structure, while it should be computed using the payslip structure. Closes #21567 opw-787671 --- addons/hr_payroll/models/hr_payslip.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/addons/hr_payroll/models/hr_payslip.py b/addons/hr_payroll/models/hr_payslip.py index 3aaa01910ee..fdf93d99951 100644 --- a/addons/hr_payroll/models/hr_payslip.py +++ b/addons/hr_payroll/models/hr_payslip.py @@ -311,7 +311,10 @@ class HrPayslip(models.Model): baselocaldict = {'categories': categories, 'rules': rules, 'payslip': payslips, 'worked_days': worked_days, 'inputs': inputs} #get the ids of the structures on the contracts and their parent id as well contracts = self.env['hr.contract'].browse(contract_ids) - structure_ids = contracts.get_all_structures() + if len(contracts) == 1 and payslip.struct_id: + structure_ids = list(set(payslip.struct_id._get_parent_structure().ids)) + else: + structure_ids = contracts.get_all_structures() #get the rules of the structure and thier children rule_ids = self.env['hr.payroll.structure'].browse(structure_ids).get_all_rules() #run the rules by sequence