[MIG][IMP]GOLEM activity registration state migration to v10, and better guidelines

This commit is contained in:
Fabien BOURGEOIS 2017-05-01 23:43:59 +02:00
parent 9e7fc9b1a3
commit c4d8c5f334
7 changed files with 73 additions and 73 deletions

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2016 Fabien Bourgeois <fabien@yaltik.com> # Copyright 2017 Fabien Bourgeois <fabien@yaltik.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
@ -23,8 +23,8 @@
'author': 'Fabien Bourgeois', 'author': 'Fabien Bourgeois',
'license': 'AGPL-3', 'license': 'AGPL-3',
'application': False, 'application': False,
'installable': False, 'installable': True,
'depends': ['golem_activity_registration'], 'depends': ['golem_activity_registration'],
'data': ['views/golem_activity_registration_view.xml', 'data': ['views/golem_activity_registration_views.xml',
'views/golem_member_view.xml', 'views/golem_activity_view.xml'] 'views/golem_member_views.xml', 'views/golem_activity_views.xml']
} }

View File

@ -4,10 +4,10 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 8.0\n" "Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-10-16 09:40+0000\n" "POT-Creation-Date: 2017-05-01 21:42+0000\n"
"PO-Revision-Date: 2016-10-16 09:40+0000\n" "PO-Revision-Date: 2017-05-01 21:42+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -47,43 +47,36 @@ msgid "GOLEM Member"
msgstr "Adhérent" msgstr "Adhérent"
#. module: golem_activity_registration_state #. 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 ?" msgid "Has draft registrations ?"
msgstr "A des inscriptions non validées ?" msgstr "A des inscriptions non validées ?"
#. module: golem_activity_registration_state #. 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." 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." 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 #. 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" msgid "Invoice"
msgstr "Facture" msgstr "Facture"
#. module: golem_activity_registration_state #. 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" msgid "Invoice line"
msgstr "Ligne de facturation" msgstr "Ligne de facturation"
#. module: golem_activity_registration_state #. 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." 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." 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 #. 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" msgid "State"
msgstr "État" msgstr "État"
#. module: golem_activity_registration_state #. 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" msgid "Validate all draft registrations"
msgstr "Valider toutes les inscriptions" 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';"

View File

@ -4,10 +4,10 @@
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Odoo Server 8.0\n" "Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-10-16 09:40+0000\n" "POT-Creation-Date: 2017-05-01 21:41+0000\n"
"PO-Revision-Date: 2016-10-16 09:40+0000\n" "PO-Revision-Date: 2017-05-01 21:41+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -46,43 +46,37 @@ msgid "GOLEM Member"
msgstr "" msgstr ""
#. module: golem_activity_registration_state #. 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 ?" msgid "Has draft registrations ?"
msgstr "" msgstr ""
#. module: golem_activity_registration_state #. 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." msgid "If you validate draft registration, they will be seen as confirmed. Then, an invoice will be created for the current member."
msgstr "" msgstr ""
#. module: golem_activity_registration_state #. 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" msgid "Invoice"
msgstr "" msgstr ""
#. module: golem_activity_registration_state #. 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" msgid "Invoice line"
msgstr "" msgstr ""
#. module: golem_activity_registration_state #. 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." msgid "Note that you can't register activities if the member is new and not yet saved into the database."
msgstr "" msgstr ""
#. module: golem_activity_registration_state #. 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" msgid "State"
msgstr "" msgstr ""
#. module: golem_activity_registration_state #. 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" msgid "Validate all draft registrations"
msgstr "" 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 ""

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# copyright 2016 fabien bourgeois <fabien@yaltik.com> # copyright 2017 fabien bourgeois <fabien@yaltik.com>
# #
# this program is free software: you can redistribute it and/or modify # this program is free software: you can redistribute it and/or modify
# it under the terms of the gnu affero general public license as # 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 # you should have received a copy of the gnu affero general public license
# along with this program. if not, see <http://www.gnu.org/licenses/>. # along with this program. if not, see <http://www.gnu.org/licenses/>.
""" GOLEM Activity Registration State """
from odoo import models, fields, api from odoo import models, fields, api
class GolemMember(models.Model): class GolemMember(models.Model):
""" GOLEM Member adaptations """
_inherit = 'golem.member' _inherit = 'golem.member'
has_draft_registrations = fields.Boolean( has_draft_registrations = fields.Boolean(
'Has draft registrations ?', 'Has draft registrations ?',
compute='_compute_has_draft_registrations') compute='_compute_has_draft_reg')
@api.one
@api.depends('activity_registration_ids') @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 """ """ Check if there are draft states in member activities """
for r in self.activity_registration_ids: for member in self:
if r.state == 'draft': for reg in member.activity_registration_ids:
self.has_draft_registrations = True if reg.state == 'draft':
return member.has_draft_registrations = True
self.has_draft_registrations = False return
member.has_draft_registrations = False
@api.one @api.multi
def do_validate_registrations(self): def do_validate_registrations(self):
""" Validate all draft registrations """ """ Validate all draft registrations """
draft_registrations = self.activity_registration_ids.filtered( for member in self:
lambda r: r.state == 'draft') draft_registrations = member.activity_registration_ids.filtered(
draft_registrations.write({'state': 'confirmed'}) lambda r: r.state == 'draft')
draft_registrations.write({'state': 'confirmed'})
@api.multi @api.multi
def write(self, values): def write(self, values):
@ -48,14 +51,17 @@ class GolemMember(models.Model):
if 'activity_registration_ids' in values: if 'activity_registration_ids' in values:
rids = values['activity_registration_ids'] rids = values['activity_registration_ids']
r_keep, r_removed = [], [] r_keep, r_removed = [], []
for r in rids: # == 2 is removal case for rid in rids: # == 2 is removal case
r_removed.append(r) if r[0] == 2 else r_keep.append(r) if rid[0] == 2:
rObj = self.env['golem.activity.registration'] r_removed.append(rid)
else:
r_keep.append(rid)
reg_obj = self.env['golem.activity.registration']
for rem in r_removed: 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 already canceled, let it be removed, else cancel it
if r.state != 'canceled': if reg.state != 'canceled':
r.state = 'canceled' reg.state = 'canceled'
else: else:
r_keep.append(rem) r_keep.append(rem)
values['activity_registration_ids'] = r_keep values['activity_registration_ids'] = r_keep
@ -63,16 +69,20 @@ class GolemMember(models.Model):
class GolemActivity(models.Model): class GolemActivity(models.Model):
""" GOLEM Activity adaptations """
_inherit = 'golem.activity' _inherit = 'golem.activity'
@api.one @api.multi
@api.depends('activity_registration_ids') @api.depends('activity_registration_ids')
def _compute_places_used(self): def compute_places_used(self):
rids = self.activity_registration_ids """ Computes used places """
self.places_used = len(rids.filtered(lambda r: r.state == 'confirmed')) for activity in self:
rids = activity.activity_registration_ids
activity.places_used = len(rids.filtered(lambda r: r.state == 'confirmed'))
class GolemActivityRegistration(models.Model): class GolemActivityRegistration(models.Model):
""" GOLEM Activity Registration adaptations """
_inherit = 'golem.activity.registration' _inherit = 'golem.activity.registration'
state = fields.Selection([('draft', 'Draft'), ('confirmed', 'Confirmed'), state = fields.Selection([('draft', 'Draft'), ('confirmed', 'Confirmed'),
@ -89,6 +99,6 @@ class GolemActivityRegistration(models.Model):
""" Recomputes values linked to registrations when state change """ """ Recomputes values linked to registrations when state change """
res = super(GolemActivityRegistration, self).write(values) res = super(GolemActivityRegistration, self).write(values)
if values['state']: if values['state']:
for r in self: for registration in self:
r.activity_id._compute_places_used() registration.activity_id.compute_places_used()
return res return res

View File

@ -19,11 +19,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<data> <data>
<!-- Tree --> <!-- Tree -->
<record id="state_tree" model="ir.ui.view"> <record id="golem_activity_registration_tree_inherit_state"
model="ir.ui.view">
<field name="name">Session registration list</field> <field name="name">Session registration list</field>
<field name="model">golem.activity.registration</field> <field name="model">golem.activity.registration</field>
<field name="inherit_id" <field name="inherit_id"
ref="golem_activity_registration.registration_tree" /> ref="golem_activity_registration.golem_activity_registration_tree" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree position="attributes"> <tree position="attributes">
<attribute name="colors">red: state == 'canceled';darkgrey: state == 'draft';</attribute> <attribute name="colors">red: state == 'canceled';darkgrey: state == 'draft';</attribute>
@ -39,11 +40,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</record> </record>
<!-- Search --> <!-- Search -->
<record id="state_searches" model="ir.ui.view"> <record id="golem_activity_registration_search_inherit_state"
model="ir.ui.view">
<field name="name">Registration state specific searches</field> <field name="name">Registration state specific searches</field>
<field name="model">golem.activity.registration</field> <field name="model">golem.activity.registration</field>
<field name="inherit_id" <field name="inherit_id"
ref="golem_activity_registration.searches" /> ref="golem_activity_registration.golem_activity_registration_search" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="activity_id" position="after"> <field name="activity_id" position="after">
<field name="invoice_id" widget="many2one" /> <field name="invoice_id" widget="many2one" />

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Copyright 2016 Fabien Bourgeois <fabien@yaltik.com> Copyright 2017 Fabien Bourgeois <fabien@yaltik.com>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by it under the terms of the GNU Affero General Public License as published by
@ -19,11 +19,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<data> <data>
<!-- Form --> <!-- Form -->
<record id="state_activity_form" model="ir.ui.view"> <record id="golem_activity_form_inherit_registration_state"
model="ir.ui.view">
<field name="name">Activity Registrations States</field> <field name="name">Activity Registrations States</field>
<field name="model">golem.activity</field> <field name="model">golem.activity</field>
<field name="inherit_id" <field name="inherit_id"
ref="golem_activity_registration.activity_form" /> ref="golem_activity_registration.golem_activity_form_inherit_registration" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree position="replace"> <tree position="replace">
<tree editable="top" <tree editable="top"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Copyright 2016 Fabien Bourgeois <fabien@yaltik.com> Copyright 2017 Fabien Bourgeois <fabien@yaltik.com>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by it under the terms of the GNU Affero General Public License as published by
@ -19,11 +19,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<data> <data>
<!-- Form --> <!-- Form -->
<record model="ir.ui.view" id="registration_state"> <record model="ir.ui.view" id="golem_member_form_inherit_registration_state">
<field name="name">Add state for registrations</field> <field name="name">Add state for registrations</field>
<field name="model">golem.member</field> <field name="model">golem.member</field>
<field name="inherit_id" <field name="inherit_id"
ref="golem_activity_registration.activities_registration" /> ref="golem_activity_registration.golem_member_form_inherit_golem_activity_registration" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<p name="default_season_label" position="after"> <p name="default_season_label" position="after">
<p attrs="{'invisible': [('id', '!=', False)]}" style="color:red;}"> <p attrs="{'invisible': [('id', '!=', False)]}" style="color:red;}">