[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: <field name="quantity">worked_days.WORK100 and worked_days.WORK100.number_of_days</field>
Should become <field name="quantity">worked_days.WORK100 and sum(worked_days.WORK100.mapped('number_of_days'))</field>

closes odoo/odoo#26386
This commit is contained in:
David Arnold
2018-11-13 17:05:00 +00:00
committed by Yannick Tivisse
parent b8c5637e7e
commit d1fd939bdb
+5 -4
View File
@@ -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)