From d456b1dd5c205801842e529759294189746e587e Mon Sep 17 00:00:00 2001 From: Fabien Bourgeois Date: Wed, 13 Jul 2016 17:43:35 +0200 Subject: [PATCH] [FIX]GOLEM Season : make first creation as default in views --- golem_season/models/golem_season.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/golem_season/models/golem_season.py b/golem_season/models/golem_season.py index cecb0f2..1864a04 100644 --- a/golem_season/models/golem_season.py +++ b/golem_season/models/golem_season.py @@ -72,8 +72,18 @@ class GolemSeason(models.Model): if 'golem.activity' in self.env.registry: self.env['golem.activity'].search([])._compute_is_current() + @api.model + @api.returns('self', lambda rec: rec.id) + def create(self, values): + """ If the season if the first one created, it must be by default """ + print values + if self.search_count([]) == 0: + values['is_default'] = True + return super(GolemSeason, self).create(values) + @api.multi def unlink(self): + """ Forbids default season removal """ for s in self: if s.is_default: emsg = _('You can\'t delete the default season')