[REF]Refactoring code for date_start and date_end validation
This commit is contained in:
parent
e26e6fd1c7
commit
f0e9dbab4d
@ -68,20 +68,11 @@ class Event(models.Model):
|
|||||||
raise models.ValidationError(_('You can have subscribed people '
|
raise models.ValidationError(_('You can have subscribed people '
|
||||||
'if event is not confirmed yet'))
|
'if event is not confirmed yet'))
|
||||||
|
|
||||||
@api.constrains('date_end')
|
@api.constrains('date_start', 'date_end')
|
||||||
def _check_date_end(self):
|
def _check_dates(self):
|
||||||
"""Test si la modification de la date n'est pas postérieur à la date de début"""
|
"""Test si la modification de la date de début est infnérieure à la date de fin"""
|
||||||
if self.date_start > self.date_end:
|
if self.date_start > self.date_end:
|
||||||
raise ValidationError(
|
raise ValidationError(_('End date most be supperior to to start date'))
|
||||||
_('Date most be supperior to to start date'))
|
|
||||||
|
|
||||||
@api.constrains('date_start')
|
|
||||||
def _check_date_start(self):
|
|
||||||
"""Test si la modification de la date de fin n'est pas anterieur à la date de début"""
|
|
||||||
if self.date_end < self.date_start:
|
|
||||||
raise ValidationError(
|
|
||||||
_('Date most be inferior to to end date'))
|
|
||||||
|
|
||||||
|
|
||||||
@api.depends('date_start', 'date_end')
|
@api.depends('date_start', 'date_end')
|
||||||
def _compute_duration(self):
|
def _compute_duration(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user