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 e73665c..9ce8794 100644 --- a/golem_member_minor/__manifest__.py +++ b/golem_member_minor/__manifest__.py @@ -19,7 +19,7 @@ { 'name': 'GOLEM members minor', 'summary': 'GOLEM non-profit members minor management', - 'version': '10.0.1.2.0', + 'version': '10.0.1.3.0', 'category': 'GOLEM', 'author': 'Fabien Bourgeois', 'license': 'AGPL-3', @@ -28,6 +28,6 @@ 'depends': ['golem_member'], 'data': ['security/ir.model.access.csv', 'views/golem_member_views.xml', - 'views/golem_membership_invoice.xml', - 'views/account_invoice.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 f03e7dc..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-10-24 05:59+0000\n" -"PO-Revision-Date: 2018-10-24 08:01+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" @@ -30,6 +30,11 @@ msgstr "Peut quitter la structure seul?" 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" @@ -60,11 +65,21 @@ msgstr "GOLEM Legal Guardian Management" 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" @@ -80,8 +95,14 @@ msgstr "Par défaut" 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?" @@ -102,6 +123,7 @@ 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" @@ -130,6 +152,11 @@ msgstr "Mobile" 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 @@ -138,7 +165,7 @@ 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:65 +#: 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 9fb8945..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-10-24 05:59+0000\n" -"PO-Revision-Date: 2018-10-24 05:59+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" @@ -30,6 +30,11 @@ msgstr "" 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" @@ -60,11 +65,21 @@ msgstr "" 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" @@ -80,8 +95,14 @@ msgstr "" 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 "" @@ -102,6 +123,7 @@ 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 "" @@ -130,6 +152,11 @@ msgstr "" 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 @@ -138,7 +165,7 @@ 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:65 +#: 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/models/__init__.py b/golem_member_minor/models/__init__.py index cf411d4..32fd987 100644 --- a/golem_member_minor/models/__init__.py +++ b/golem_member_minor/models/__init__.py @@ -16,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, golem_membership, account_invoice, golem_legal_guardian +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 index ea32f07..53cb662 100644 --- a/golem_member_minor/models/account_invoice.py +++ b/golem_member_minor/models/account_invoice.py @@ -18,11 +18,12 @@ """ Account Invoice adaptations """ -from odoo import models, fields, api +from odoo import models, fields class AccountInvoice(models.Model): """ Account Invoice adaptations """ _inherit = 'account.invoice' - partner_ids = fields.Many2many('res.partner', string="Concerned partners") + partner_ids = fields.Many2many('res.partner', string='Concerned partners', + auto_join=True) is_minor_invoice = fields.Boolean() diff --git a/golem_member_minor/views/account_invoice.xml b/golem_member_minor/views/account_invoice.xml index 5183a51..fcbb818 100644 --- a/golem_member_minor/views/account_invoice.xml +++ b/golem_member_minor/views/account_invoice.xml @@ -20,6 +20,7 @@ along with this program. If not, see . + account.invoice.form.iherited.member.minor @@ -27,13 +28,12 @@ along with this program. If not, see . - - + + + diff --git a/golem_member_minor/views/golem_member_views.xml b/golem_member_minor/views/golem_member_views.xml index 7908ced..ad3eb86 100644 --- a/golem_member_minor/views/golem_member_views.xml +++ b/golem_member_minor/views/golem_member_views.xml @@ -39,7 +39,8 @@ along with this program. If not, see . - + membership_invoice_action object 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/models/golem_membership.py b/golem_member_minor/wizard/golem_membership_invoice.py similarity index 73% rename from golem_member_minor/models/golem_membership.py rename to golem_member_minor/wizard/golem_membership_invoice.py index 512ab0e..e7c74d1 100644 --- a/golem_member_minor/models/golem_membership.py +++ b/golem_member_minor/wizard/golem_membership_invoice.py @@ -26,30 +26,31 @@ class GolemMembershipInvoice(models.TransientModel): _inherit = 'golem.membership.invoice' - src_member_id = fields.Many2one('golem.member') - partner_id = fields.Many2one(required=True) + 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 """ - record = self[0] - if record.src_member_id.is_minor: - return {'domain': {'partner_id': - [('id', 'in', record.src_member_id.legal_guardian_ids.ids)] - } - } + 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 """ + """ 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 and record.src_member_id.is_minor: - #gettin invoice_id from action's domain already declared - invoice_id = (res['domain'][0][2] if - res['domain'][0][2] else False) - if invoice_id: - invoice = self.env['account.invoice'].browse(invoice_id) + 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])] diff --git a/golem_member_minor/views/golem_membership_invoice.xml b/golem_member_minor/wizard/golem_membership_invoice.xml similarity index 78% rename from golem_member_minor/views/golem_membership_invoice.xml rename to golem_member_minor/wizard/golem_membership_invoice.xml index c9ba6f4..1854442 100644 --- a/golem_member_minor/views/golem_membership_invoice.xml +++ b/golem_member_minor/wizard/golem_membership_invoice.xml @@ -20,6 +20,7 @@ along with this program. If not, see . + membership.invoice.view.form_iherit @@ -27,12 +28,14 @@ along with this program. If not, see . - - + + + + 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',