Add constraint on hr_timesheet_sheet to prevent keyerror when bropwsing all timesheet

bzr revid: joel.grandguillaume@camptocamp.com-20080819091524-rcdsj0mlfznubs87
This commit is contained in:
Joel Grand-Guillaume 2008-08-19 11:15:24 +02:00
parent ea3d7a5414
commit 57ae896b10
1 changed files with 9 additions and 1 deletions

View File

@ -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):