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

This commit is contained in:
Fabien BOURGEOIS 2017-05-01 23:20:04 +02:00
parent bccf22aa3f
commit 96822910a1
7 changed files with 131 additions and 139 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,9 +23,9 @@
'author': 'Fabien Bourgeois', 'author': 'Fabien Bourgeois',
'license': 'AGPL-3', 'license': 'AGPL-3',
'application': False, 'application': False,
'installable': False, 'installable': True,
'depends': ['golem_activity', 'golem_member'], 'depends': ['golem_activity', 'golem_member'],
'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',
'security/ir.model.access.csv'] 'security/ir.model.access.csv']
} }

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-10 16:10+0000\n" "POT-Creation-Date: 2017-05-01 21:16+0000\n"
"PO-Revision-Date: 2016-10-10 16:10+0000\n" "PO-Revision-Date: 2017-05-01 21:16+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -17,53 +17,53 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
#. module: golem_activity_registration #. module: golem_activity_registration
#: model:ir.ui.menu,name:golem_activity_registration.registration_menu_list #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_member_activity_registration_ids
msgid "Acitivity registrations" #: model:ir.ui.view,arch_db:golem_activity_registration.golem_member_form_inherit_golem_activity_registration
msgstr "Inscriptions aux activités"
#. module: golem_activity_registration
#: view:golem.member:golem_activity_registration.activities_registration
#: field:golem.member,activity_registration_ids:0
msgid "Activities" msgid "Activities"
msgstr "Activités" msgstr "Activités"
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,activity_id:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_activity_id
msgid "Activity" msgid "Activity"
msgstr "Activité" msgstr "Activité"
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,create_uid:0 #: model:ir.ui.menu,name:golem_activity_registration.golem_activity_registration_menu
msgid "Created by" msgid "Activity registrations"
msgstr "Creé par" msgstr "Inscriptions"
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,create_date:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_create_uid
msgid "Created by"
msgstr "Créé par"
#. module: golem_activity_registration
#: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_create_date
msgid "Created on" msgid "Created on"
msgstr "Créé le" msgstr "Créé le"
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,is_current:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_is_current
msgid "Current season?" msgid "Current season?"
msgstr "Saison par défaut?" msgstr "Saison en cours?"
#. module: golem_activity_registration #. module: golem_activity_registration
#: view:golem.activity.registration:golem_activity_registration.searches #: model:ir.ui.view,arch_db:golem_activity_registration.golem_activity_registration_search
msgid "Default season" msgid "Default season"
msgstr "Saison par défaut" msgstr "Saison par défaut"
#. module: golem_activity_registration #. module: golem_activity_registration
#: view:golem.member:golem_activity_registration.activities_registration #: model:ir.ui.view,arch_db:golem_activity_registration.golem_member_form_inherit_golem_activity_registration
msgid "Default season activities" msgid "Default season activities"
msgstr "Activités de la saison affichée par défaut" msgstr "Activités de la saison affichée par défaut"
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,display_name:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_display_name
msgid "Display Name" msgid "Display Name"
msgstr "Nom affiché" msgstr "Nom affiché"
#. module: golem_activity_registration #. module: golem_activity_registration
#: view:golem.activity:golem_activity_registration.activity_search #: model:ir.ui.view,arch_db:golem_activity_registration.golem_activity_search_inherit_registration
msgid "Full" msgid "Full"
msgstr "Plein" msgstr "Plein"
@ -78,7 +78,7 @@ msgid "GOLEM Activity Registration"
msgstr "Inscription à l'activité" msgstr "Inscription à l'activité"
#. module: golem_activity_registration #. module: golem_activity_registration
#: model:ir.actions.act_window,name:golem_activity_registration.registration_action_list #: model:ir.actions.act_window,name:golem_activity_registration.golem_activity_registration_action
msgid "GOLEM Activity Registration List" msgid "GOLEM Activity Registration List"
msgstr "Liste des inscriptions aux activités" msgstr "Liste des inscriptions aux activités"
@ -88,99 +88,88 @@ msgid "GOLEM Member"
msgstr "Adhérent" msgstr "Adhérent"
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,id:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_id
msgid "ID" msgid "ID"
msgstr "ID" msgstr "ID"
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,__last_update:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration___last_update
msgid "Last Modified on" msgid "Last Modified on"
msgstr "Modifié pour la dernière fois le" msgstr "Dernière Modification le"
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,write_uid:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_write_uid
msgid "Last Updated by" msgid "Last Updated by"
msgstr "Dernière mise à jour par" msgstr "Dernière mise à jour par"
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,write_date:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_write_date
msgid "Last Updated on" msgid "Last Updated on"
msgstr "Mis à jour pour la dernière fois le" msgstr "Dernière mise à jour le"
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,member_id:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_member_id
msgid "Member" msgid "Member"
msgstr "Adhérent" msgstr "Adhérent"
#. module: golem_activity_registration #. module: golem_activity_registration
#: view:golem.activity:golem_activity_registration.activity_form #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_activity_registration_ids
#: field:golem.activity,activity_registration_ids:0 #: model:ir.ui.view,arch_db:golem_activity_registration.golem_activity_form_inherit_registration
msgid "Members" msgid "Members"
msgstr "Adhérents" msgstr "Adhérents"
#. module: golem_activity_registration #. module: golem_activity_registration
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:32 #: code:addons/golem_activity_registration/models/golem_activity_registration.py:36
#: sql_constraint:golem.activity:0 #: sql_constraint:golem.activity:0
#, python-format #, python-format
msgid "Number of places cannot be negative." msgid "Number of places cannot be negative."
msgstr "Le nombre de places ne peut pas être négatif" msgstr "Le nombre de places ne peut pas être négatif"
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity,places:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_places
msgid "Places" msgid "Places"
msgstr "Places" msgstr "Places"
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity,places_used:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_places_used
msgid "Places used" msgid "Places used"
msgstr "Places prises" msgstr "Places prises"
#. module: golem_activity_registration #. module: golem_activity_registration
#: view:golem.activity:golem_activity_registration.activity_tree #: model:ir.ui.view,arch_db:golem_activity_registration.golem_activity_tree_inherit_registration
msgid "Remain" msgid "Remain"
msgstr "Reste" msgstr "Reste"
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity,places_remain:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_places_remain
msgid "Remaining places" msgid "Remaining places"
msgstr "Places restantes" msgstr "Places restantes"
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,season_id:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_season_id
msgid "Season" msgid "Season"
msgstr "Saison" msgstr "Saison"
#. module: golem_activity_registration #. module: golem_activity_registration
#: view:golem.activity:golem_activity_registration.activity_form #: code:addons/golem_activity_registration/models/golem_activity_registration.py:67
msgid "Session"
msgstr "Séance"
#. module: golem_activity_registration
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:58
#, python-format #, python-format
msgid "Sorry, there is no more place !" msgid "Sorry, there is no more place !"
msgstr "Désolé, il n'y a plus de place disponible !" msgstr "Désolé, il n'y a plus de place disponible !"
#. module: golem_activity_registration #. module: golem_activity_registration
#: view:golem.activity.registration:golem_activity_registration.registration_form #: model:ir.ui.view,arch_db:golem_activity_registration.golem_activity_registration_form
msgid "Subscription" msgid "Subscription"
msgstr "Inscription" msgstr "Inscription"
#. module: golem_activity_registration #. module: golem_activity_registration
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:85 #: code:addons/golem_activity_registration/models/golem_activity_registration.py:95
#, python-format #, python-format
msgid "Subscription can not be executed : the targeted member is not on the same season as the activity." msgid "Subscription can not be executed : the targeted member is not on the same season as the activity."
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 l'activité." 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 l'activité."
#. module: golem_activity_registration #. module: golem_activity_registration
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:77 #: code:addons/golem_activity_registration/models/golem_activity_registration.py:87
#: sql_constraint:golem.activity.registration:0 #: sql_constraint:golem.activity.registration:0
#, python-format #, python-format
msgid "This member has already been registered for this activity." msgid "This member has already been registered for this activity."
msgstr "Le membre a déjà été inscrit à cette activité." msgstr "Le membre a déjà été inscrit à cette activité."
#. module: golem_activity_registration
#: view:golem.activity:golem_activity_registration.activity_tree
msgid "red: places_remain == 0;orange: places_remain <= 4;"
msgstr "red: places_remain == 0;orange: places_remain <= 4;"

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-10 16:10+0000\n" "POT-Creation-Date: 2017-05-01 21:16+0000\n"
"PO-Revision-Date: 2016-10-10 16:10+0000\n" "PO-Revision-Date: 2017-05-01 21:16+0000\n"
"Last-Translator: <>\n" "Last-Translator: <>\n"
"Language-Team: \n" "Language-Team: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -16,53 +16,53 @@ msgstr ""
"Plural-Forms: \n" "Plural-Forms: \n"
#. module: golem_activity_registration #. module: golem_activity_registration
#: model:ir.ui.menu,name:golem_activity_registration.registration_menu_list #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_member_activity_registration_ids
msgid "Acitivity registrations" #: model:ir.ui.view,arch_db:golem_activity_registration.golem_member_form_inherit_golem_activity_registration
msgstr ""
#. module: golem_activity_registration
#: view:golem.member:golem_activity_registration.activities_registration
#: field:golem.member,activity_registration_ids:0
msgid "Activities" msgid "Activities"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,activity_id:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_activity_id
msgid "Activity" msgid "Activity"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,create_uid:0 #: model:ir.ui.menu,name:golem_activity_registration.golem_activity_registration_menu
msgid "Activity registrations"
msgstr ""
#. module: golem_activity_registration
#: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_create_uid
msgid "Created by" msgid "Created by"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,create_date:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_create_date
msgid "Created on" msgid "Created on"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,is_current:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_is_current
msgid "Current season?" msgid "Current season?"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: view:golem.activity.registration:golem_activity_registration.searches #: model:ir.ui.view,arch_db:golem_activity_registration.golem_activity_registration_search
msgid "Default season" msgid "Default season"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: view:golem.member:golem_activity_registration.activities_registration #: model:ir.ui.view,arch_db:golem_activity_registration.golem_member_form_inherit_golem_activity_registration
msgid "Default season activities" msgid "Default season activities"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,display_name:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_display_name
msgid "Display Name" msgid "Display Name"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: view:golem.activity:golem_activity_registration.activity_search #: model:ir.ui.view,arch_db:golem_activity_registration.golem_activity_search_inherit_registration
msgid "Full" msgid "Full"
msgstr "" msgstr ""
@ -77,7 +77,7 @@ msgid "GOLEM Activity Registration"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: model:ir.actions.act_window,name:golem_activity_registration.registration_action_list #: model:ir.actions.act_window,name:golem_activity_registration.golem_activity_registration_action
msgid "GOLEM Activity Registration List" msgid "GOLEM Activity Registration List"
msgstr "" msgstr ""
@ -87,103 +87,89 @@ msgid "GOLEM Member"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,id:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_id
msgid "ID" msgid "ID"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,__last_update:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration___last_update
msgid "Last Modified on" msgid "Last Modified on"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,write_uid:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_write_uid
msgid "Last Updated by" msgid "Last Updated by"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,write_date:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_write_date
msgid "Last Updated on" msgid "Last Updated on"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: sql_constraint:golem.activity:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_member_id
msgid "Le nombre de places ne peut pas être négatif"
msgstr ""
#. module: golem_activity_registration
#: field:golem.activity.registration,member_id:0
msgid "Member" msgid "Member"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: view:golem.activity:golem_activity_registration.activity_form #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_activity_registration_ids
#: field:golem.activity,activity_registration_ids:0 #: model:ir.ui.view,arch_db:golem_activity_registration.golem_activity_form_inherit_registration
msgid "Members" msgid "Members"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:32 #: code:addons/golem_activity_registration/models/golem_activity_registration.py:36
#: sql_constraint:golem.activity:0
#, python-format #, python-format
msgid "Number of places cannot be negative." msgid "Number of places cannot be negative."
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity,places:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_places
msgid "Places" msgid "Places"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity,places_used:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_places_used
msgid "Places used" msgid "Places used"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: view:golem.activity:golem_activity_registration.activity_tree #: model:ir.ui.view,arch_db:golem_activity_registration.golem_activity_tree_inherit_registration
msgid "Remain" msgid "Remain"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity,places_remain:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_places_remain
msgid "Remaining places" msgid "Remaining places"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: field:golem.activity.registration,season_id:0 #: model:ir.model.fields,field_description:golem_activity_registration.field_golem_activity_registration_season_id
msgid "Season" msgid "Season"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: view:golem.activity:golem_activity_registration.activity_form #: code:addons/golem_activity_registration/models/golem_activity_registration.py:67
msgid "Session"
msgstr ""
#. module: golem_activity_registration
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:58
#, python-format #, python-format
msgid "Sorry, there is no more place !" msgid "Sorry, there is no more place !"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: view:golem.activity.registration:golem_activity_registration.registration_form #: model:ir.ui.view,arch_db:golem_activity_registration.golem_activity_registration_form
msgid "Subscription" msgid "Subscription"
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:85 #: code:addons/golem_activity_registration/models/golem_activity_registration.py:95
#, python-format #, python-format
msgid "Subscription can not be executed : the targeted member is not on the same season as the activity." msgid "Subscription can not be executed : the targeted member is not on the same season as the activity."
msgstr "" msgstr ""
#. module: golem_activity_registration #. module: golem_activity_registration
#: code:addons/golem_activity_registration/models/golem_activity_registration.py:77 #: code:addons/golem_activity_registration/models/golem_activity_registration.py:87
#: sql_constraint:golem.activity.registration:0 #: sql_constraint:golem.activity.registration:0
#, python-format #, python-format
msgid "This member has already been registered for this activity." msgid "This member has already been registered for this activity."
msgstr "" msgstr ""
#. module: golem_activity_registration
#: view:golem.activity:golem_activity_registration.activity_tree
msgid "red: places_remain == 0;orange: places_remain <= 4;"
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,57 +15,67 @@
# 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 """
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'
activity_registration_ids = fields.One2many('golem.activity.registration', activity_registration_ids = fields.One2many('golem.activity.registration',
'member_id', 'Activities') 'member_id', 'Activities',
index=True)
class GolemActivity(models.Model): class GolemActivity(models.Model):
""" GOLEM Activity adaptations """
_inherit = 'golem.activity' _inherit = 'golem.activity'
_sql_constraints = [('golem_activity_places_signed', _sql_constraints = [('golem_activity_places_signed',
'CHECK (places >= 0)', 'CHECK (places >= 0)',
_('Number of places cannot be negative.'))] _('Number of places cannot be negative.'))]
activity_registration_ids = fields.One2many('golem.activity.registration', activity_registration_ids = fields.One2many('golem.activity.registration',
'activity_id', 'Members') 'activity_id', 'Members',
index=True)
places_used = fields.Integer('Places used', compute='_compute_places_used', places_used = fields.Integer('Places used', compute='_compute_places_used',
store=True) store=True)
@api.one @api.multi
@api.depends('activity_registration_ids') @api.depends('activity_registration_ids')
def _compute_places_used(self): def _compute_places_used(self):
self.places_used = len(self.activity_registration_ids) """ Computes used places """
for activity in self:
activity.places_used = len(activity.activity_registration_ids)
places = fields.Integer('Places', default=20) places = fields.Integer('Places', default=20)
places_remain = fields.Integer('Remaining places', store=True, places_remain = fields.Integer('Remaining places', store=True,
compute='_compute_places_remain') compute='_compute_places_remain')
@api.one @api.multi
@api.depends('places', 'places_used') @api.depends('places', 'places_used')
def _compute_places_remain(self): def _compute_places_remain(self):
self.places_remain = self.places - self.places_used """ Computes remaining places """
for activity in self:
activity.places_remain = activity.places - activity.places_used
@api.constrains('places_remain') @api.constrains('places_remain')
def _check_remaining_places(self): def _check_remaining_places(self):
""" Forbid inscription when there is no more place """ """ Forbid inscription when there is no more place """
for s in self: for activity in self:
if s.places_remain < 0: if activity.places_remain < 0:
emsg = _('Sorry, there is no more place !') emsg = _('Sorry, there is no more place !')
raise models.ValidationError(emsg) raise models.ValidationError(emsg)
class GolemActivityRegistration(models.Model): class GolemActivityRegistration(models.Model):
""" GOLEM Activity Registration """
_name = 'golem.activity.registration' _name = 'golem.activity.registration'
_description = 'GOLEM Activity Registration' _description = 'GOLEM Activity Registration'
member_id = fields.Many2one('golem.member', string='Member', required=True, member_id = fields.Many2one('golem.member', string='Member', required=True,
ondelete='cascade') ondelete='cascade', index=True)
activity_id = fields.Many2one('golem.activity', required=True, activity_id = fields.Many2one('golem.activity', required=True, index=True,
string='Activity', ondelete='cascade') string='Activity', ondelete='cascade')
season_id = fields.Many2one(string='Season', season_id = fields.Many2one(string='Season',
related='activity_id.season_id') related='activity_id.season_id')
@ -80,8 +90,8 @@ class GolemActivityRegistration(models.Model):
def _check_season_reliability(self): def _check_season_reliability(self):
""" Forbid registration when member season if not coherent with """ Forbid registration when member season if not coherent with
activity season or are duplicates """ activity season or are duplicates """
for r in self: for reg in self:
if r.activity_id.season_id not in r.member_id.season_ids: if reg.activity_id.season_id not in reg.member_id.season_ids:
emsg = _('Subscription can not be executed : the targeted ' emsg = _('Subscription can not be executed : the targeted '
'member is not on the same season as the activity.') 'member is not on the same season as the activity.')
raise models.ValidationError(emsg) raise models.ValidationError(emsg)

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
@ -15,10 +15,12 @@ GNU Affero General Public License for more details.
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/>.
--> -->
<odoo> <odoo>
<data> <data>
<!-- Form --> <!-- Form -->
<record id="registration_form" model="ir.ui.view"> <record id="golem_activity_registration_form" model="ir.ui.view">
<field name="name">Activity registration form</field> <field name="name">Activity registration form</field>
<field name="model">golem.activity.registration</field> <field name="model">golem.activity.registration</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
@ -36,7 +38,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<!-- Tree --> <!-- Tree -->
<record id="registration_tree" model="ir.ui.view"> <record id="golem_activity_registration_tree" model="ir.ui.view">
<field name="name">Activity registration list</field> <field name="name">Activity registration list</field>
<field name="model">golem.activity.registration</field> <field name="model">golem.activity.registration</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
@ -49,7 +51,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</record> </record>
<!-- Search --> <!-- Search -->
<record id="searches" model="ir.ui.view"> <record id="golem_activity_registration_search" model="ir.ui.view">
<field name="name">GOLEM Activity Registration searches</field> <field name="name">GOLEM Activity Registration searches</field>
<field name="model">golem.activity.registration</field> <field name="model">golem.activity.registration</field>
<field name="arch" type="xml"> <field name="arch" type="xml">
@ -64,7 +66,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</record> </record>
<!-- Action --> <!-- Action -->
<record id="registration_action_list" model="ir.actions.act_window"> <record id="golem_activity_registration_action" model="ir.actions.act_window">
<field name="name">GOLEM Activity Registration List</field> <field name="name">GOLEM Activity Registration List</field>
<field name="res_model">golem.activity.registration</field> <field name="res_model">golem.activity.registration</field>
<field name="view_mode">tree</field> <field name="view_mode">tree</field>
@ -72,9 +74,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</record> </record>
<!-- Menu --> <!-- Menu -->
<menuitem id="registration_menu_list" name="Acitivity registrations" <menuitem id="golem_activity_registration_menu" name="Activity registrations"
parent="golem_activity.activity_menu" action="registration_action_list" parent="golem_activity.golem_activity_menu"
action="golem_activity_registration_action"
groups="golem_base.group_golem_user" groups="golem_base.group_golem_user"
sequence="20" /> sequence="20" />
</data> </data>
</odoo> </odoo>

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
@ -15,19 +15,21 @@ GNU Affero General Public License for more details.
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/>.
--> -->
<odoo> <odoo>
<data> <data>
<!-- Form --> <!-- Form -->
<record id="activity_form" model="ir.ui.view"> <record id="golem_activity_form_inherit_registration"
model="ir.ui.view">
<field name="name">Activity Registrations and Places</field> <field name="name">Activity Registrations and Places</field>
<field name="model">golem.activity</field> <field name="model">golem.activity</field>
<field name="inherit_id" ref="golem_activity.view_form" /> <field name="inherit_id" ref="golem_activity.golem_activity_form" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<group name="places" position="inside"> <group name="places" position="inside">
<field name="places" /> <field name="places" />
</group> </group>
<page string="Session" position="after"> <page name="session" position="after">
<page string="Members"> <page string="Members">
<group> <group>
<field name="places_remain" readonly="True" /> <field name="places_remain" readonly="True" />
@ -47,10 +49,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</record> </record>
<!-- Tree --> <!-- Tree -->
<record id="activity_tree" model="ir.ui.view"> <record id="golem_activity_tree_inherit_registration" model="ir.ui.view">
<field name="name">Activity Tree registrations additions</field> <field name="name">Activity Tree registrations additions</field>
<field name="model">golem.activity</field> <field name="model">golem.activity</field>
<field name="inherit_id" ref="golem_activity.view_tree" /> <field name="inherit_id" ref="golem_activity.golem_activity_tree" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<tree position="attributes"> <tree position="attributes">
<attribute name="colors">red: places_remain == 0;orange: places_remain &lt;= 4;</attribute> <attribute name="colors">red: places_remain == 0;orange: places_remain &lt;= 4;</attribute>
@ -63,10 +65,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</record> </record>
<!-- Search --> <!-- Search -->
<record id="activity_search" model="ir.ui.view"> <record id="golem_activity_search_inherit_registration" model="ir.ui.view">
<field name="name">Activity Search registrations additions</field> <field name="name">Activity Search registrations additions</field>
<field name="model">golem.activity</field> <field name="model">golem.activity</field>
<field name="inherit_id" ref="golem_activity.view_filter" /> <field name="inherit_id" ref="golem_activity.golem_activity_search" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<filter name="season_default" position="after"> <filter name="season_default" position="after">
<filter name="full_activity" string="Full" <filter name="full_activity" string="Full"

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,10 +19,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<data> <data>
<!-- Form --> <!-- Form -->
<record model="ir.ui.view" id="activities_registration"> <record id="golem_member_form_inherit_golem_activity_registration"
model="ir.ui.view">
<field name="name">Add activities registrations to member form</field> <field name="name">Add activities registrations to member form</field>
<field name="model">golem.member</field> <field name="model">golem.member</field>
<field name="inherit_id" ref="golem_member.view_form" /> <field name="inherit_id" ref="golem_member.golem_member_form" />
<field name="arch" type="xml"> <field name="arch" type="xml">
<page name="other_page" position="before"> <page name="other_page" position="before">
<page name="activities" string="Activities"> <page name="activities" string="Activities">