From 57ae896b10661537859240dcf4fbb3a74a1c5a42 Mon Sep 17 00:00:00 2001 From: Joel Grand-Guillaume Date: Tue, 19 Aug 2008 11:15:24 +0200 Subject: [PATCH] Add constraint on hr_timesheet_sheet to prevent keyerror when bropwsing all timesheet bzr revid: joel.grandguillaume@camptocamp.com-20080819091524-rcdsj0mlfznubs87 --- addons/hr_timesheet_sheet/hr_timesheet_sheet.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index 56bf68750db..53e5087a1fa 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -276,8 +276,16 @@ class hr_timesheet_sheet(osv.osv): return False return True + def _date_current_check(self, cr, uid, ids): + for sheet in self.browse(cr, uid, ids): + if sheet.date_current < sheet.date_from or sheet.date_current > sheet.date_to: + return False + return True + + _constraints = [ - (_sheet_date, 'You can not have 2 timesheets that overlaps !', ['date_from','date_to']) + (_sheet_date, 'You can not have 2 timesheets that overlaps !', ['date_from','date_to']), + (_date_current_check, 'You must select a Current date wich is in the timesheet dates !', ['date_current']), ] def action_set_to_draft(self, cr, uid, ids, *args):