Merge pull request #5780 from expsa/younes_dev_odex25_hr

[FIX] attendances: FIX bug
This commit is contained in:
kchyounes19 2025-12-21 15:24:29 +01:00 committed by GitHub
commit 2b1ca19234
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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')