mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[FIX] hr_payroll_attendance: duplicate attendances during initial form create
This commit is contained in:
@@ -39,6 +39,7 @@ class HrPayslip(models.Model):
|
||||
('employee_id', '=', self.employee_id.id),
|
||||
('check_out', '<=', self.date_to),
|
||||
('payslip_id', '=', False),
|
||||
('id', 'not in', attendance_to_keep.ids),
|
||||
])
|
||||
self.update({'attendance_ids': [(6, 0, attendance_to_keep.ids)]})
|
||||
|
||||
@@ -87,7 +88,7 @@ class HrPayslip(models.Model):
|
||||
|
||||
def _pre_aggregate_attendance_data(self, default_workentrytype):
|
||||
worked_attn = defaultdict(list)
|
||||
for attn in self.attendance_ids:
|
||||
for attn in self.attendance_ids.sorted('check_in'):
|
||||
if attn.worked_hours:
|
||||
# Avoid in/outs
|
||||
attn_iso = attn.check_in.isocalendar()
|
||||
|
||||
@@ -126,7 +126,11 @@ class TestUsPayslip(common.TransactionCase):
|
||||
return categories
|
||||
|
||||
def test_attendance_hourly(self):
|
||||
self.payslip._onchange_employee()
|
||||
payslip_form = common.Form(self.env['hr.payslip'])
|
||||
payslip_form.date_from = '2020-01-06'
|
||||
payslip_form.date_to = '2020-01-19'
|
||||
payslip_form.employee_id = self.employee
|
||||
self.payslip = payslip_form.save()
|
||||
self.assertTrue(self.payslip.contract_id, 'No auto-discovered contract!')
|
||||
self.payslip.compute_sheet()
|
||||
# 58.97 => 40hr regular, 18.97hr OT
|
||||
|
||||
Reference in New Issue
Block a user