diff --git a/golem_activity_registration_payment/__manifest__.py b/golem_activity_registration_payment/__manifest__.py index 2363982..cfb8e4a 100644 --- a/golem_activity_registration_payment/__manifest__.py +++ b/golem_activity_registration_payment/__manifest__.py @@ -20,7 +20,7 @@ 'name': 'GOLEM Activity Member Registration Payments', 'summary': 'GOLEM Activities Member Registration Payments', 'description': 'GOLEM Activities Member Registration Payments', - 'version': '10.0.0.4.1', + 'version': '10.0.0.5.0', 'category': 'GOLEM', 'author': 'Fabien Bourgeois', 'license': 'AGPL-3', diff --git a/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py b/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py index 6454666..96fd434 100644 --- a/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py +++ b/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Copyright 2017-2018 Fabien Bourgeois +# Copyright 2018 Youssef El Ouahby # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -84,13 +85,21 @@ class GolemActivityRegistrationInvoicing(models.TransientModel): """ Create invoice and lines """ self.ensure_one() partner = self.member_id.partner_id - invoice = self.env['account.invoice'].create({ - 'partner_id': partner.id, - 'account_id': partner.property_account_receivable_id.id, - 'fiscal_position_id': partner.property_account_position_id.id - }) + #check if there is a draft invoice for the current customer + member_line = partner.member_lines.filtered( + lambda ml: (ml.membership_id.membership_season_id == self.season_id + and ml.account_invoice_id.state == 'draft') + ) + if member_line: + invoice = member_line[0].account_invoice_id + else: + invoice = self.env['account.invoice'].create({ + 'partner_id': partner.id, + 'account_id': partner.property_account_receivable_id.id, + 'fiscal_position_id': partner.property_account_position_id.id + }) for line in self.line_ids: - product = line.activity_id.product_id + product = line.activity_id.product_id.product_variant_id invoice_line = self._create_invoice_line(product, line.price, invoice) line.registration_id.invoice_line_id = invoice_line.id return invoice diff --git a/golem_family/__manifest__.py b/golem_family/__manifest__.py index 21b0107..289bda9 100644 --- a/golem_family/__manifest__.py +++ b/golem_family/__manifest__.py @@ -19,7 +19,7 @@ 'name': 'GOLEM families', 'summary': 'GOLEM Members Families', 'description': 'GOLEM Members Families', - 'version': '10.0.2.4.0', + 'version': '10.0.2.5.0', 'category': 'GOLEM', 'author': 'Fabien Bourgeois, Youssef El Ouahby', 'license': 'AGPL-3', diff --git a/golem_family/i18n/fr.po b/golem_family/i18n/fr.po index 062d970..05fbec5 100644 --- a/golem_family/i18n/fr.po +++ b/golem_family/i18n/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-19 07:03+0000\n" -"PO-Revision-Date: 2018-10-19 09:04+0200\n" +"POT-Creation-Date: 2018-10-26 15:44+0000\n" +"PO-Revision-Date: 2018-10-26 17:45+0200\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -52,6 +52,31 @@ msgstr "Région :" msgid "Address" msgstr "Adresse" +#. module: golem_family +#: model:ir.model.fields,field_description:golem_family.field_golem_family_area_id +msgid "Area" +msgstr "Territoire" + +#. module: golem_family +#: model:ir.model.fields,field_description:golem_family.field_golem_family_area_from_street +msgid "Area from street" +msgstr "Territoire automatique depuis la rue" + +#. module: golem_family +#: model:ir.ui.view,arch_db:golem_family.golem_family_form +msgid "Area, quarter..." +msgstr "Lieu, quartier..." + +#. module: golem_family +#: model:ir.model.fields,help:golem_family.field_golem_family_area_id +msgid "Area, quarter... for statistics and activity price." +msgstr "Lieu, quartier... pour les statistiques et les tarifs des activités." + +#. module: golem_family +#: model:ir.ui.view,arch_db:golem_family.golem_family_search +msgid "By area" +msgstr "Par territoire" + #. module: golem_family #: model:ir.ui.view,arch_db:golem_family.golem_family_search msgid "By city" diff --git a/golem_family/i18n/golem_family.pot b/golem_family/i18n/golem_family.pot index b77ee95..6b8ce85 100644 --- a/golem_family/i18n/golem_family.pot +++ b/golem_family/i18n/golem_family.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-19 07:03+0000\n" -"PO-Revision-Date: 2018-10-19 07:03+0000\n" +"POT-Creation-Date: 2018-10-26 15:44+0000\n" +"PO-Revision-Date: 2018-10-26 15:44+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -52,6 +52,31 @@ msgstr "" msgid "Address" msgstr "" +#. module: golem_family +#: model:ir.model.fields,field_description:golem_family.field_golem_family_area_id +msgid "Area" +msgstr "" + +#. module: golem_family +#: model:ir.model.fields,field_description:golem_family.field_golem_family_area_from_street +msgid "Area from street" +msgstr "" + +#. module: golem_family +#: model:ir.ui.view,arch_db:golem_family.golem_family_form +msgid "Area, quarter..." +msgstr "" + +#. module: golem_family +#: model:ir.model.fields,help:golem_family.field_golem_family_area_id +msgid "Area, quarter... for statistics and activity price." +msgstr "" + +#. module: golem_family +#: model:ir.ui.view,arch_db:golem_family.golem_family_search +msgid "By area" +msgstr "" + #. module: golem_family #: model:ir.ui.view,arch_db:golem_family.golem_family_search msgid "By city" diff --git a/golem_family/models/golem_family.py b/golem_family/models/golem_family.py index d6c1c16..2d5211d 100644 --- a/golem_family/models/golem_family.py +++ b/golem_family/models/golem_family.py @@ -145,6 +145,12 @@ class GolemFamily(models.Model): note = fields.Text() count = fields.Integer(compute='_compute_count', store=True) + area_id = fields.Many2one( + 'golem.partner.area', index=True, auto_join=True, string='Area', + help="Area, quarter... for statistics and activity price." + ) + area_from_street = fields.Boolean(store=False, default=False) + @api.depends('member_ids') def _compute_count(self): for family in self: @@ -161,6 +167,34 @@ class GolemFamily(models.Model): 'zip': family.member_ids[0].zip, 'city': family.member_ids[0].city}) + @api.onchange('street') + def onchange_street(self): + """ Area auto assignement """ + for family in self: + mstreet = family.street.strip() if family.street else False + if mstreet and not family.area_id: + street_id = self.env['golem.partner.area.street'].search( + [('name', 'ilike', mstreet)], limit=1 + ) + if street_id: + family.area_id = street_id.area_id + family.area_from_street = True + + @api.constrains('street') + def save_street(self): + """ Save street if no exist """ + for family in self: + if family.street and not family.area_from_street: + mstreet = family.street.strip() + street_id = self.env['golem.partner.area.street'].search( + [('name', 'ilike', mstreet)] + ) + if not street_id: + self.env['golem.partner.area.street'].create( + {'name': mstreet, 'area_id': family.area_id.id} + ) + + class GolemFamilyRole(models.Model): """ GOLEM Family Role """ _name = 'golem.family.role' diff --git a/golem_family/views/golem_family_views.xml b/golem_family/views/golem_family_views.xml index 04ba706..68e52ed 100644 --- a/golem_family/views/golem_family_views.xml +++ b/golem_family/views/golem_family_views.xml @@ -45,6 +45,8 @@ along with this program. If not, see . + @@ -186,6 +188,7 @@ along with this program. If not, see . + @@ -194,6 +197,8 @@ along with this program. If not, see . + diff --git a/golem_family_minor/golem_member.py b/golem_family_history/__init__.py similarity index 66% rename from golem_family_minor/golem_member.py rename to golem_family_history/__init__.py index 96ee293..1fced20 100644 --- a/golem_family_minor/golem_member.py +++ b/golem_family_history/__init__.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- -# Copyright 2017 Fabien Bourgeois +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -15,15 +16,4 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -""" GOLEM Family Minor glue module""" - -from odoo import models, fields - -LEGAL_DMN = "['&', ('family_id', '=', family_id), ('id', '!=', partner_id)]" - - -class GolemMember(models.Model): - """ Member adaptations """ - _inherit = 'golem.member' - - legal_guardian_ids = fields.Many2many(domain=LEGAL_DMN) +from . import models diff --git a/golem_family_history/__manifest__.py b/golem_family_history/__manifest__.py new file mode 100644 index 0000000..cc143fb --- /dev/null +++ b/golem_family_history/__manifest__.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +{ + 'name': 'GOLEM Families History', + 'summary': 'GOLEM Families History', + 'description': 'GOLEM Families History', + 'version': '10.0.0.1.1', + 'category': 'GOLEM', + 'author': 'Fabien Bourgeois, Youssef El ouahby', + 'license': 'AGPL-3', + 'application': False, + 'installable': True, + 'depends': ['golem_family'], + 'data': ['security/ir.model.access.csv', 'views/golem_family_views.xml'] +} diff --git a/golem_family_history/i18n/fr.po b/golem_family_history/i18n/fr.po new file mode 100644 index 0000000..e6e827f --- /dev/null +++ b/golem_family_history/i18n/fr.po @@ -0,0 +1,114 @@ +# 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 15:44+0000\n" +"PO-Revision-Date: 2018-10-26 17:46+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_area_id +msgid "Area" +msgstr "Territoire" + +#. 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" + diff --git a/golem_family_history/i18n/golem_family_history.pot b/golem_family_history/i18n/golem_family_history.pot new file mode 100644 index 0000000..8ab7acc --- /dev/null +++ b/golem_family_history/i18n/golem_family_history.pot @@ -0,0 +1,114 @@ +# 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 15:44+0000\n" +"PO-Revision-Date: 2018-10-26 15:44+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_area_id +msgid "Area" +msgstr "" + +#. 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 family 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 "" + diff --git a/golem_family_history/models/__init__.py b/golem_family_history/models/__init__.py new file mode 100644 index 0000000..1557790 --- /dev/null +++ b/golem_family_history/models/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from . import golem_family_history, golem_family diff --git a/golem_family_history/models/golem_family.py b/golem_family_history/models/golem_family.py new file mode 100644 index 0000000..aef8dcf --- /dev/null +++ b/golem_family_history/models/golem_family.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +""" GOLEM Families Adaptations""" + +from odoo import models, fields, api + + +class GolemFamily(models.Model): + """ GOLEM Family Adaptations """ + _inherit = 'golem.family' + + family_history_ids = fields.One2many('golem.family.history', 'family_id', + readonly=True, string='History details') + + @api.constrains('area_id', 'zip', 'city', 'country_id', 'member_ids') + def save_family_history(self): + """ Saves family history """ + default_season = self.env['golem.season'].search([('is_default', '=', True)], limit=1) + for family in self: + history_id = self.env['golem.family.history'].search([ + ('family_id', '=', family.id), + ('season_id', '=', default_season.id)], limit=1) + history_data = { + 'zip_code': family.zip, + 'area_id': family.area_id.id, + 'city': family.city, + 'country_id': family.country_id.id, + 'member_ids':[(6, False, family.member_ids.ids)] + } + if history_id: + history_id.write(history_data) + else: + history_data.update({'family_id': family.id, + 'season_id': default_season.id}) + self.env['golem.family.history'].create(history_data) diff --git a/golem_family_history/models/golem_family_history.py b/golem_family_history/models/golem_family_history.py new file mode 100644 index 0000000..9add9d0 --- /dev/null +++ b/golem_family_history/models/golem_family_history.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +""" GOLEM Family History Management """ + +from odoo import models, fields, _ + +class GolemFamilyHistory(models.Model): + """ GOLEM Family History Management """ + _name = 'golem.family.history' + _description = 'GOLEM Family History Management' + _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, + string='Family', ondelete='cascade') + season_id = fields.Many2one('golem.season', required=True, auto_join=True, + string='Season', ondelete='cascade') + zip_code = fields.Char(string='ZIP') + area_id = fields.Many2one('golem.partner.area', string='Area', + auto_join=True, ondelete='cascade') + city = fields.Char() + country_id = fields.Many2one('res.country', string='Country') + member_ids = fields.Many2many('res.partner', string='Members', + auto_join=True) diff --git a/golem_family_history/security/ir.model.access.csv b/golem_family_history/security/ir.model.access.csv new file mode 100644 index 0000000..759fb24 --- /dev/null +++ b/golem_family_history/security/ir.model.access.csv @@ -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 diff --git a/golem_family_history/views/golem_family_views.xml b/golem_family_history/views/golem_family_views.xml new file mode 100644 index 0000000..2da14e3 --- /dev/null +++ b/golem_family_history/views/golem_family_views.xml @@ -0,0 +1,48 @@ + + + + + + + + + + Golem Family form history adaptations + golem.family + + + + + + + + + + + + + + + + + + + + + diff --git a/golem_family_membership/__manifest__.py b/golem_family_membership/__manifest__.py index 50ba7d7..9c866fd 100644 --- a/golem_family_membership/__manifest__.py +++ b/golem_family_membership/__manifest__.py @@ -20,7 +20,7 @@ 'name': 'GOLEM Family Memberships', 'summary': 'GOLEM Family Membership Management', 'description': 'GOLEM Family Membership Management', - 'version': '10.0.0.1.0', + 'version': '10.0.0.1.1', 'category': 'GOLEM', 'author': 'Fabien Bourgeois, Youssef ELOUAHBY', 'license': 'AGPL-3', diff --git a/golem_family_membership/wizard/golem_membership_invoice.py b/golem_family_membership/wizard/golem_membership_invoice.py index 6db2ac2..debd2b5 100644 --- a/golem_family_membership/wizard/golem_membership_invoice.py +++ b/golem_family_membership/wizard/golem_membership_invoice.py @@ -25,10 +25,9 @@ class GolemMembershipInvoice(models.TransientModel): _inherit = 'golem.membership.invoice' family_id = fields.Many2one('golem.family', string='Family', - required=True, ondelete='cascade') + ondelete='cascade') member_ids = fields.Many2many('res.partner', string='Concerned members') - on_the_name_of = fields.Many2one('res.partner', ondelete='cascade', - required=True) + on_the_name_of = fields.Many2one('res.partner', ondelete='cascade') @api.onchange('family_id') def onchange_family(self): diff --git a/golem_family_membership/wizard/golem_membership_invoice_views.xml b/golem_family_membership/wizard/golem_membership_invoice_views.xml index 78bf637..0876d88 100644 --- a/golem_family_membership/wizard/golem_membership_invoice_views.xml +++ b/golem_family_membership/wizard/golem_membership_invoice_views.xml @@ -31,7 +31,7 @@ along with this program. If not, see . + attrs="{'readonly': [('member_ids', '=', [])], 'required': [('family_id', '!=', False)]}" /> diff --git a/golem_family_minor/__init__.py b/golem_family_minor/__init__.py index 8d28962..643d893 100644 --- a/golem_family_minor/__init__.py +++ b/golem_family_minor/__init__.py @@ -14,5 +14,3 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . - -from . import golem_member diff --git a/golem_family_minor/__manifest__.py b/golem_family_minor/__manifest__.py index da1ab91..44b581c 100644 --- a/golem_family_minor/__manifest__.py +++ b/golem_family_minor/__manifest__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2016 Fabien Bourgeois +# Copyright 2016-2018 Fabien Bourgeois # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -18,7 +18,7 @@ { 'name': 'GOLEM members minor and family', 'summary': 'GOLEM non-profit members family + minor management', - 'version': '10.0.1.0.0', + 'version': '10.0.1.1.0', 'category': 'GOLEM', 'author': 'Fabien Bourgeois', 'license': 'AGPL-3', diff --git a/golem_member/i18n/fr.po b/golem_member/i18n/fr.po index 77e1429..776e3e9 100644 --- a/golem_member/i18n/fr.po +++ b/golem_member/i18n/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-22 16:02+0000\n" -"PO-Revision-Date: 2018-10-22 18:09+0200\n" +"POT-Creation-Date: 2018-10-26 15:43+0000\n" +"PO-Revision-Date: 2018-10-26 17:47+0200\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -67,6 +67,7 @@ msgstr "Appliquer pour les nouveaux adhérents" #. module: golem_member #: model:ir.model.fields,field_description:golem_member.field_golem_member_area_id +#: model:ir.model.fields,field_description:golem_member.field_golem_partner_area_street_area_id #: model:ir.model.fields,field_description:golem_member.field_res_partner_area_id #: model:ir.model.fields,field_description:golem_member.field_res_users_area_id msgid "Area" @@ -79,11 +80,6 @@ msgstr "Territoire" msgid "Area from street" msgstr "Territoire automatique depuis la rue" -#. module: golem_member -#: model:ir.model.fields,field_description:golem_member.field_golem_partner_area_street_area_id -msgid "Area id" -msgstr "Territoire" - #. module: golem_member #: model:ir.ui.view,arch_db:golem_member.golem_member_form #: model:ir.ui.view,arch_db:golem_member.res_partner_form_inherit_golem_member diff --git a/golem_member/i18n/golem_member.pot b/golem_member/i18n/golem_member.pot index f53956e..c4e6e10 100644 --- a/golem_member/i18n/golem_member.pot +++ b/golem_member/i18n/golem_member.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-10-22 16:02+0000\n" -"PO-Revision-Date: 2018-10-22 16:02+0000\n" +"POT-Creation-Date: 2018-10-26 15:43+0000\n" +"PO-Revision-Date: 2018-10-26 15:43+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -67,6 +67,7 @@ msgstr "" #. module: golem_member #: model:ir.model.fields,field_description:golem_member.field_golem_member_area_id +#: model:ir.model.fields,field_description:golem_member.field_golem_partner_area_street_area_id #: model:ir.model.fields,field_description:golem_member.field_res_partner_area_id #: model:ir.model.fields,field_description:golem_member.field_res_users_area_id msgid "Area" @@ -79,11 +80,6 @@ msgstr "" msgid "Area from street" msgstr "" -#. module: golem_member -#: model:ir.model.fields,field_description:golem_member.field_golem_partner_area_street_area_id -msgid "Area id" -msgstr "" - #. module: golem_member #: model:ir.ui.view,arch_db:golem_member.golem_member_form #: model:ir.ui.view,arch_db:golem_member.res_partner_form_inherit_golem_member diff --git a/golem_member/models/golem_member.py b/golem_member/models/golem_member.py index 449d3a9..e9e9fd3 100644 --- a/golem_member/models/golem_member.py +++ b/golem_member/models/golem_member.py @@ -79,7 +79,7 @@ class GolemPartnerAreaStreet(models.Model): _description = 'GOLEM Partner Area Street' name = fields.Char(required=True) - area_id = fields.Many2one('golem.partner.area', required=True, sring='Area', + area_id = fields.Many2one('golem.partner.area', required=True, string='Area', index=True, auto_join=True, ondelete='set null') diff --git a/golem_member_history/__init__.py b/golem_member_history/__init__.py new file mode 100644 index 0000000..1fced20 --- /dev/null +++ b/golem_member_history/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from . import models diff --git a/golem_member_history/__manifest__.py b/golem_member_history/__manifest__.py new file mode 100644 index 0000000..ed47bb9 --- /dev/null +++ b/golem_member_history/__manifest__.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +{ + 'name': 'GOLEM Member History', + 'summary': 'Member History', + 'version': '10.0.0.1.0', + 'category': 'GOLEM', + 'author': 'Fabien Bourgeois, Youssef El ouahby', + 'license': 'AGPL-3', + 'application': False, + 'installable': True, + 'depends': ['golem_member', 'golem_pcs', 'golem_member_familyquotient'], + 'data': ['security/ir.model.access.csv', 'views/golem_member_views.xml'] +} diff --git a/golem_member_history/i18n/fr.po b/golem_member_history/i18n/fr.po new file mode 100644 index 0000000..a3f3be1 --- /dev/null +++ b/golem_member_history/i18n/fr.po @@ -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" + diff --git a/golem_member_history/i18n/golem_member_history.pot b/golem_member_history/i18n/golem_member_history.pot new file mode 100644 index 0000000..575c6ab --- /dev/null +++ b/golem_member_history/i18n/golem_member_history.pot @@ -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 "" + diff --git a/golem_member_history/models/__init__.py b/golem_member_history/models/__init__.py new file mode 100644 index 0000000..846f25b --- /dev/null +++ b/golem_member_history/models/__init__.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from . import golem_member_history, golem_member diff --git a/golem_member_history/models/golem_member.py b/golem_member_history/models/golem_member.py new file mode 100644 index 0000000..b4386ce --- /dev/null +++ b/golem_member_history/models/golem_member.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +""" GOLEM Member adaptations """ + +from odoo import models, fields, api + + +class GolemMember(models.Model): + """ GOLEM Member adaptations """ + _inherit = 'golem.member' + + member_history_ids = fields.One2many('golem.member.history', 'member_id', + readonly=True, string='History details') + + @api.constrains('gender', 'area_id', 'zip', 'city', 'family_quotient', + 'pcs_id', 'nationality_id', 'season_ids') + def save_history(self): + """ Saves member history """ + default_season = self.env['golem.season'].search([('is_default', '=', True)], limit=1) + for member in self: + history_id = self.env['golem.member.history'].search([ + ('member_id', '=', member.id), + ('season_id', '=', default_season.id)], limit=1) + history_data = {'gender': member.gender, + 'nationality_id': member.nationality_id.id, + 'zip_code': member.zip, + 'city': member.city, + 'family_quotient': member.family_quotient, + 'pcs_id': member.pcs_id.id, + 'area_id': member.area_id.id} + if history_id: + history_id.write(history_data) + else: + history_data.update({'member_id': member.id, + 'season_id': default_season.id}) + self.env['golem.member.history'].create(history_data) diff --git a/golem_member_history/models/golem_member_history.py b/golem_member_history/models/golem_member_history.py new file mode 100644 index 0000000..f304a01 --- /dev/null +++ b/golem_member_history/models/golem_member_history.py @@ -0,0 +1,47 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +""" GOLEM Member History Management """ + +from odoo import models, fields, _ + +class GolemMemberHistory(models.Model): + """ GOLEM Member History """ + _name = 'golem.member.history' + _description = 'GOLEM Member History Management' + _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, + string='Service user', ondelete='cascade') + season_id = fields.Many2one('golem.season', required=True, auto_join=True, + string='Season', ondelete='cascade') + gender = fields.Selection([('male', _('Male')), ('female', _('Female'))]) + area_id = fields.Many2one('golem.partner.area', string='Area', + auto_join=True, ondelete='cascade') + zip_code = fields.Char(string='ZIP') + city = fields.Char() + family_quotient = fields.Monetary() + currency_id = fields.Many2one(related='member_id.currency_id', + string='Currency', readonly=True) + pcs_id = fields.Many2one('golem.pcs', string='PCS') + nationality_id = fields.Many2one('res.country', string='Nationality', + auto_join=True, ondelete='cascade') diff --git a/golem_member_history/security/ir.model.access.csv b/golem_member_history/security/ir.model.access.csv new file mode 100644 index 0000000..0fff7e0 --- /dev/null +++ b/golem_member_history/security/ir.model.access.csv @@ -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 diff --git a/golem_member_history/views/golem_member_views.xml b/golem_member_history/views/golem_member_views.xml new file mode 100644 index 0000000..7f69fe3 --- /dev/null +++ b/golem_member_history/views/golem_member_views.xml @@ -0,0 +1,49 @@ + + + + + + + + + + GOLEM Member Form history adaptations + golem.member + + + + + + + + + + + + + + + + + + + + + + diff --git a/golem_member_minor/__init__.py b/golem_member_minor/__init__.py index 82314be..e460319 100644 --- a/golem_member_minor/__init__.py +++ b/golem_member_minor/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright 2017 Fabien Bourgeois +# Copyright 2017-2018 Fabien Bourgeois # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -15,4 +15,4 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from . import models +from . import models, wizard diff --git a/golem_member_minor/__manifest__.py b/golem_member_minor/__manifest__.py index c966b54..9ce8794 100644 --- a/golem_member_minor/__manifest__.py +++ b/golem_member_minor/__manifest__.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Copyright 2017-2018 Fabien Bourgeois +# Copyright 2018 Youssef El Ouahby # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -18,12 +19,15 @@ { 'name': 'GOLEM members minor', 'summary': 'GOLEM non-profit members minor management', - 'version': '10.0.1.1.0', + 'version': '10.0.1.3.0', 'category': 'GOLEM', 'author': 'Fabien Bourgeois', 'license': 'AGPL-3', 'application': False, 'installable': True, 'depends': ['golem_member'], - 'data': ['views/golem_member_views.xml'] + 'data': ['security/ir.model.access.csv', + 'views/golem_member_views.xml', + 'views/account_invoice.xml', + 'wizard/golem_membership_invoice.xml'] } diff --git a/golem_member_minor/i18n/fr.po b/golem_member_minor/i18n/fr.po index 5834c19..b642b63 100644 --- a/golem_member_minor/i18n/fr.po +++ b/golem_member_minor/i18n/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-08-26 16:15+0000\n" -"PO-Revision-Date: 2018-08-26 18:15+0200\n" +"POT-Creation-Date: 2018-10-25 15:51+0000\n" +"PO-Revision-Date: 2018-10-25 17:52+0200\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -25,33 +25,148 @@ msgstr "Participation aux activités?" msgid "Can leave alone?" msgstr "Peut quitter la structure seul?" +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_contact_address +msgid "Complete Address" +msgstr "Adresse complète" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_account_invoice_partner_ids +msgid "Concerned partners" +msgstr "Contacts concernés" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_create_uid +msgid "Created by" +msgstr "Créé par" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_create_date +msgid "Created on" +msgstr "Créé le" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_display_name +msgid "Display Name" +msgstr "Nom affiché" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_email +msgid "Email" +msgstr "Courriel" + +#. module: golem_member_minor +#: model:ir.model,name:golem_member_minor.model_golem_legal_guardian +msgid "GOLEM Legal Guardian Management" +msgstr "GOLEM Legal Guardian Management" + #. module: golem_member_minor #: model:ir.model,name:golem_member_minor.model_golem_member msgid "GOLEM Member" msgstr "Usager" +#. module: golem_member_minor +#: model:ir.model,name:golem_member_minor.model_golem_membership_invoice +msgid "GOLEM MemberShip invoicing" +msgstr "Facturation de l'adhésion" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_id +msgid "ID" +msgstr "ID" + +#. module: golem_member_minor +#: model:ir.model,name:golem_member_minor.model_account_invoice +msgid "Invoice" +msgstr "Facture" + #. module: golem_member_minor #: model:ir.ui.view,arch_db:golem_member_minor.golem_member_search_inherit_minor msgid "Is adult" msgstr "Est adulte" +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_is_default_guardian +msgid "Is default guardian" +msgstr "Par défaut" + #. module: golem_member_minor #: model:ir.ui.view,arch_db:golem_member_minor.golem_member_search_inherit_minor msgid "Is minor" msgstr "Est mineur" +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_account_invoice_is_minor_invoice +msgid "Is minor invoice" +msgstr "Facture sur mineur" + #. module: golem_member_minor #: model:ir.model.fields,field_description:golem_member_minor.field_golem_member_is_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_membership_invoice_src_member_minor msgid "Is minor?" msgstr "Est mineur?" +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian___last_update +msgid "Last Modified on" +msgstr "Dernière Modification le" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_write_uid +msgid "Last Updated by" +msgstr "Dernière mise à jour par" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_write_date +msgid "Last Updated on" +msgstr "Dernière mise à jour le" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_legal_guardian_id +#: model:ir.ui.view,arch_db:golem_member_minor.golem_membership_invoice_form_inherit +msgid "Legal guardian" +msgstr "Représentant légal" + #. module: golem_member_minor #: model:ir.model.fields,field_description:golem_member_minor.field_golem_member_legal_guardian_ids msgid "Legal guardians" msgstr "Représentants légaux" +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_member_id +msgid "Member id" +msgstr "Usager" + #. module: golem_member_minor #: model:ir.ui.view,arch_db:golem_member_minor.golem_member_form_inherit_minor msgid "Minor" msgstr "Mineur" +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_mobile +msgid "Mobile" +msgstr "Mobile" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_phone +msgid "Phone" +msgstr "Téléphone" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_membership_invoice_src_member_id +msgid "Src member id" +msgstr "Usager" + +#. module: golem_member_minor +#: code:addons/golem_member_minor/models/golem_legal_guardian.py:29 +#: sql_constraint:golem.legal.guardian:0 +#, python-format +msgid "There are doubles in your legal guardians. Please check your fills." +msgstr "Il y a des doublons au niveau des représentants légaux. Merci de vérifier vos saisies." + +#. module: golem_member_minor +#: code:addons/golem_member_minor/models/golem_member.py:76 +#, python-format +msgid "You must have one and only one default legal guardian. Please check your fills." +msgstr "Vous ne pouvez avoir qu'un et un seul représentant légal par défaut. Merci de vérifier vos saisies." + diff --git a/golem_member_minor/i18n/golem_member_minor.pot b/golem_member_minor/i18n/golem_member_minor.pot index 2059c34..7227fb6 100644 --- a/golem_member_minor/i18n/golem_member_minor.pot +++ b/golem_member_minor/i18n/golem_member_minor.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 10.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-08-26 16:15+0000\n" -"PO-Revision-Date: 2018-08-26 16:15+0000\n" +"POT-Creation-Date: 2018-10-25 15:51+0000\n" +"PO-Revision-Date: 2018-10-25 15:51+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -25,33 +25,148 @@ msgstr "" msgid "Can leave alone?" msgstr "" +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_contact_address +msgid "Complete Address" +msgstr "" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_account_invoice_partner_ids +msgid "Concerned partners" +msgstr "" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_create_uid +msgid "Created by" +msgstr "" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_create_date +msgid "Created on" +msgstr "" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_display_name +msgid "Display Name" +msgstr "" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_email +msgid "Email" +msgstr "" + +#. module: golem_member_minor +#: model:ir.model,name:golem_member_minor.model_golem_legal_guardian +msgid "GOLEM Legal Guardian Management" +msgstr "" + #. module: golem_member_minor #: model:ir.model,name:golem_member_minor.model_golem_member msgid "GOLEM Member" msgstr "" +#. module: golem_member_minor +#: model:ir.model,name:golem_member_minor.model_golem_membership_invoice +msgid "GOLEM MemberShip invoicing" +msgstr "" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_id +msgid "ID" +msgstr "" + +#. module: golem_member_minor +#: model:ir.model,name:golem_member_minor.model_account_invoice +msgid "Invoice" +msgstr "" + #. module: golem_member_minor #: model:ir.ui.view,arch_db:golem_member_minor.golem_member_search_inherit_minor msgid "Is adult" msgstr "" +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_is_default_guardian +msgid "Is default guardian" +msgstr "" + #. module: golem_member_minor #: model:ir.ui.view,arch_db:golem_member_minor.golem_member_search_inherit_minor msgid "Is minor" msgstr "" +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_account_invoice_is_minor_invoice +msgid "Is minor invoice" +msgstr "" + #. module: golem_member_minor #: model:ir.model.fields,field_description:golem_member_minor.field_golem_member_is_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_membership_invoice_src_member_minor msgid "Is minor?" msgstr "" +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian___last_update +msgid "Last Modified on" +msgstr "" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_write_uid +msgid "Last Updated by" +msgstr "" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_write_date +msgid "Last Updated on" +msgstr "" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_legal_guardian_id +#: model:ir.ui.view,arch_db:golem_member_minor.golem_membership_invoice_form_inherit +msgid "Legal guardian" +msgstr "" + #. module: golem_member_minor #: model:ir.model.fields,field_description:golem_member_minor.field_golem_member_legal_guardian_ids msgid "Legal guardians" msgstr "" +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_member_id +msgid "Member id" +msgstr "" + #. module: golem_member_minor #: model:ir.ui.view,arch_db:golem_member_minor.golem_member_form_inherit_minor msgid "Minor" msgstr "" +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_mobile +msgid "Mobile" +msgstr "" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_legal_guardian_phone +msgid "Phone" +msgstr "" + +#. module: golem_member_minor +#: model:ir.model.fields,field_description:golem_member_minor.field_golem_membership_invoice_src_member_id +msgid "Src member id" +msgstr "" + +#. module: golem_member_minor +#: code:addons/golem_member_minor/models/golem_legal_guardian.py:29 +#: sql_constraint:golem.legal.guardian:0 +#, python-format +msgid "There are doubles in your legal guardians. Please check your fills." +msgstr "" + +#. module: golem_member_minor +#: code:addons/golem_member_minor/models/golem_member.py:76 +#, python-format +msgid "You must have one and only one default legal guardian. Please check your fills." +msgstr "" + diff --git a/golem_member_minor/migrations/10.0.1.1.3/post-migrate.py b/golem_member_minor/migrations/10.0.1.1.3/post-migrate.py new file mode 100644 index 0000000..7b96e02 --- /dev/null +++ b/golem_member_minor/migrations/10.0.1.1.3/post-migrate.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +""" Post-migration script """ + +from openupgradelib import openupgrade + +@openupgrade.migrate(use_env=False) +def migrate(cursor, version): + """ Recover old legal_gardian_ids and delete their database table """ + cursor.execute('SELECT golem_member_id, res_partner_id FROM golem_member_res_partner_rel') + for member_id, legal_guardian_id in cursor.fetchall(): + cursor.execute('''INSERT INTO golem_legal_guardian(member_id, legal_guardian_id) VALUES + (%s, %s)''' % (member_id, legal_guardian_id)) + cursor.execute('DROP TABLE golem_member_res_partner_rel') + cursor.execute('DELETE FROM ir_model_fields WHERE name=\'legal_guardian_ids\' ' + 'AND ttype=\'many2many\'') diff --git a/golem_member_minor/models/__init__.py b/golem_member_minor/models/__init__.py index f4e5ac9..32fd987 100644 --- a/golem_member_minor/models/__init__.py +++ b/golem_member_minor/models/__init__.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Copyright 2017 Fabien Bourgeois +# Copyright 2018 Youssef El Ouahby # # 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,4 +16,4 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . -from . import golem_member +from . import golem_member, account_invoice, golem_legal_guardian diff --git a/golem_member_minor/models/account_invoice.py b/golem_member_minor/models/account_invoice.py new file mode 100644 index 0000000..53cb662 --- /dev/null +++ b/golem_member_minor/models/account_invoice.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Fabien Bourgeois +# Copyright 2018 Youssef El Ouahby +# +# 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 the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +""" Account Invoice adaptations """ + +from odoo import models, fields + +class AccountInvoice(models.Model): + """ Account Invoice adaptations """ + _inherit = 'account.invoice' + + partner_ids = fields.Many2many('res.partner', string='Concerned partners', + auto_join=True) + is_minor_invoice = fields.Boolean() diff --git a/golem_member_minor/models/golem_legal_guardian.py b/golem_member_minor/models/golem_legal_guardian.py new file mode 100644 index 0000000..2e5e1df --- /dev/null +++ b/golem_member_minor/models/golem_legal_guardian.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Youssef El Ouahby +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +""" GOLEM Legal Guardian Management """ + +from odoo import models, fields, _ + +class GolemLegalGuardian(models.Model): + """ GOLEM Legal Guardian Management """ + _name = 'golem.legal.guardian' + _description = 'GOLEM Legal Guardian Management' + _sql_constraints = [( + 'golem_legal_guardian_uniq', 'UNIQUE (member_id, legal_guardian_id)', + _('There are doubles in your legal guardians. Please check your fills.') + )] + + member_id = fields.Many2one('golem.member', required=True, + index=True, auto_join=True, + ondelete='cascade') + legal_guardian_id = fields.Many2one( + 'res.partner', required=True, index=True, auto_join=True, + string='Legal guardian', ondelete='cascade', + domain="[('is_company', '=', False)]" + ) + contact_address = fields.Char(related='legal_guardian_id.contact_address') + phone = fields.Char(related='legal_guardian_id.phone') + mobile = fields.Char(related='legal_guardian_id.mobile') + email = fields.Char(related='legal_guardian_id.email') + is_default_guardian = fields.Boolean() diff --git a/golem_member_minor/models/golem_member.py b/golem_member_minor/models/golem_member.py index ab31550..6048b3c 100644 --- a/golem_member_minor/models/golem_member.py +++ b/golem_member_minor/models/golem_member.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # Copyright 2017-2018 Fabien Bourgeois +# Copyright 2018 Youssef El Ouahby # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -18,7 +19,8 @@ """ GOLEM Member Minor management """ from datetime import date, timedelta -from odoo import models, fields, api +from odoo import models, fields, api, _ +from odoo.exceptions import ValidationError ADULT_DURATION = timedelta(days=365.25*18) @@ -26,9 +28,8 @@ class GolemMember(models.Model): """ GOLEM Member adaptations """ _inherit = 'golem.member' - legal_guardian_ids = fields.Many2many( - 'res.partner', string='Legal guardians', index=True, auto_join=True, - domain="['&', ('is_company', '=', False), ('id', '!=', partner_id)]") + legal_guardian_ids = fields.One2many('golem.legal.guardian', 'member_id', + string='Legal guardians') activities_participation = fields.Boolean('Activities participation?') leave_alone = fields.Boolean('Can leave alone?') is_minor = fields.Boolean('Is minor?', compute='_compute_is_minor', @@ -52,3 +53,26 @@ class GolemMember(models.Model): else: operator = '<=' if value else '>' return [('birthdate_date', operator, adult_date)] + + def membership_invoice_action(self): + """ Membership invoice action for minor member """ + self.ensure_one() + member = self[0] + action = self.env.ref('golem_member.golem_membership_invoice_action').read()[0] + if member.is_minor: + action['context'] = {'default_src_member_id': member.id, + 'default_partner_id': False} + return action + + @api.constrains('legal_guardian_ids') + def check_default_guardian(self): + """ Ensures there is one and only one default guardian, no double """ + for member in self: + if len(member.legal_guardian_ids): + default_guardians_count = len(member.legal_guardian_ids.filtered( + 'is_default_guardian' + )) + if not default_guardians_count or default_guardians_count > 1: + verr = _('You must have one and only one default legal ' + 'guardian. Please check your fills.') + raise ValidationError(verr) diff --git a/golem_member_minor/models/res_partner.py b/golem_member_minor/models/res_partner.py new file mode 100644 index 0000000..5a17c8d --- /dev/null +++ b/golem_member_minor/models/res_partner.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- + +# Copyright 2017-2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +""" Res Partner adaptations """ + +from odoo import models, fields + +class ResPartner(models.Model): + """ Res Partner adaptations """ + _inherit = 'res.partner' + + is_default_gardian = fields.Boolean() + + def do_default_gardian(self): + """ make only default gardian """ + self.ensure_one() + self.is_default_gardian = True + member_id = self._context.get('member_id', False) diff --git a/golem_member_minor/security/ir.model.access.csv b/golem_member_minor/security/ir.model.access.csv new file mode 100644 index 0000000..3e6751c --- /dev/null +++ b/golem_member_minor/security/ir.model.access.csv @@ -0,0 +1,2 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +access_golem_legal_guardian_user,Access GOLEM Legal Guardian User,model_golem_legal_guardian,golem_base.group_golem_user,1,1,1,1 diff --git a/golem_member_minor/views/account_invoice.xml b/golem_member_minor/views/account_invoice.xml new file mode 100644 index 0000000..fcbb818 --- /dev/null +++ b/golem_member_minor/views/account_invoice.xml @@ -0,0 +1,39 @@ + + + + + + + + + + account.invoice.form.iherited.member.minor + account.invoice + + + + + + + + + + + diff --git a/golem_member_minor/views/golem_member_views.xml b/golem_member_minor/views/golem_member_views.xml index 412df59..ad3eb86 100644 --- a/golem_member_minor/views/golem_member_views.xml +++ b/golem_member_minor/views/golem_member_views.xml @@ -2,6 +2,7 @@ + Add Minor Page/Tab golem.member @@ -34,19 +35,47 @@ along with this program. If not, see . - - - - - - - - - + + + membership_invoice_action + object + + + + + + GOLEM Legal Guardian Form + golem.legal.guardian + +
+ + + + + + + +
+
+
+ + + + GOLEM Legal Guardian Tree + golem.legal.guardian + + + + + + + + + diff --git a/golem_member_minor/wizard/__init__.py b/golem_member_minor/wizard/__init__.py new file mode 100644 index 0000000..bd92ed2 --- /dev/null +++ b/golem_member_minor/wizard/__init__.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Fabien Bourgeois +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +from . import golem_membership_invoice diff --git a/golem_member_minor/wizard/golem_membership_invoice.py b/golem_member_minor/wizard/golem_membership_invoice.py new file mode 100644 index 0000000..e7c74d1 --- /dev/null +++ b/golem_member_minor/wizard/golem_membership_invoice.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- + +# Copyright 2018 Fabien Bourgeois +# Copyright 2018 Youssef El Ouahby +# +# 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 the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +""" GOLEM Membership """ + +from odoo import models, fields, api + + +class GolemMembershipInvoice(models.TransientModel): + """ Membership invoicing """ + _inherit = 'golem.membership.invoice' + + + src_member_id = fields.Many2one('golem.member', ondelete='cascade') + src_member_minor = fields.Boolean(related='src_member_id.is_minor') + + @api.onchange('src_member_id') + def onchange_member(self): + """ Set partner domain if src_member_id is filled """ + self.ensure_one() + record = self[0] + domain = ([('id', 'in', + record.src_member_id.mapped('legal_guardian_ids.legal_guardian_id').ids)] + if record.src_member_id.is_minor else []) + return {'domain': {'partner_id': domain}} + + @api.multi + def membership_invoice(self): + """ Add partners concerned to invoice and move membership from legal + guardian to minor """ + self.ensure_one() + record = self[0] + res = super(GolemMembershipInvoice, self).membership_invoice() + if record.src_member_id.is_minor: + # Getting invoice IDS from action's domain already declared + invoice_ids = (res['domain'][0][2] or False) + if invoice_ids: # As invoice_ids is a Python list, empty or not + invoice = self.env['account.invoice'].browse(invoice_ids)[-1] + invoice.is_minor_invoice = True + invoice.partner_ids = [(6, 0, [record.partner_id.id, + record.src_member_id.partner_id.id])] + # move the created membership from legal guardian to the minor + membership_line = record.partner_id.member_lines[0] + membership_line.copy({'partner': record.src_member_id.partner_id.id}) + membership_line.unlink() + return res diff --git a/golem_member_minor/wizard/golem_membership_invoice.xml b/golem_member_minor/wizard/golem_membership_invoice.xml new file mode 100644 index 0000000..1854442 --- /dev/null +++ b/golem_member_minor/wizard/golem_membership_invoice.xml @@ -0,0 +1,41 @@ + + + + + + + + + + membership.invoice.view.form_iherit + golem.membership.invoice + + + + + + + + + + + + diff --git a/golem_membership/models/golem_membership.py b/golem_membership/models/golem_membership.py index 3c4dbcf..85ed4f9 100644 --- a/golem_membership/models/golem_membership.py +++ b/golem_membership/models/golem_membership.py @@ -26,7 +26,8 @@ class GolemMembershipInvoice(models.TransientModel): _name = 'golem.membership.invoice' _description = 'GOLEM MemberShip invoicing' - partner_id = fields.Many2one('res.partner', 'Partner') + partner_id = fields.Many2one('res.partner', 'Partner', required=True, + ondelete='cascade') product_id = fields.Many2one('product.product', 'Membership', required=True) member_price = fields.Float('Member Price',