[ADD][REF]GOLEM Member and Family Histories enhancements

* Small refactorings ;
* Add zip code history handling ;
* Add translations and base security.
This commit is contained in:
Fabien BOURGEOIS 2018-10-26 08:48:53 +02:00
parent e3d2c63402
commit 2599eb55fb
14 changed files with 587 additions and 56 deletions

View File

@ -20,12 +20,12 @@
'name': 'GOLEM Families History', 'name': 'GOLEM Families History',
'summary': 'GOLEM Families History', 'summary': 'GOLEM Families History',
'description': 'GOLEM Families History', 'description': 'GOLEM Families History',
'version': '10.0.0.0.1', 'version': '10.0.0.1.0',
'category': 'GOLEM', 'category': 'GOLEM',
'author': 'Fabien Bourgeois, Youssef El ouahby', 'author': 'Fabien Bourgeois, Youssef El ouahby',
'license': 'AGPL-3', 'license': 'AGPL-3',
'application': False, 'application': False,
'installable': True, 'installable': True,
'depends': ['golem_family'], 'depends': ['golem_family'],
'data': ['views/golem_family_views.xml'] 'data': ['security/ir.model.access.csv', 'views/golem_family_views.xml']
} }

View File

@ -0,0 +1,109 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * golem_family_history
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-10-26 06:41+0000\n"
"PO-Revision-Date: 2018-10-26 08:45+0200\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_city
msgid "City"
msgstr "Ville"
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_country_id
msgid "Country"
msgstr "Pays"
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_create_uid
msgid "Created by"
msgstr "Créé par"
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_create_date
msgid "Created on"
msgstr "Créé le"
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_display_name
msgid "Display Name"
msgstr "Nom affiché"
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_family_id
msgid "Family"
msgstr "Famille"
#. module: golem_family_history
#: model:ir.model,name:golem_family_history.model_golem_family
msgid "GOLEM Family Entity"
msgstr "Famille"
#. module: golem_family_history
#: model:ir.model,name:golem_family_history.model_golem_family_history
msgid "GOLEM Family History Management"
msgstr "GOLEM Family History Management"
#. module: golem_family_history
#: model:ir.ui.view,arch_db:golem_family_history.golem_family_form_inherit_golem_family_history
msgid "History"
msgstr "Historique"
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_family_history_ids
msgid "History details"
msgstr "Historique"
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_id
msgid "ID"
msgstr "ID"
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history___last_update
msgid "Last Modified on"
msgstr "Dernière Modification le"
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_write_uid
msgid "Last Updated by"
msgstr "Dernière mise à jour par"
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_write_date
msgid "Last Updated on"
msgstr "Dernière mise à jour le"
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_member_ids
msgid "Members"
msgstr "Adhérents"
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_season_id
msgid "Season"
msgstr "Saison"
#. module: golem_family_history
#: code:addons/golem_family_history/models/golem_family_history.py:30
#: sql_constraint:golem.family.history:0
#, python-format
msgid "You can only have one history line for each family and season combination."
msgstr "Vous ne pouvez avoir qu'une seule ligne par famille par saison."
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_zip_code
msgid "ZIP"
msgstr "Code postal"

View File

@ -0,0 +1,109 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * golem_family_history
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-10-26 06:41+0000\n"
"PO-Revision-Date: 2018-10-26 06:41+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_city
msgid "City"
msgstr ""
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_country_id
msgid "Country"
msgstr ""
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_create_uid
msgid "Created by"
msgstr ""
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_create_date
msgid "Created on"
msgstr ""
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_display_name
msgid "Display Name"
msgstr ""
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_family_id
msgid "Family"
msgstr ""
#. module: golem_family_history
#: model:ir.model,name:golem_family_history.model_golem_family
msgid "GOLEM Family Entity"
msgstr ""
#. module: golem_family_history
#: model:ir.model,name:golem_family_history.model_golem_family_history
msgid "GOLEM Family History Management"
msgstr ""
#. module: golem_family_history
#: model:ir.ui.view,arch_db:golem_family_history.golem_family_form_inherit_golem_family_history
msgid "History"
msgstr ""
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_family_history_ids
msgid "History details"
msgstr ""
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_id
msgid "ID"
msgstr ""
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history___last_update
msgid "Last Modified on"
msgstr ""
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_write_uid
msgid "Last Updated by"
msgstr ""
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_write_date
msgid "Last Updated on"
msgstr ""
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_member_ids
msgid "Members"
msgstr ""
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_season_id
msgid "Season"
msgstr ""
#. module: golem_family_history
#: code:addons/golem_family_history/models/golem_family_history.py:30
#: sql_constraint:golem.family.history:0
#, python-format
msgid "You can only have one history line for each member and season combination."
msgstr ""
#. module: golem_family_history
#: model:ir.model.fields,field_description:golem_family_history.field_golem_family_history_zip_code
msgid "ZIP"
msgstr ""

View File

@ -18,34 +18,33 @@
""" GOLEM Families Adaptations""" """ GOLEM Families Adaptations"""
from odoo import models, fields, api, _ from odoo import models, fields, api
class GolemFamily(models.Model): class GolemFamily(models.Model):
""" GOLEM Family Adaptations """ """ GOLEM Family Adaptations """
_inherit = 'golem.family' _inherit = 'golem.family'
family_history_ids = fields.One2many('golem.family.history', 'family_id') family_history_ids = fields.One2many('golem.family.history', 'family_id',
readonly=True, string='History details')
@api.constrains('city', 'country_id', 'member_ids') @api.constrains('zip', 'city', 'country_id', 'member_ids')
def save_family_history(self): def save_family_history(self):
""" save family history """ """ Saves family history """
default_season = self.env['golem.season'].search([('is_default', '=', True)], limit=1) default_season = self.env['golem.season'].search([('is_default', '=', True)], limit=1)
for family in self: for family in self:
history = self.env['golem.family.history'].search([ history_id = self.env['golem.family.history'].search([
('family_id', '=', family.id), ('family_id', '=', family.id),
('season_id', '=', default_season.id)], limit=1) ('season_id', '=', default_season.id)], limit=1)
if history: history_data = {
history.write({ 'zip_code': family.zip,
'city': family.city, 'city': family.city,
'country_id': family.country_id.id, 'country_id': family.country_id.id,
'member_ids':[(6, False, family.member_ids.ids)] 'member_ids':[(6, False, family.member_ids.ids)]
}) }
if history_id:
history_id.write(history_data)
else: else:
self.env['golem.family.history'].create({ history_data.update({'family_id': family.id,
'family_id': family.id, 'season_id': default_season.id})
'season_id': default_season.id, self.env['golem.family.history'].create(history_data)
'city': family.city,
'country_id': family.country_id.id,
'member_ids':[(6, False, family.member_ids.ids)]
})

View File

@ -18,18 +18,24 @@
""" GOLEM Family History Management """ """ GOLEM Family History Management """
from odoo import models, fields, api, _ from odoo import models, fields, _
class GolemFamilyHistory(models.Model): class GolemFamilyHistory(models.Model):
""" GOLEM Family History Management """ """ GOLEM Family History Management """
_name = 'golem.family.history' _name = 'golem.family.history'
_description = 'GOLEM Family History Management' _description = 'GOLEM Family History Management'
_order = "season_id desc, id desc" _order = 'season_id desc, id desc'
_sql_constraints = [('golem_family_history_family_season_uniq',
'UNIQUE (family_id, season_id)',
_('You can only have one history line for each '
'family and season combination.'))]
family_id = fields.Many2one('golem.family', required=True, auto_join=True, family_id = fields.Many2one('golem.family', required=True, auto_join=True,
ondelete="cascade") string='Family', ondelete='cascade')
season_id = fields.Many2one('golem.season', required=True, auto_join=True, season_id = fields.Many2one('golem.season', required=True, auto_join=True,
ondelete="cascade") string='Season', ondelete='cascade')
zip_code = fields.Char(string='ZIP')
city = fields.Char() city = fields.Char()
country_id = fields.Many2one('res.country', string='Country') country_id = fields.Many2one('res.country', string='Country')
member_ids = fields.Many2many('res.partner') member_ids = fields.Many2many('res.partner', string='Members',
auto_join=True)

View File

@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_golem_family_history_user,Access GOLEM Family History User,model_golem_family_history,golem_base.group_golem_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_golem_family_history_user Access GOLEM Family History User model_golem_family_history golem_base.group_golem_user 1 1 1 1

View File

@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<odoo> <odoo>
<data> <data>
<!-- Forms --> <!-- Forms -->
<record model="ir.ui.view" id="golem_family_form_inherit_golem_family_history"> <record model="ir.ui.view" id="golem_family_form_inherit_golem_family_history">
<field name="name">Golem Family form history adaptations</field> <field name="name">Golem Family form history adaptations</field>
@ -32,6 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<tree> <tree>
<field name="season_id"/> <field name="season_id"/>
<field name="member_ids"/> <field name="member_ids"/>
<field name="zip_code"/>
<field name="city"/> <field name="city"/>
<field name="country_id"/> <field name="country_id"/>
</tree> </tree>
@ -40,5 +42,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</page> </page>
</field> </field>
</record> </record>
</data> </data>
</odoo> </odoo>

View File

@ -19,12 +19,12 @@
{ {
'name': 'GOLEM Member History', 'name': 'GOLEM Member History',
'summary': 'Member History', 'summary': 'Member History',
'version': '10.0.0.0.1', 'version': '10.0.0.1.0',
'category': 'GOLEM', 'category': 'GOLEM',
'author': 'Fabien Bourgeois, Youssef El ouahby', 'author': 'Fabien Bourgeois, Youssef El ouahby',
'license': 'AGPL-3', 'license': 'AGPL-3',
'application': False, 'application': False,
'installable': True, 'installable': True,
'depends': ['golem_member', 'golem_pcs', 'golem_member_familyquotient'], 'depends': ['golem_member', 'golem_pcs', 'golem_member_familyquotient'],
'data': ['views/golem_member_views.xml'] 'data': ['security/ir.model.access.csv', 'views/golem_member_views.xml']
} }

View File

@ -0,0 +1,148 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * golem_member_history
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-10-26 06:41+0000\n"
"PO-Revision-Date: 2018-10-26 08:45+0200\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_area_id
msgid "Area"
msgstr "Territoire"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_city
msgid "City"
msgstr "Ville"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_create_uid
msgid "Created by"
msgstr "Créé par"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_create_date
msgid "Created on"
msgstr "Créé le"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_currency_id
msgid "Currency"
msgstr "Devise"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_display_name
msgid "Display Name"
msgstr "Nom affiché"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_family_quotient
msgid "Family quotient"
msgstr "Quotient familial"
#. module: golem_member_history
#: code:addons/golem_member_history/models/golem_member_history.py:37
#: selection:golem.member.history,gender:0
#, python-format
msgid "Female"
msgstr "Féminin"
#. module: golem_member_history
#: model:ir.model,name:golem_member_history.model_golem_member
msgid "GOLEM Member"
msgstr "Adhérent"
#. module: golem_member_history
#: model:ir.model,name:golem_member_history.model_golem_member_history
msgid "GOLEM Member History Management"
msgstr "GOLEM Member History Management"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_gender
msgid "Gender"
msgstr "Genre"
#. module: golem_member_history
#: model:ir.ui.view,arch_db:golem_member_history.golem_member_form_inherit_golem_member_history
msgid "History"
msgstr "Historique"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_member_history_ids
msgid "History details"
msgstr "Historique"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_id
msgid "ID"
msgstr "ID"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history___last_update
msgid "Last Modified on"
msgstr "Dernière Modification le"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_write_uid
msgid "Last Updated by"
msgstr "Dernière mise à jour par"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_write_date
msgid "Last Updated on"
msgstr "Dernière mise à jour le"
#. module: golem_member_history
#: code:addons/golem_member_history/models/golem_member_history.py:37
#: selection:golem.member.history,gender:0
#, python-format
msgid "Male"
msgstr "Masculin"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_nationality_id
msgid "Nationality"
msgstr "Nationalité"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_pcs_id
msgid "PCS"
msgstr "PCS"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_season_id
msgid "Season"
msgstr "Saison"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_member_id
msgid "Service user"
msgstr "Usager"
#. module: golem_member_history
#: model:ir.model.fields,help:golem_member_history.field_golem_member_history_currency_id
msgid "Utility field to express amount currency"
msgstr "Champ utile pour indiquer le montant de la monnaie"
#. module: golem_member_history
#: code:addons/golem_member_history/models/golem_member_history.py:30
#: sql_constraint:golem.member.history:0
#, python-format
msgid "You can only have one history line for each member and season combination."
msgstr "Vous ne pouvez avoir qu'une seule ligne par usager par saison."
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_zip_code
msgid "ZIP"
msgstr "Code postal"

View File

@ -0,0 +1,148 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * golem_member_history
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-10-26 06:41+0000\n"
"PO-Revision-Date: 2018-10-26 06:41+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_area_id
msgid "Area"
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_city
msgid "City"
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_create_uid
msgid "Created by"
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_create_date
msgid "Created on"
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_currency_id
msgid "Currency"
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_display_name
msgid "Display Name"
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_family_quotient
msgid "Family quotient"
msgstr ""
#. module: golem_member_history
#: code:addons/golem_member_history/models/golem_member_history.py:37
#: selection:golem.member.history,gender:0
#, python-format
msgid "Female"
msgstr ""
#. module: golem_member_history
#: model:ir.model,name:golem_member_history.model_golem_member
msgid "GOLEM Member"
msgstr ""
#. module: golem_member_history
#: model:ir.model,name:golem_member_history.model_golem_member_history
msgid "GOLEM Member History Management"
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_gender
msgid "Gender"
msgstr ""
#. module: golem_member_history
#: model:ir.ui.view,arch_db:golem_member_history.golem_member_form_inherit_golem_member_history
msgid "History"
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_member_history_ids
msgid "History details"
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_id
msgid "ID"
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history___last_update
msgid "Last Modified on"
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_write_uid
msgid "Last Updated by"
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_write_date
msgid "Last Updated on"
msgstr ""
#. module: golem_member_history
#: code:addons/golem_member_history/models/golem_member_history.py:37
#: selection:golem.member.history,gender:0
#, python-format
msgid "Male"
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_nationality_id
msgid "Nationality"
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_pcs_id
msgid "PCS"
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_season_id
msgid "Season"
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_member_id
msgid "Service user"
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,help:golem_member_history.field_golem_member_history_currency_id
msgid "Utility field to express amount currency"
msgstr ""
#. module: golem_member_history
#: code:addons/golem_member_history/models/golem_member_history.py:30
#: sql_constraint:golem.member.history:0
#, python-format
msgid "You can only have one history line for each member and season combination."
msgstr ""
#. module: golem_member_history
#: model:ir.model.fields,field_description:golem_member_history.field_golem_member_history_zip_code
msgid "ZIP"
msgstr ""

View File

@ -25,32 +25,28 @@ class GolemMember(models.Model):
""" GOLEM Member adaptations """ """ GOLEM Member adaptations """
_inherit = 'golem.member' _inherit = 'golem.member'
member_history_ids = fields.One2many('golem.member.history', 'member_id') member_history_ids = fields.One2many('golem.member.history', 'member_id',
readonly=True, string='History details')
@api.constrains('gender', 'area_id', 'city', 'family_quotient', @api.constrains('gender', 'area_id', 'zip', 'city', 'family_quotient',
'pcs_id', 'nationality_id', 'season_ids') 'pcs_id', 'nationality_id', 'season_ids')
def save_history(self): def save_history(self):
""" save member history """ """ Saves member history """
default_season = self.env['golem.season'].search([('is_default', '=', True)], limit=1) default_season = self.env['golem.season'].search([('is_default', '=', True)], limit=1)
for member in self: for member in self:
history = self.env['golem.member.history'].search([ history_id = self.env['golem.member.history'].search([
('member_id', '=', member.id), ('member_id', '=', member.id),
('season_id', '=', default_season.id)], limit=1) ('season_id', '=', default_season.id)], limit=1)
if history: history_data = {'gender': member.gender,
history.write({'gender': member.gender,
'nationality_id': member.nationality_id.id, 'nationality_id': member.nationality_id.id,
'zip_code': member.zip,
'city': member.city, 'city': member.city,
'family_quotient': member.family_quotient, 'family_quotient': member.family_quotient,
'pcs_id': member.pcs_id.id, 'pcs_id': member.pcs_id.id,
'area_id': member.area_id.id}) 'area_id': member.area_id.id}
if history_id:
history_id.write(history_data)
else: else:
self.env['golem.member.history'].create({'member_id': member.id, history_data.update({'member_id': member.id,
'season_id': default_season.id, 'season_id': default_season.id})
'gender': member.gender, self.env['golem.member.history'].create(history_data)
'nationality_id': member.nationality_id.id,
'city': member.city,
'family_quotient': member.family_quotient,
'pcs_id': member.pcs_id.id,
'area_id': member.area_id.id
})

View File

@ -18,22 +18,30 @@
""" GOLEM Member History Management """ """ GOLEM Member History Management """
from odoo import models, fields, api, _ from odoo import models, fields, _
class GolemMemberHistory(models.Model): class GolemMemberHistory(models.Model):
""" GOLEM Member History """ """ GOLEM Member History """
_name = 'golem.member.history' _name = 'golem.member.history'
_description = 'GOLEM Member History Management' _description = 'GOLEM Member History Management'
_order = "season_id desc, id desc" _order = 'season_id desc, id desc'
_sql_constraints = [('golem_member_history_member_season_uniq',
'UNIQUE (member_id, season_id)',
_('You can only have one history line for each '
'member and season combination.'))]
member_id = fields.Many2one('golem.member', required=True, auto_join=True, member_id = fields.Many2one('golem.member', required=True, auto_join=True,
ondelete="cascade") string='Service user', ondelete='cascade')
season_id = fields.Many2one('golem.season', required=True, auto_join=True, season_id = fields.Many2one('golem.season', required=True, auto_join=True,
ondelete="cascade") string='Season', ondelete='cascade')
gender = fields.Selection([('male', _('Male')), ('female', _('Female'))]) gender = fields.Selection([('male', _('Male')), ('female', _('Female'))])
area_id = fields.Many2one('golem.partner.area', string='Area', ondelete="cascade") area_id = fields.Many2one('golem.partner.area', string='Area',
auto_join=True, ondelete='cascade')
zip_code = fields.Char(string='ZIP')
city = fields.Char() city = fields.Char()
family_quotient = fields.Monetary() family_quotient = fields.Monetary()
currency_id = fields.Many2one(related="member_id.currency_id", string="Currency", readonly=True) currency_id = fields.Many2one(related='member_id.currency_id',
string='Currency', readonly=True)
pcs_id = fields.Many2one('golem.pcs', string='PCS') pcs_id = fields.Many2one('golem.pcs', string='PCS')
nationality_id = fields.Many2one('res.country', string="Nationality", ondelete="cascade") nationality_id = fields.Many2one('res.country', string='Nationality',
auto_join=True, ondelete='cascade')

View File

@ -0,0 +1,2 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_golem_member_history_user,Access GOLEM Member History User,model_golem_member_history,golem_base.group_golem_user,1,1,1,1
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_golem_member_history_user Access GOLEM Member History User model_golem_member_history golem_base.group_golem_user 1 1 1 1

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Copyright 2018 Michel Dessenne <michel@yaltik.com> Copyright 2018 Youssef El Ouahby <youssef@yaltik.com>
Copyright 2018 Fabien Bourgeois <fabien@yaltik.com> Copyright 2018 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
@ -35,6 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="gender"/> <field name="gender"/>
<field name="pcs_id"/> <field name="pcs_id"/>
<field name="area_id"/> <field name="area_id"/>
<field name="zip_code"/>
<field name="city"/> <field name="city"/>
<field name="nationality_id"/> <field name="nationality_id"/>
</tree> </tree>