Skip to content

Commit

Permalink
[FIX] calendar: prevent updating event with a start date greater than…
Browse files Browse the repository at this point in the history
… the end date

Setting a constraint on an old api style computed field is broken in Odoo 8.0
The constraint is checked with the old value of the computed field, not the new one
So, it was possible to update an event with a start date greater than the stop date
And once done, it was impossible to correct the mistake
  • Loading branch information
beledouxdenis committed Jan 8, 2015
1 parent c53951e commit 6c78541
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions addons/calendar/calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,12 +971,14 @@ def _get_default_partners(self, cr, uid, ctx=None):

def _check_closing_date(self, cr, uid, ids, context=None):
for event in self.browse(cr, uid, ids, context=context):
if event.stop < event.start:
if event.start_datetime and event.stop_datetime < event.start_datetime:
return False
if event.start_date and event.stop_date < event.start_date:
return False
return True

_constraints = [
(_check_closing_date, 'Error ! End date cannot be set before start date.', ['start', 'stop'])
(_check_closing_date, 'Error ! End date cannot be set before start date.', ['start_datetime', 'stop_datetime', 'start_date', 'stop_date'])
]

def onchange_allday(self, cr, uid, ids, start=False, end=False, starttime=False, endtime=False, startdatetime=False, enddatetime=False, checkallday=False, context=None):
Expand Down

0 comments on commit 6c78541

Please sign in to comment.