Add a check on the period dates to be in the fiscal year dates

This commit is contained in:
Cédric Krier
2008-09-19 14:17:58 +02:00
parent 0a57ad48f0
commit dbfc43bc68
+10
View File
@@ -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, [