[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 -*-
# 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
# 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']
}

View File

@ -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';"

View File

@ -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 ""

View File

@ -1,6 +1,6 @@
# -*- 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
# 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 <http://www.gnu.org/licenses/>.
""" 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

View File

@ -19,11 +19,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<data>
<!-- 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="model">golem.activity.registration</field>
<field name="inherit_id"
ref="golem_activity_registration.registration_tree" />
ref="golem_activity_registration.golem_activity_registration_tree" />
<field name="arch" type="xml">
<tree position="attributes">
<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>
<!-- 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="model">golem.activity.registration</field>
<field name="inherit_id"
ref="golem_activity_registration.searches" />
ref="golem_activity_registration.golem_activity_registration_search" />
<field name="arch" type="xml">
<field name="activity_id" position="after">
<field name="invoice_id" widget="many2one" />

View File

@ -1,6 +1,6 @@
<?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
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>
<!-- 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="model">golem.activity</field>
<field name="inherit_id"
ref="golem_activity_registration.activity_form" />
ref="golem_activity_registration.golem_activity_form_inherit_registration" />
<field name="arch" type="xml">
<tree position="replace">
<tree editable="top"

View File

@ -1,6 +1,6 @@
<?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
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>
<!-- 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="model">golem.member</field>
<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">
<p name="default_season_label" position="after">
<p attrs="{'invisible': [('id', '!=', False)]}" style="color:red;}">