From bb275f89a7d17d2761e5fc1b9e14304563af4298 Mon Sep 17 00:00:00 2001 From: Elouan Le Bars Date: Tue, 26 Nov 2019 11:52:50 +0100 Subject: [PATCH] [ADD] b_shift : constraint on irregular_start_date --- beesdoo_shift/models/cooperative_status.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/beesdoo_shift/models/cooperative_status.py b/beesdoo_shift/models/cooperative_status.py index 494636a..eb3a400 100644 --- a/beesdoo_shift/models/cooperative_status.py +++ b/beesdoo_shift/models/cooperative_status.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from openerp import models, fields, api, _ -from openerp.exceptions import ValidationError +from openerp.exceptions import ValidationError, UserError from datetime import timedelta, datetime import logging @@ -201,6 +201,11 @@ class CooperativeStatus(models.Model): next_countdown_date = date rec.next_countdown_date = next_countdown_date + @api.constrains("working_mode", "irregular_start_date") + def _constrains_irregular_start_date(self): + if self.working_mode == "irregular" and not self.irregular_start_date: + raise UserError(_("Irregular workers must have an irregular start date.")) + def _next_countdown_date(self, irregular_start_date, today=False): """ Return the next countdown date given irregular_start_date and