add validation for overlap two timesheet entries
This commit is contained in:
parent
90f690f3eb
commit
bffade6c6e
|
@ -224,3 +224,17 @@ class AccountAnalyticLine(models.Model):
|
|||
for rec in self:
|
||||
if rec.start_datetime:
|
||||
rec.date = rec.start_datetime.date()
|
||||
|
||||
@api.constrains('start_datetime', 'end_datetime', 'employee_id')
|
||||
def _check_date(self):
|
||||
for entry in self.filtered('employee_id'):
|
||||
domain = [
|
||||
('start_datetime', '<', entry.end_datetime),
|
||||
('end_datetime', '>', entry.start_datetime),
|
||||
('employee_id', '=', entry.employee_id.id),
|
||||
('id', '!=', entry.id),
|
||||
]
|
||||
entries = self.search_count(domain)
|
||||
if entries:
|
||||
raise ValidationError(
|
||||
_('You can not set 2 timesheet entries that overlaps on the same day for the same employee.'))
|
||||
|
|
Loading…
Reference in New Issue