From d1fd939bdb6634900c0abc4205ef3552fb2165aa Mon Sep 17 00:00:00 2001 From: David Arnold Date: Tue, 14 Aug 2018 16:38:36 +0000 Subject: [PATCH] [IMP] hr_payroll: Manage duplicated 'code' on input/worked_days lines Purpose ======= Before this commit, inputs (workdays or inputs) could not manage two lines having the same code (Example: two holidays of the same type in the payslip period). The result was a wrong computation as only one of the 2 lines was taken into account. Without even warning the user. Specification ============= Put recordsets on the local dictionaries, where previously only a browse record was set. This requires a modification on the salary rules to make them work (with multiple lines, otherwise it is still ok). Example: worked_days.WORK100 and worked_days.WORK100.number_of_days Should become worked_days.WORK100 and sum(worked_days.WORK100.mapped('number_of_days')) closes odoo/odoo#26386 --- addons/hr_payroll/models/hr_payslip.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/hr_payroll/models/hr_payslip.py b/addons/hr_payroll/models/hr_payslip.py index 0c2eeb7aebf..e15d1379586 100644 --- a/addons/hr_payroll/models/hr_payslip.py +++ b/addons/hr_payroll/models/hr_payslip.py @@ -226,10 +226,11 @@ class HrPayslip(models.Model): worked_days_dict = {} inputs_dict = {} blacklist = [] - for worked_days_line in self.worked_days_line_ids: - worked_days_dict[worked_days_line.code] = worked_days_line - for input_line in self.input_line_ids: - inputs_dict[input_line.code] = input_line + + for code in self.worked_days_line_ids.mapped('code'): + worked_days_dict[code] = self.worked_days_line_ids.filtered(lambda l: l.code == code) + for code in self.input_line_ids.mapped('code'): + inputs_dict[code] = self.input_line_ids.filtered(lambda l: l.code == code) categories = BrowsableObject(self.employee_id.id, {}, self.env) inputs = InputLine(self.employee_id.id, inputs_dict, self.env)