[IMP]GOLEM Seasons : only 1 season per default without ability to delete linked ones

This commit is contained in:
Fabien Bourgeois 2016-07-11 07:11:27 +02:00
parent b4b164a10f
commit e2a0671b4b
4 changed files with 77 additions and 29 deletions

View File

@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-06-28 03:18+0000\n"
"PO-Revision-Date: 2016-06-28 03:18+0000\n"
"POT-Creation-Date: 2016-07-11 05:07+0000\n"
"PO-Revision-Date: 2016-07-11 05:07+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@ -16,6 +16,11 @@ msgstr ""
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. module: golem_season
#: field:golem.season,member_counter:0
msgid "Counter for member number generation"
msgstr "Compteur pour la génération des numéros d'adhérents"
#. module: golem_season
#: field:golem.season,create_uid:0
msgid "Created by"
@ -31,6 +36,11 @@ msgstr "Créé le"
msgid "Default season"
msgstr "Saison par défaut"
#. module: golem_season
#: view:golem.season:golem_season.form
msgid "Default season for views ?"
msgstr "Saison affichée par défaut dans toutes les listes ?"
#. module: golem_season
#: field:golem.season,is_default:0
msgid "Default season for views?"
@ -42,7 +52,7 @@ msgid "Display Name"
msgstr "Nom affiché"
#. module: golem_season
#: code:addons/golem_season/models/golem_season.py:49
#: code:addons/golem_season/models/golem_season.py:50
#, python-format
msgid "End of the period is in range of an existing period {}"
msgstr "La fin de la période est en conflit avec la période existante {}"
@ -50,13 +60,13 @@ msgstr "La fin de la période est en conflit avec la période existante {}"
#. module: golem_season
#: model:ir.model,name:golem_season.model_golem_season
msgid "GOLEM Season"
msgstr "GOLEM : Saison"
msgstr "Saison"
#. module: golem_season
#: model:ir.actions.act_window,name:golem_season.action_list
#: model:ir.ui.menu,name:golem_season.menu_seasons
msgid "GOLEM Seasons"
msgstr "GOLEM : Saisons"
msgstr "Saisons"
#. module: golem_season
#: field:golem.season,id:0
@ -78,6 +88,11 @@ msgstr "Dernière modification par"
msgid "Last Updated on"
msgstr "Dernière modification le"
#. module: golem_season
#: view:golem.season:golem_season.form
msgid "Make this season as default"
msgstr "Activer cette saison par défaut"
#. module: golem_season
#: field:golem.season,date_end:0
msgid "Period end"
@ -89,7 +104,7 @@ msgid "Period start"
msgstr "Début de la période"
#. module: golem_season
#: code:addons/golem_season/models/golem_season.py:53
#: code:addons/golem_season/models/golem_season.py:54
#, python-format
msgid "Period {} cannot be included into current period"
msgstr "La période {} ne peut être incluse dans la période en cours"
@ -105,13 +120,13 @@ msgid "Season name"
msgstr "Nom de la saison"
#. module: golem_season
#: code:addons/golem_season/models/golem_season.py:38
#: code:addons/golem_season/models/golem_season.py:39
#, python-format
msgid "Start of the period cannot be after end of the period."
msgstr "Le début de la période ne peut être postérieur à sa fin."
#. module: golem_season
#: code:addons/golem_season/models/golem_season.py:45
#: code:addons/golem_season/models/golem_season.py:46
#, python-format
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 {}"

View File

@ -6,8 +6,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-06-28 03:18+0000\n"
"PO-Revision-Date: 2016-06-28 03:18+0000\n"
"POT-Creation-Date: 2016-07-11 05:06+0000\n"
"PO-Revision-Date: 2016-07-11 05:06+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@ -15,6 +15,11 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: golem_season
#: field:golem.season,member_counter:0
msgid "Counter for member number generation"
msgstr ""
#. module: golem_season
#: field:golem.season,create_uid:0
msgid "Created by"
@ -30,6 +35,11 @@ msgstr ""
msgid "Default season"
msgstr ""
#. module: golem_season
#: view:golem.season:golem_season.form
msgid "Default season for views ?"
msgstr ""
#. module: golem_season
#: field:golem.season,is_default:0
msgid "Default season for views?"
@ -41,7 +51,7 @@ msgid "Display Name"
msgstr ""
#. module: golem_season
#: code:addons/golem_season/models/golem_season.py:49
#: code:addons/golem_season/models/golem_season.py:50
#, python-format
msgid "End of the period is in range of an existing period {}"
msgstr ""
@ -77,6 +87,11 @@ msgstr ""
msgid "Last Updated on"
msgstr ""
#. module: golem_season
#: view:golem.season:golem_season.form
msgid "Make this season as default"
msgstr ""
#. module: golem_season
#: field:golem.season,date_end:0
msgid "Period end"
@ -88,7 +103,7 @@ msgid "Period start"
msgstr ""
#. module: golem_season
#: code:addons/golem_season/models/golem_season.py:53
#: code:addons/golem_season/models/golem_season.py:54
#, python-format
msgid "Period {} cannot be included into current period"
msgstr ""
@ -104,13 +119,13 @@ msgid "Season name"
msgstr ""
#. module: golem_season
#: code:addons/golem_season/models/golem_season.py:38
#: code:addons/golem_season/models/golem_season.py:39
#, python-format
msgid "Start of the period cannot be after end of the period."
msgstr ""
#. module: golem_season
#: code:addons/golem_season/models/golem_season.py:45
#: code:addons/golem_season/models/golem_season.py:46
#, python-format
msgid "Start of the period is in range of an existing period {}"
msgstr ""

View File

@ -29,7 +29,6 @@ class GolemSeason(models.Model):
readonly=True, default=0)
date_start = fields.Date('Period start')
date_end = fields.Date('Period end')
is_default = fields.Boolean('Default season for views?')
@api.constrains('date_start', 'date_end')
def _check_period(self):
@ -55,17 +54,30 @@ class GolemSeason(models.Model):
'period'.format(s.name))
raise models.ValidationError(msg)
@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 """
is_new_default = values.get('is_default')
is_default = fields.Boolean('Default season for views?', readonly=True)
@api.one
def do_default_season(self):
""" is_default on and ensure that only one is_default is active """
old_default_season = self.search([('is_default', '=', True)])
res = super(GolemSeason, self).write(values)
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
old_default_season.is_default = False
self.is_default = True
all_members = self.env['golem.member'].search([])
all_members._compute_is_current()
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

View File

@ -27,9 +27,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="arch" type="xml">
<form>
<sheet>
<div class="oe_right">
<button name="do_default_season" type="object"
string="Make this season as default" class="oe_highlight"
help="Default season for views ?"
attrs="{'invisible': [('is_default', '=', True)]}" />
</div>
<group string="Season">
<field name="is_default" invisible="True" />
<field name="name" />
<field name="is_default" />
<field name="date_start" />
<field name="date_end" />
</group>