[FIX]GOLEM SEASON : use update for onchange + unit test warning on membership creation

This commit is contained in:
Fabien BOURGEOIS 2018-01-16 10:53:16 +01:00
parent 5143c1d985
commit 28407b4acf
2 changed files with 5 additions and 3 deletions

View File

@ -44,8 +44,10 @@ class GolemSeason(models.Model):
for season in self:
if season.membership_id:
if not season.date_start:
season.date_start = season.membership_id.membership_date_from
season.date_end = season.membership_id.membership_date_to
season.update({
'date_start': season.membership_id.membership_date_from,
'date_end': season.membership_id.membership_date_to
})
@api.constrains('date_start', 'date_end')
def _check_period(self):

View File

@ -58,7 +58,7 @@ class TestGolemSeason(TransactionCase):
def test__onchange_season_dates(self):
""" Test if membership date """
membership = self.env['product.template'].create({'name': 'Name',
'membership_id': 'truc',
'membership': True,
'membership_date_from': '2017-11-01',
'membership_date_to': '2018-11-01'})