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

[cgscop #178] ajout d'une contrainte sur la quantité : 8h par jour max

parent 57c3f0c2
No related branches found
No related tags found
No related merge requests found
...@@ -92,6 +92,20 @@ class ScopHrTimesheet(models.Model): ...@@ -92,6 +92,20 @@ class ScopHrTimesheet(models.Model):
fields.Datetime.now() > self.partner_id.ur_regional_convention_date: fields.Datetime.now() > self.partner_id.ur_regional_convention_date:
self.ur_regional_convention_id = self.partner_id.ur_regional_convention_id self.ur_regional_convention_id = self.partner_id.ur_regional_convention_id
# ------------------------------------------------------
# Contrains
# ------------------------------------------------------
@api.constrains('unit_amount')
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 total > 8:
raise ValidationError(
"Vous ne pourvez imputer plus de 8h sur la même journée")
# ------------------------------------------------------ # ------------------------------------------------------
# Override ORM # Override ORM
# ------------------------------------------------------ # ------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment