[FIX]GOLEM Activity : if season is not on period, do not check start / end dates coherence

This commit is contained in:
Fabien BOURGEOIS 2018-02-27 18:49:08 +01:00
parent 021d70e828
commit 209013864e
2 changed files with 4 additions and 3 deletions

View File

@ -18,7 +18,7 @@
{ {
'name': 'GOLEM activities', 'name': 'GOLEM activities',
'summary': 'Extends Odoo products for multi-activity', 'summary': 'Extends Odoo products for multi-activity',
'version': '10.0.2.1.0', 'version': '10.0.2.1.1',
'category': 'GOLEM', 'category': 'GOLEM',
'author': 'Fabien Bourgeois, Michel Dessenne', 'author': 'Fabien Bourgeois, Michel Dessenne',
'license': 'AGPL-3', 'license': 'AGPL-3',

View File

@ -108,15 +108,16 @@ class GolemActivity(models.Model):
def _check_period(self): def _check_period(self):
""" Checks if end date if after start date """ """ Checks if end date if after start date """
for activity in self: for activity in self:
season = activity.season_id
if activity.date_start and activity.date_stop and \ if activity.date_start and activity.date_stop and \
activity.date_start > activity.date_stop: activity.date_start > activity.date_stop:
raise models.ValidationError(_('Start of the period cannot be ' raise models.ValidationError(_('Start of the period cannot be '
'after end of the period.')) 'after end of the period.'))
if activity.season_id.date_start > activity.date_start: if season.date_start and season.date_start > activity.date_start:
msg = _(u'Activity start date can not be set before ' msg = _(u'Activity start date can not be set before '
'linked season start.') 'linked season start.')
raise models.ValidationError(msg) raise models.ValidationError(msg)
if activity.season_id.date_end < activity.date_stop: if season.date_end and season.date_end < activity.date_stop:
msg = _(u'Activity end date can not be set after ' msg = _(u'Activity end date can not be set after '
'linked season end.') 'linked season end.')
raise models.ValidationError(msg) raise models.ValidationError(msg)