Skip to content
Snippets Groups Projects
Commit 11a04b2b authored by Benjamin - Le Filament's avatar Benjamin - Le Filament
Browse files

[fix] constraint only on timesheet analytic line

parent 2bc0f6fc
No related branches found
No related tags found
No related merge requests found
......@@ -157,27 +157,28 @@ class ScopHrTimesheet(models.Model):
@api.constrains("unit_amount", "date")
def _check_hours(self):
for record in self:
lines = self.search(
[
("date", "=", record.date),
("employee_id", "=", record.employee_id.id),
]
)
total = sum(lines.mapped("unit_amount"))
if (
not self.env.company.day_working
and total > self.env.company.day_duration
):
raise ValidationError(
_(
"Vous ne pouvez imputer plus de %sh sur la même journée.\n"
"Journée du %s"
)
% (
self.env.company.day_duration,
record.date.strftime("%d/%m/%Y"),
)
if record.project_id:
lines = self.search(
[
("date", "=", record.date),
("employee_id", "=", record.employee_id.id),
]
)
total = sum(lines.mapped("unit_amount"))
if (
not self.env.company.day_working
and total > self.env.company.day_duration
):
raise ValidationError(
_(
"Vous ne pouvez imputer plus de %sh sur la même journée.\n"
"Journée du %s"
)
% (
self.env.company.day_duration,
record.date.strftime("%d/%m/%Y"),
)
)
@api.constrains("date")
def _check_weekday(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment