[FIX] attendances: FIX bug

This commit is contained in:
younes 2025-12-21 15:23:00 +01:00
parent 7f2833113d
commit 27f093bcb7
1 changed files with 2 additions and 2 deletions

View File

@ -60,7 +60,7 @@ class HrAttendanceReport(models.Model):
def unlink(self):
for rec in self:
if rec.state != 'draft':
if rec.state != 'draft' and not self._context.get('can_delete'):
raise exceptions.Warning(_('You can not delete record in state not in draft'))
return super(HrAttendanceReport, self).unlink()
@ -466,7 +466,7 @@ class HrAttendanceReport(models.Model):
'additional_hours': sum_line.additional_hours + sum(sum_recs.mapped('line_ids.additional_hours')),
})
recs.unlink()
recs.with_context(can_delete=True).unlink()
def _get_email_template(self):
return self.env.ref('attendances.emapproval_line')