Skip to content
Extraits de code Groupes Projets
Valider 79136f97 rédigé par Benjamin - Le Filament's avatar Benjamin - Le Filament
Parcourir les fichiers

[cgscop #179] ajout contrainte sur imputations weekend et resource.calendar.leaves

parent 13d8b895
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
# © 2019 Le Filament (<http://www.le-filament.com>) # © 2019 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from datetime import datetime, time
from odoo import models, fields, api from odoo import models, fields, api
from odoo.exceptions import UserError, ValidationError from odoo.exceptions import UserError, ValidationError
...@@ -108,6 +110,20 @@ class ScopHrTimesheet(models.Model): ...@@ -108,6 +110,20 @@ class ScopHrTimesheet(models.Model):
"Vous ne pourvez imputer plus de 8h sur la même journée.\n" "Vous ne pourvez imputer plus de 8h sur la même journée.\n"
"Journée du %s" % record.date.strftime("%d/%m/%Y")) "Journée du %s" % record.date.strftime("%d/%m/%Y"))
@api.constrains('date')
def _check_weekday(self):
for line in self:
dt = datetime.combine(line.date, time(12, 00))
holiday = self.env['resource.calendar.leaves'].search([
('company_id', '=', self.env.user.company_id.id),
('date_from', '<=', dt),
('date_to', '>=', dt),
])
if line.date.weekday() in (5, 6) or holiday:
raise ValidationError(
"Vous ne pourvez imputer du temps sur un weekend "
"ou un jour férié.")
# ------------------------------------------------------ # ------------------------------------------------------
# Override ORM # Override ORM
# ------------------------------------------------------ # ------------------------------------------------------
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter