From 30ddbbccc25d10164e873d33d1532255c5201129 Mon Sep 17 00:00:00 2001 From: Fabien Bourgeois Date: Mon, 10 Oct 2016 11:09:57 +0200 Subject: [PATCH] [IMP]GOLEM Activity Session Registrations simplification : no state handling per default --- .../i18n/fr.po | 24 ++++++--- .../golem_activity_session_registration.pot | 24 ++++++--- .../golem_activity_session_registration.py | 54 +------------------ ...lem_activity_session_registration_view.xml | 4 +- .../views/golem_activity_view.xml | 4 +- .../views/golem_member_view.xml | 23 ++------ 6 files changed, 39 insertions(+), 94 deletions(-) diff --git a/golem_activity_session_registration/i18n/fr.po b/golem_activity_session_registration/i18n/fr.po index 0dff78c..4a3114d 100644 --- a/golem_activity_session_registration/i18n/fr.po +++ b/golem_activity_session_registration/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-09-22 11:49+0000\n" -"PO-Revision-Date: 2016-09-22 11:49+0000\n" +"POT-Creation-Date: 2016-10-10 09:08+0000\n" +"PO-Revision-Date: 2016-10-10 09:08+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -17,7 +17,7 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n > 1);\n" #. module: golem_activity_session_registration -#: view:golem.member:golem_activity_session_registration.sessions_inscription +#: view:golem.member:golem_activity_session_registration.sessions_registration #: field:golem.member,activity_session_registration_ids:0 msgid "Activities" msgstr "Activités" @@ -48,7 +48,7 @@ msgid "Default season" msgstr "Saison par défaut" #. module: golem_activity_session_registration -#: view:golem.member:golem_activity_session_registration.sessions_inscription +#: view:golem.member:golem_activity_session_registration.sessions_registration msgid "Default season activities" msgstr "Activités de la saison affichée par défaut" @@ -112,6 +112,16 @@ msgstr "Dernière mise à jour par" msgid "Last Updated on" msgstr "Mis à jour pour la dernière fois le" +#. module: golem_activity_session_registration +#: sql_constraint:golem.activity.session.registration:0 +msgid "Le membre a déjà été inscrit à cette séance." +msgstr "Le membre a déjà été inscrit à cette séance." + +#. module: golem_activity_session_registration +#: sql_constraint:golem.activity.session:0 +msgid "Le nombre de places ne peut pas être négatif" +msgstr "Le nombre de places ne peut pas être négatif" + #. module: golem_activity_session_registration #: field:golem.activity.session.registration,member_id:0 msgid "Member" @@ -125,7 +135,6 @@ msgstr "Adhérents" #. module: golem_activity_session_registration #: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:32 -#: sql_constraint:golem.activity.session:0 #, python-format msgid "Number of places cannot be negative." msgstr "Le nombre de places ne peut pas être négatif" @@ -177,14 +186,13 @@ msgid "Subscription" msgstr "Inscription" #. module: golem_activity_session_registration -#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:91 +#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:90 #, python-format msgid "Subscription can not be executed : the targeted member is not on the same season as the session." msgstr "L'inscription n'a pas pu être enregistrée : le membre visé n'est pas ahdérant pour la même saison que celle pendant laquelle se déroule la séance." #. module: golem_activity_session_registration -#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:83 -#: sql_constraint:golem.activity.session.registration:0 +#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:82 #, python-format msgid "This member has already been registered for this session." msgstr "Le membre a déjà été inscrit à cette séance." diff --git a/golem_activity_session_registration/i18n/golem_activity_session_registration.pot b/golem_activity_session_registration/i18n/golem_activity_session_registration.pot index 3352fe1..2cf5dfc 100644 --- a/golem_activity_session_registration/i18n/golem_activity_session_registration.pot +++ b/golem_activity_session_registration/i18n/golem_activity_session_registration.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 8.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-09-22 11:49+0000\n" -"PO-Revision-Date: 2016-09-22 11:49+0000\n" +"POT-Creation-Date: 2016-10-10 09:08+0000\n" +"PO-Revision-Date: 2016-10-10 09:08+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,7 +16,7 @@ msgstr "" "Plural-Forms: \n" #. module: golem_activity_session_registration -#: view:golem.member:golem_activity_session_registration.sessions_inscription +#: view:golem.member:golem_activity_session_registration.sessions_registration #: field:golem.member,activity_session_registration_ids:0 msgid "Activities" msgstr "" @@ -47,7 +47,7 @@ msgid "Default season" msgstr "" #. module: golem_activity_session_registration -#: view:golem.member:golem_activity_session_registration.sessions_inscription +#: view:golem.member:golem_activity_session_registration.sessions_registration msgid "Default season activities" msgstr "" @@ -111,6 +111,16 @@ msgstr "" msgid "Last Updated on" msgstr "" +#. module: golem_activity_session_registration +#: sql_constraint:golem.activity.session.registration:0 +msgid "Le membre a déjà été inscrit à cette séance." +msgstr "" + +#. module: golem_activity_session_registration +#: sql_constraint:golem.activity.session:0 +msgid "Le nombre de places ne peut pas être négatif" +msgstr "" + #. module: golem_activity_session_registration #: field:golem.activity.session.registration,member_id:0 msgid "Member" @@ -124,7 +134,6 @@ msgstr "" #. module: golem_activity_session_registration #: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:32 -#: sql_constraint:golem.activity.session:0 #, python-format msgid "Number of places cannot be negative." msgstr "" @@ -176,14 +185,13 @@ msgid "Subscription" msgstr "" #. module: golem_activity_session_registration -#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:91 +#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:90 #, python-format msgid "Subscription can not be executed : the targeted member is not on the same season as the session." msgstr "" #. module: golem_activity_session_registration -#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:83 -#: sql_constraint:golem.activity.session.registration:0 +#: code:addons/golem_activity_session_registration/models/golem_activity_session_registration.py:82 #, python-format msgid "This member has already been registered for this session." msgstr "" diff --git a/golem_activity_session_registration/models/golem_activity_session_registration.py b/golem_activity_session_registration/models/golem_activity_session_registration.py index 2525a90..ff931f5 100644 --- a/golem_activity_session_registration/models/golem_activity_session_registration.py +++ b/golem_activity_session_registration/models/golem_activity_session_registration.py @@ -23,45 +23,6 @@ class GolemMember(models.Model): activity_session_registration_ids = fields.One2many( 'golem.activity.session.registration', 'member_id', 'Activities') - has_draft_registrations = fields.Boolean( - 'Has draft registrations ?', - compute='_compute_has_draft_registrations') - - @api.one - @api.depends('activity_session_registration_ids') - def _compute_has_draft_registrations(self): - """ Check if there are draft states in member activities """ - for r in self.activity_session_registration_ids: - if r.state == 'draft': - self.has_draft_registrations = True - return - self.has_draft_registrations = False - - @api.one - def do_validate_registrations(self): - """ Validate all draft registrations """ - draft_registrations = self.activity_session_registration_ids.filtered( - lambda r: r.state == 'draft') - draft_registrations.write({'state': 'confirmed'}) - - @api.multi - def write(self, values): - """ Handle removed activities to be canceled """ - if 'activity_session_registration_ids' in values: - rids = values['activity_session_registration_ids'] - r_keep, r_removed = [], [] - for r in rids: # == 2 is removal case - r_removed.append(r) if r[0] == 2 else r_keep.append(r) - rObj = self.env['golem.activity.session.registration'] - for rem in r_removed: - r = rObj.browse([rem[1]]) - # if already canceled, let it be removed, else cancel it - if r.state != 'canceled': - r.state = 'canceled' - else: - r_keep.append(rem) - values['activity_session_registration_ids'] = r_keep - return super(GolemMember, self).write(values) class GolemActivitySession(models.Model): @@ -78,8 +39,7 @@ class GolemActivitySession(models.Model): @api.one @api.depends('activity_session_registration_ids') def _compute_places_used(self): - rids = self.activity_session_registration_ids - self.places_used = len(rids.filtered(lambda r: r.state == 'confirmed')) + self.places_used = len(self.activity_session_registration_ids) places = fields.Integer('Places', default=20) places_remain = fields.Integer('Remaining places', store=True, @@ -103,9 +63,6 @@ class GolemActivitySessionRegistration(models.Model): _name = 'golem.activity.session.registration' _description = 'GOLEM Activity Session Registration' - state = fields.Selection([('draft', 'Draft'), ('confirmed', 'Confirmed'), - ('canceled', 'Canceled')], required=True, - default='draft') member_id = fields.Many2one('golem.member', string='Member', required=True, ondelete='cascade') session_id = fields.Many2one('golem.activity.session', required=True, @@ -133,12 +90,3 @@ class GolemActivitySessionRegistration(models.Model): emsg = _('Subscription can not be executed : the targeted ' 'member is not on the same season as the session.') raise models.ValidationError(emsg) - - @api.multi - def write(self, values): - """ Recomputes values linked to registrations when state change """ - res = super(GolemActivitySessionRegistration, self).write(values) - if values['state']: - for r in self: - r.session_id._compute_places_used() - return res diff --git a/golem_activity_session_registration/views/golem_activity_session_registration_view.xml b/golem_activity_session_registration/views/golem_activity_session_registration_view.xml index e28293e..0c7f581 100644 --- a/golem_activity_session_registration/views/golem_activity_session_registration_view.xml +++ b/golem_activity_session_registration/views/golem_activity_session_registration_view.xml @@ -40,9 +40,7 @@ along with this program. If not, see . Session registration list golem.activity.session.registration - - + diff --git a/golem_activity_session_registration/views/golem_activity_view.xml b/golem_activity_session_registration/views/golem_activity_view.xml index 5c28578..b82e68b 100644 --- a/golem_activity_session_registration/views/golem_activity_view.xml +++ b/golem_activity_session_registration/views/golem_activity_view.xml @@ -33,9 +33,7 @@ along with this program. If not, see . - - + diff --git a/golem_activity_session_registration/views/golem_member_view.xml b/golem_activity_session_registration/views/golem_member_view.xml index 0acf0bd..7bc21a7 100644 --- a/golem_activity_session_registration/views/golem_member_view.xml +++ b/golem_activity_session_registration/views/golem_member_view.xml @@ -19,35 +19,20 @@ along with this program. If not, see . - - Add sessions inscriptions to member form + + Add sessions registrations to member form golem.member +

Default season activities

-

Default season activities

-

- Note that you can't register activities if the member is new and not yet saved into the database. -

-

- -