From dbfc43bc68f4cf36805810bbf248258942f0cd5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 19 Sep 2008 14:17:58 +0200 Subject: [PATCH] Add a check on the period dates to be in the fiscal year dates --- period.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/period.py b/period.py index ad0c0ca7a5..b3923ab51b 100644 --- a/period.py +++ b/period.py @@ -38,6 +38,7 @@ class Period(OSV): super(Period, self).__init__() self._constraints += [ ('check_dates', 'periods_overlaps'), + ('check_fiscalyear_dates', 'fiscalyear_dates'), ('check_post_move_sequence', 'different_move_sequence'), ] self._order.insert(0, ('start_date', 'ASC')) @@ -57,6 +58,8 @@ class Period(OSV): 'periods_overlaps': 'You can not have 2 periods that overlaps!', 'different_move_sequence': 'You must have different ' \ 'post move sequence per fiscal year!', + 'fiscalyear_dates': 'The period dates must be in ' \ + 'the fiscal year dates', }) def default_state(self, cursor, user, context=None): @@ -85,6 +88,13 @@ class Period(OSV): return False return True + def check_fiscalyear_dates(self, cursor, user, ids): + for period in self.browse(cursor, user, ids): + if period.start_date < period.fiscalyear.start_date \ + or period.end_date > period.fiscalyear.end_date: + return False + return True + def check_post_move_sequence(self, cursor, user, ids): for period in self.browse(cursor, user, ids): if self.search(cursor, user, [