From 66c3964464c1795dc8c491e90e63a3948681e0cd Mon Sep 17 00:00:00 2001 From: Fabien Bourgeois Date: Mon, 11 Jul 2016 07:23:58 +0200 Subject: [PATCH] [FIX]GOLEM Season : do now allow default_season removal --- golem_season/i18n/fr.po | 10 ++++++++-- golem_season/i18n/golem_season.pot | 10 ++++++++-- golem_season/models/golem_season.py | 22 ++++++++-------------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/golem_season/i18n/fr.po b/golem_season/i18n/fr.po index 3b03def..7a45dd3 100644 --- a/golem_season/i18n/fr.po +++ b/golem_season/i18n/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-07-11 05:07+0000\n" -"PO-Revision-Date: 2016-07-11 05:07+0000\n" +"POT-Creation-Date: 2016-07-11 05:22+0000\n" +"PO-Revision-Date: 2016-07-11 05:22+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -131,3 +131,9 @@ msgstr "Le début de la période ne peut être postérieur à sa fin." msgid "Start of the period is in range of an existing period {}" msgstr "Le début de la période est en conflit avec la période existante {}" +#. module: golem_season +#: code:addons/golem_season/models/golem_season.py:74 +#, python-format +msgid "You can't delete the default season" +msgstr "Vous ne pouvez pas supprimer la saison par défaut" + diff --git a/golem_season/i18n/golem_season.pot b/golem_season/i18n/golem_season.pot index c36f704..0a06491 100644 --- a/golem_season/i18n/golem_season.pot +++ b/golem_season/i18n/golem_season.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-07-11 05:06+0000\n" -"PO-Revision-Date: 2016-07-11 05:06+0000\n" +"POT-Creation-Date: 2016-07-11 05:22+0000\n" +"PO-Revision-Date: 2016-07-11 05:22+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -130,3 +130,9 @@ msgstr "" msgid "Start of the period is in range of an existing period {}" msgstr "" +#. module: golem_season +#: code:addons/golem_season/models/golem_season.py:74 +#, python-format +msgid "You can't delete the default season" +msgstr "" + diff --git a/golem_season/models/golem_season.py b/golem_season/models/golem_season.py index b2e2b8a..9cae62e 100644 --- a/golem_season/models/golem_season.py +++ b/golem_season/models/golem_season.py @@ -67,17 +67,11 @@ class GolemSeason(models.Model): all_members._compute_number() self.env['golem.activity'].search([])._compute_is_current() - # @api.multi - # def write(self, values): - # """ Extends write to recomputes all current members in case of - # is_default changes and ensures that only one is_default is active """ - # res = super(GolemSeason, self).write(values) - # is_new_default = values.get('is_default') - # old_default_season = self.search([('is_default', '=', True)]) - # if is_new_default: - # if old_default_season: - # old_default_season.is_default = False - # self.env['golem.member'].search([])._compute_is_current() - # self.env['golem.member'].search([])._compute_number() - # self.env['golem.activity'].search([])._compute_is_current() - # return res + @api.multi + def unlink(self): + for s in self: + if s.is_default: + emsg = _('You can\'t delete the default season') + raise models.ValidationError(emsg) + else: + return super(GolemSeason, self).unlink()