diff --git a/golem_activity_registration_state/__manifest__.py b/golem_activity_registration_state/__manifest__.py index 7e81d72..8d9802f 100644 --- a/golem_activity_registration_state/__manifest__.py +++ b/golem_activity_registration_state/__manifest__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2016 Fabien Bourgeois +# Copyright 2017 Fabien Bourgeois # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -23,8 +23,8 @@ 'author': 'Fabien Bourgeois', 'license': 'AGPL-3', 'application': False, - 'installable': False, + 'installable': True, 'depends': ['golem_activity_registration'], - 'data': ['views/golem_activity_registration_view.xml', - 'views/golem_member_view.xml', 'views/golem_activity_view.xml'] + 'data': ['views/golem_activity_registration_views.xml', + 'views/golem_member_views.xml', 'views/golem_activity_views.xml'] } diff --git a/golem_activity_registration_state/i18n/fr.po b/golem_activity_registration_state/i18n/fr.po index 0341d38..62cd82f 100644 --- a/golem_activity_registration_state/i18n/fr.po +++ b/golem_activity_registration_state/i18n/fr.po @@ -4,10 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-10-16 09:40+0000\n" -"PO-Revision-Date: 2016-10-16 09:40+0000\n" +"POT-Creation-Date: 2017-05-01 21:42+0000\n" +"PO-Revision-Date: 2017-05-01 21:42+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -47,43 +47,36 @@ msgid "GOLEM Member" msgstr "Adhérent" #. module: golem_activity_registration_state -#: field:golem.member,has_draft_registrations:0 +#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_member_has_draft_registrations msgid "Has draft registrations ?" msgstr "A des inscriptions non validées ?" #. module: golem_activity_registration_state -#: view:golem.member:golem_activity_registration_state.registration_state +#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_member_form_inherit_registration_state msgid "If you validate draft registration, they will be seen as confirmed. Then, an invoice will be created for the current member." msgstr "Si vous validez les inscriptions, elles seront vues comme confirmées. Ensuite, une facture sera créée pour l'adhérent." #. module: golem_activity_registration_state -#: field:golem.activity.registration,invoice_id:0 +#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_invoice_id msgid "Invoice" msgstr "Facture" #. module: golem_activity_registration_state -#: field:golem.activity.registration,invoice_line_id:0 +#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_invoice_line_id msgid "Invoice line" msgstr "Ligne de facturation" #. module: golem_activity_registration_state -#: view:golem.member:golem_activity_registration_state.registration_state +#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_member_form_inherit_registration_state msgid "Note that you can't register activities if the member is new and not yet saved into the database." msgstr "Notez que vous ne devez d'abord enregistrer la fiche d'un nouvel adhérent avant de pouvoir saisie ses activités." #. module: golem_activity_registration_state -#: field:golem.activity.registration,state:0 +#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_state msgid "State" msgstr "État" #. module: golem_activity_registration_state -#: view:golem.member:golem_activity_registration_state.registration_state +#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_member_form_inherit_registration_state msgid "Validate all draft registrations" msgstr "Valider toutes les inscriptions" - -#. module: golem_activity_registration_state -#: view:golem.activity.registration:golem_activity_registration_state.state_tree -#: view:golem.member:golem_activity_registration_state.registration_state -msgid "red: state == 'canceled';darkgrey: state == 'draft';" -msgstr "red: state == 'canceled';darkgrey: state == 'draft';" - diff --git a/golem_activity_registration_state/i18n/golem_activity_registration_state.pot b/golem_activity_registration_state/i18n/golem_activity_registration_state.pot index abd4271..fad4a34 100644 --- a/golem_activity_registration_state/i18n/golem_activity_registration_state.pot +++ b/golem_activity_registration_state/i18n/golem_activity_registration_state.pot @@ -4,10 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" +"Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-10-16 09:40+0000\n" -"PO-Revision-Date: 2016-10-16 09:40+0000\n" +"POT-Creation-Date: 2017-05-01 21:41+0000\n" +"PO-Revision-Date: 2017-05-01 21:41+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -46,43 +46,37 @@ msgid "GOLEM Member" msgstr "" #. module: golem_activity_registration_state -#: field:golem.member,has_draft_registrations:0 +#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_member_has_draft_registrations msgid "Has draft registrations ?" msgstr "" #. module: golem_activity_registration_state -#: view:golem.member:golem_activity_registration_state.registration_state +#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_member_form_inherit_registration_state msgid "If you validate draft registration, they will be seen as confirmed. Then, an invoice will be created for the current member." msgstr "" #. module: golem_activity_registration_state -#: field:golem.activity.registration,invoice_id:0 +#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_invoice_id msgid "Invoice" msgstr "" #. module: golem_activity_registration_state -#: field:golem.activity.registration,invoice_line_id:0 +#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_invoice_line_id msgid "Invoice line" msgstr "" #. module: golem_activity_registration_state -#: view:golem.member:golem_activity_registration_state.registration_state +#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_member_form_inherit_registration_state msgid "Note that you can't register activities if the member is new and not yet saved into the database." msgstr "" #. module: golem_activity_registration_state -#: field:golem.activity.registration,state:0 +#: model:ir.model.fields,field_description:golem_activity_registration_state.field_golem_activity_registration_state msgid "State" msgstr "" #. module: golem_activity_registration_state -#: view:golem.member:golem_activity_registration_state.registration_state +#: model:ir.ui.view,arch_db:golem_activity_registration_state.golem_member_form_inherit_registration_state msgid "Validate all draft registrations" msgstr "" -#. module: golem_activity_registration_state -#: view:golem.activity.registration:golem_activity_registration_state.state_tree -#: view:golem.member:golem_activity_registration_state.registration_state -msgid "red: state == 'canceled';darkgrey: state == 'draft';" -msgstr "" - diff --git a/golem_activity_registration_state/models/golem_activity_registration.py b/golem_activity_registration_state/models/golem_activity_registration.py index c1eb489..3b6fac3 100644 --- a/golem_activity_registration_state/models/golem_activity_registration.py +++ b/golem_activity_registration_state/models/golem_activity_registration.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# copyright 2016 fabien bourgeois +# copyright 2017 fabien bourgeois # # this program is free software: you can redistribute it and/or modify # it under the terms of the gnu affero general public license as @@ -15,32 +15,35 @@ # you should have received a copy of the gnu affero general public license # along with this program. if not, see . +""" GOLEM Activity Registration State """ + from odoo import models, fields, api - class GolemMember(models.Model): + """ GOLEM Member adaptations """ _inherit = 'golem.member' has_draft_registrations = fields.Boolean( 'Has draft registrations ?', - compute='_compute_has_draft_registrations') + compute='_compute_has_draft_reg') - @api.one @api.depends('activity_registration_ids') - def _compute_has_draft_registrations(self): + def _compute_has_draft_reg(self): """ Check if there are draft states in member activities """ - for r in self.activity_registration_ids: - if r.state == 'draft': - self.has_draft_registrations = True - return - self.has_draft_registrations = False + for member in self: + for reg in member.activity_registration_ids: + if reg.state == 'draft': + member.has_draft_registrations = True + return + member.has_draft_registrations = False - @api.one + @api.multi def do_validate_registrations(self): """ Validate all draft registrations """ - draft_registrations = self.activity_registration_ids.filtered( - lambda r: r.state == 'draft') - draft_registrations.write({'state': 'confirmed'}) + for member in self: + draft_registrations = member.activity_registration_ids.filtered( + lambda r: r.state == 'draft') + draft_registrations.write({'state': 'confirmed'}) @api.multi def write(self, values): @@ -48,14 +51,17 @@ class GolemMember(models.Model): if 'activity_registration_ids' in values: rids = values['activity_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.registration'] + for rid in rids: # == 2 is removal case + if rid[0] == 2: + r_removed.append(rid) + else: + r_keep.append(rid) + reg_obj = self.env['golem.activity.registration'] for rem in r_removed: - r = rObj.browse([rem[1]]) + reg = reg_obj.browse([rem[1]]) # if already canceled, let it be removed, else cancel it - if r.state != 'canceled': - r.state = 'canceled' + if reg.state != 'canceled': + reg.state = 'canceled' else: r_keep.append(rem) values['activity_registration_ids'] = r_keep @@ -63,16 +69,20 @@ class GolemMember(models.Model): class GolemActivity(models.Model): + """ GOLEM Activity adaptations """ _inherit = 'golem.activity' - @api.one + @api.multi @api.depends('activity_registration_ids') - def _compute_places_used(self): - rids = self.activity_registration_ids - self.places_used = len(rids.filtered(lambda r: r.state == 'confirmed')) + def compute_places_used(self): + """ Computes used places """ + for activity in self: + rids = activity.activity_registration_ids + activity.places_used = len(rids.filtered(lambda r: r.state == 'confirmed')) class GolemActivityRegistration(models.Model): + """ GOLEM Activity Registration adaptations """ _inherit = 'golem.activity.registration' state = fields.Selection([('draft', 'Draft'), ('confirmed', 'Confirmed'), @@ -89,6 +99,6 @@ class GolemActivityRegistration(models.Model): """ Recomputes values linked to registrations when state change """ res = super(GolemActivityRegistration, self).write(values) if values['state']: - for r in self: - r.activity_id._compute_places_used() + for registration in self: + registration.activity_id.compute_places_used() return res diff --git a/golem_activity_registration_state/views/golem_activity_registration_view.xml b/golem_activity_registration_state/views/golem_activity_registration_views.xml similarity index 84% rename from golem_activity_registration_state/views/golem_activity_registration_view.xml rename to golem_activity_registration_state/views/golem_activity_registration_views.xml index 823f3fa..b939857 100644 --- a/golem_activity_registration_state/views/golem_activity_registration_view.xml +++ b/golem_activity_registration_state/views/golem_activity_registration_views.xml @@ -19,11 +19,12 @@ along with this program. If not, see . - + Session registration list golem.activity.registration + ref="golem_activity_registration.golem_activity_registration_tree" /> red: state == 'canceled';darkgrey: state == 'draft'; @@ -39,11 +40,12 @@ along with this program. If not, see . - + Registration state specific searches golem.activity.registration + ref="golem_activity_registration.golem_activity_registration_search" /> diff --git a/golem_activity_registration_state/views/golem_activity_view.xml b/golem_activity_registration_state/views/golem_activity_views.xml similarity index 86% rename from golem_activity_registration_state/views/golem_activity_view.xml rename to golem_activity_registration_state/views/golem_activity_views.xml index 4848d55..456d7fe 100644 --- a/golem_activity_registration_state/views/golem_activity_view.xml +++ b/golem_activity_registration_state/views/golem_activity_views.xml @@ -1,6 +1,6 @@ - + Activity Registrations States golem.activity + ref="golem_activity_registration.golem_activity_form_inherit_registration" /> - + Add state for registrations golem.member + ref="golem_activity_registration.golem_member_form_inherit_golem_activity_registration" />