[REF][FIX]GOLEM Member Minor : membership invoice on legal guardians

* Small refacorings ;
* Better require for legal guardian when minor ;
* Adaptations to new legal guardians ;
* Fix on last invoice gathering.
This commit is contained in:
Fabien BOURGEOIS 2018-10-25 17:55:49 +02:00
parent d057579378
commit 3dcdd23d90
12 changed files with 119 additions and 40 deletions

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Fabien Bourgeois <fabien@yaltik.com>
# Copyright 2017-2018 Fabien Bourgeois <fabien@yaltik.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@ -15,4 +15,4 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from . import models
from . import models, wizard

View File

@ -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']
}

View File

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

View File

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

View File

@ -16,4 +16,4 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from . import golem_member, golem_membership, account_invoice, golem_legal_guardian
from . import golem_member, account_invoice, golem_legal_guardian

View File

@ -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()

View File

@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<odoo>
<data>
<!-- Forms -->
<record id="account.invoice_form_inherited_member_minor" model="ir.ui.view">
<field name="name">account.invoice.form.iherited.member.minor</field>
@ -28,12 +29,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="arch" type="xml">
<field name='partner_id' position='after'>
<field name='is_minor_invoice' invisible="1" />
<field name="partner_ids"
widget="many2many_tags"
readonly="1"
<field name="partner_ids" widget="many2many_tags" readonly="1"
attrs="{'invisible': [('is_minor_invoice', '=', False)]}" />
</field>
</field>
</record>
</data>
</odoo>

View File

@ -39,7 +39,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
</group>
</page>
</page>
<xpath expr="//page[@name='membership']/group/group/div/button[1]" position="attributes">
<xpath expr="//page[@name='membership']/group/group/div/button[1]"
position="attributes">
<attribute name="name">membership_invoice_action</attribute>
<attribute name="type">object</attribute>
</xpath>

View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by 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 <http://www.gnu.org/licenses/>.
from . import golem_membership_invoice

View File

@ -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 """
self.ensure_one()
record = self[0]
if record.src_member_id.is_minor:
return {'domain': {'partner_id':
[('id', 'in', record.src_member_id.legal_guardian_ids.ids)]
}
}
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])]

View File

@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<odoo>
<data>
<!-- Forms -->
<record id="golem_membership_invoice_form_inherit" model="ir.ui.view">
<field name="name">membership.invoice.view.form_iherit</field>
@ -27,12 +28,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<field name="inherit_id" ref="golem_membership.golem_membership_invoice_form" />
<field name="arch" type="xml">
<field name='product_id' position='before'>
<field name='partner_id'
attrs="{'invisible': [('src_member_id', '=', False)]}"
options="{'no_create': True}"/>
<field name='src_member_id' invisible="1" />
<field name='src_member_minor' invisible="1" />
<field name='partner_id' string="Legal guardian"
options="{'no_create': True}"
attrs="{'invisible': [('src_member_id', '=', False)], 'required': [('src_member_minor', '=', True)]}" />
</field>
</field>
</record>
</data>
</odoo>

View File

@ -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',