forked from Yaltik/golem
[TMP] Test if date_start date_end is required and vice-versa AND unit test
This commit is contained in:
parent
8cf4a1f07f
commit
e7ba4b91f8
@ -42,8 +42,7 @@ class GolemSeason(models.Model):
|
|||||||
def _onchange_season_dates(self):
|
def _onchange_season_dates(self):
|
||||||
""" Sets defaults dates according to membership type """
|
""" Sets defaults dates according to membership type """
|
||||||
for season in self:
|
for season in self:
|
||||||
if season.membership_id:
|
if season.membership_id and not season.date_start:
|
||||||
if not season.date_start:
|
|
||||||
season.update({
|
season.update({
|
||||||
'date_start': season.membership_id.membership_date_from,
|
'date_start': season.membership_id.membership_date_from,
|
||||||
'date_end': season.membership_id.membership_date_to
|
'date_end': season.membership_id.membership_date_to
|
||||||
@ -59,7 +58,6 @@ class GolemSeason(models.Model):
|
|||||||
raise models.ValidationError(_('The date end is required'))
|
raise models.ValidationError(_('The date end is required'))
|
||||||
elif season.date_end and not season.date_start:
|
elif season.date_end and not season.date_start:
|
||||||
raise models.ValidationError(_('The date start is required'))
|
raise models.ValidationError(_('The date start is required'))
|
||||||
|
|
||||||
if season.date_start > season.date_end:
|
if season.date_start > season.date_end:
|
||||||
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.'))
|
||||||
|
@ -74,9 +74,8 @@ class TestGolemSeason(TransactionCase):
|
|||||||
'membership_date_to': '2018-11-01'})
|
'membership_date_to': '2018-11-01'})
|
||||||
|
|
||||||
new_season = self.env['golem.season'].create({'name': 'Name',
|
new_season = self.env['golem.season'].create({'name': 'Name',
|
||||||
'membership_id': membership.id})
|
'membership_id': membership.id,
|
||||||
|
'membership_date_from': '2017-11-01',
|
||||||
new_season._onchange_season_dates()
|
'membership_date_to': '2018-11-01'})
|
||||||
|
|
||||||
self.assertEqual(new_season.date_start, membership.membership_date_from)
|
self.assertEqual(new_season.date_start, membership.membership_date_from)
|
||||||
self.assertEqual(new_season.date_end, membership.membership_date_to)
|
self.assertEqual(new_season.date_end, membership.membership_date_to)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user