[ADD][REF]GOLEM Activity Registration Payment : refactor addons and depndencies

* Payment may not have minor as dependency, so we should not use it for minors ;
* Add two glue addons with some functional around guardians for minor.
This commit is contained in:
Fabien BOURGEOIS 2018-11-01 18:47:21 +01:00
parent c8ccf3e4fa
commit a11675fe35
18 changed files with 418 additions and 46 deletions

View File

@ -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.6.0',
'version': '10.0.0.6.1',
'category': 'GOLEM',
'author': 'Fabien Bourgeois',
'license': 'AGPL-3',

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-09-26 09:44+0000\n"
"PO-Revision-Date: 2018-09-26 11:58+0200\n"
"POT-Creation-Date: 2018-11-01 17:43+0000\n"
"PO-Revision-Date: 2018-11-01 18:45+0100\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@ -157,14 +157,14 @@ msgid "GOLEM Member"
msgstr "Adhérent"
#. module: golem_activity_registration_payment
#: code:addons/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py:153
#: code:addons/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py:161
#: model:ir.model.fields,field_description:golem_activity_registration_payment.field_golem_activity_registration_invoicing_invoice_id
#, python-format
msgid "Generated invoice"
msgstr "Facture générée"
#. module: golem_activity_registration_payment
#: code:addons/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py:168
#: code:addons/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py:176
#: model:ir.model.fields,field_description:golem_activity_registration_payment.field_golem_activity_registration_invoicing_payment_ids
#, python-format
msgid "Generated payments"
@ -351,13 +351,13 @@ msgid "Status"
msgstr "État"
#. module: golem_activity_registration_payment
#: code:addons/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py:149
#: code:addons/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py:157
#, python-format
msgid "There is no generated invoice."
msgstr "Il n'y a pas de facture générée."
#. module: golem_activity_registration_payment
#: code:addons/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py:164
#: code:addons/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py:172
#, python-format
msgid "There is no generated payments."
msgstr "Il n'y a pas de paiement généré."

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-09-26 09:44+0000\n"
"PO-Revision-Date: 2018-09-26 09:44+0000\n"
"POT-Creation-Date: 2018-11-01 17:43+0000\n"
"PO-Revision-Date: 2018-11-01 17:43+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
@ -153,14 +153,14 @@ msgid "GOLEM Member"
msgstr ""
#. module: golem_activity_registration_payment
#: code:addons/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py:153
#: code:addons/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py:161
#: model:ir.model.fields,field_description:golem_activity_registration_payment.field_golem_activity_registration_invoicing_invoice_id
#, python-format
msgid "Generated invoice"
msgstr ""
#. module: golem_activity_registration_payment
#: code:addons/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py:168
#: code:addons/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py:176
#: model:ir.model.fields,field_description:golem_activity_registration_payment.field_golem_activity_registration_invoicing_payment_ids
#, python-format
msgid "Generated payments"
@ -347,13 +347,13 @@ msgid "Status"
msgstr ""
#. module: golem_activity_registration_payment
#: code:addons/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py:149
#: code:addons/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py:157
#, python-format
msgid "There is no generated invoice."
msgstr ""
#. module: golem_activity_registration_payment
#: code:addons/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py:164
#: code:addons/golem_activity_registration_payment/wizard/golem_activity_registration_invoicing.py:172
#, python-format
msgid "There is no generated payments."
msgstr ""

View File

@ -21,7 +21,6 @@
import logging
from math import ceil
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
from odoo.exceptions import UserError
_LOGGER = logging.getLogger(__name__)
@ -51,10 +50,6 @@ class GolemActivityRegistrationInvoicing(models.TransientModel):
ondelete='cascade')
member_id = fields.Many2one('golem.member', 'Member', required=True,
ondelete='cascade')
guardian_ids = fields.Many2many('res.partner', compute='_compute_guardian_ids')
on_the_name_of = fields.Many2one('res.partner', 'On the Name of',
ondelete='cascade')
is_minor = fields.Boolean(related='member_id.is_minor')
line_ids = fields.One2many('golem.activity.registration.invoicing.line',
'invoicing_id', string='Activities')
schedule_id = fields.Many2one('golem.payment.schedule', 'Payment schedule',
@ -70,15 +65,6 @@ class GolemActivityRegistrationInvoicing(models.TransientModel):
ondelete='cascade')
payment_ids = fields.Many2many('account.payment', string='Generated payments')
@api.depends('member_id')
def _compute_guardian_ids(self):
for rec in self:
partner_ids = rec.member_id.legal_guardian_ids.mapped('legal_guardian_id').ids
if hasattr(rec.member_id, 'family_member_ids'):
partner_ids += rec.member_id.family_member_ids.filtered(
lambda r: r.id != self.member_id.partner_id.id).ids
rec.guardian_ids = [(6, 0, partner_ids)]
def _create_invoice_line(self, product, price, invoice):
""" Create invoice line : needs cache record for onchange, then real
writing... """
@ -97,10 +83,7 @@ class GolemActivityRegistrationInvoicing(models.TransientModel):
def _create_invoice(self):
""" Create invoice and lines """
self.ensure_one()
if self[0].is_minor:
partner = self[0].on_the_name_of
else:
partner = self[0].member_id.partner_id
partner = self[0].member_id.partner_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
@ -114,10 +97,6 @@ class GolemActivityRegistrationInvoicing(models.TransientModel):
'account_id': partner.property_account_receivable_id.id,
'fiscal_position_id': partner.property_account_position_id.id
})
if self[0].is_minor:
invoice.write({'is_minor_invoice': True,
'partner_ids': [(6, 0, [self[0].on_the_name_of.id,
self[0].member_id.partner_id.id])]})
for line in self.line_ids:
product = line.activity_id.product_id.product_variant_id
invoice_line = self._create_invoice_line(product, line.price, invoice)
@ -156,10 +135,6 @@ class GolemActivityRegistrationInvoicing(models.TransientModel):
def validate(self):
""" Validate and create invoice and payments """
self.ensure_one()
if self.is_minor and not self.on_the_name_of:
err = _('This member is a minor, please fill on the name of so you '
'invoice this registration')
raise ValidationError(err)
self[0].line_ids.mapped('registration_id').write({'state': 'confirmed'})
invoice = self._create_invoice()
self.invoice_id = invoice

View File

@ -2,6 +2,7 @@
<!--
Copyright 2017-2018 Fabien Bourgeois <fabien@yaltik.com>
Copyright 2018 Youssef El Ouahby <youssef@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
@ -33,13 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<group states="init">
<group name="lines" colspan="2">
<field name="season_id" readonly="1" />
<field name="member_id" readonly="0" />
<field name="on_the_name_of"
attrs="{'invisible': [('is_minor', '=', False)], 'required': [('is_minor', '=', True)]}"
options="{'no_create': True}"
domain="[('id', 'in', guardian_ids[0][2])]" />
<field name="is_minor" invisible="1" />
<field name="guardian_ids" invisible="1" widget="many2many_tags" />
<field name="member_id" readonly="1" />
<field name="line_ids" string="Activities and Prices">
<tree delete="false" create="false" edit="true" editable="bottom">
<field name="activity_id" readonly="1" />

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 wizard

View File

@ -0,0 +1,29 @@
# -*- 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/>.
{
'name': 'GOLEM Activity Payment for Minors inside families',
'summary': 'GOLEM Activity Registration Payment for Minors inside families',
'version': '10.0.0.1.0',
'category': 'GOLEM',
'author': 'Fabien Bourgeois',
'license': 'AGPL-3',
'application': False,
'installable': True,
'auto_install': True,
'depends': ['golem_family', 'golem_activity_registration_payment_member_minor'],
}

View File

@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * golem_activity_registration_payment_family_minor
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-11-01 17:44+0000\n"
"PO-Revision-Date: 2018-11-01 17: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_activity_registration_payment_family_minor
#: model:ir.model,name:golem_activity_registration_payment_family_minor.model_golem_activity_registration_invoicing
msgid "GOLEM Activity Registration Invoicing Wizard"
msgstr "GOLEM Activity Registration Invoicing Wizard"

View File

@ -0,0 +1,22 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * golem_activity_registration_payment_family_minor
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-11-01 17:44+0000\n"
"PO-Revision-Date: 2018-11-01 17: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_activity_registration_payment_family_minor
#: model:ir.model,name:golem_activity_registration_payment_family_minor.model_golem_activity_registration_invoicing
msgid "GOLEM Activity Registration Invoicing Wizard"
msgstr ""

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_activity_registration_invoicing

View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
# Copyright 2017-2018 Fabien Bourgeois <fabien@yaltik.com>
# Copyright 2018 Youssef El Ouahby <youssef@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/>.
""" GOLEM Activity Registration Invoicing Wizard """
from odoo import models, api
class GolemActivityRegistrationInvoicing(models.TransientModel):
""" GOLEM Activity Registration Invoicing Wizard """
_inherit = 'golem.activity.registration.invoicing'
@api.depends('member_id')
def _compute_guardian_ids(self):
res = super(GolemActivityRegistrationInvoicing, self)._compute_guardian_ids()
for rec in self:
if rec.member_id.family_member_ids:
rec.guardian_ids += rec.member_id.family_member_ids.filtered(
lambda r: r.id != self.member_id.partner_id.id
)
return res

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 wizard

View File

@ -0,0 +1,30 @@
# -*- 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/>.
{
'name': 'GOLEM Activity Payment for Minors',
'summary': 'GOLEM Activity Registration Payment for Minors',
'version': '10.0.0.1.0',
'category': 'GOLEM',
'author': 'Fabien Bourgeois',
'license': 'AGPL-3',
'application': False,
'installable': True,
'auto_install': True,
'depends': ['golem_member_minor', 'golem_activity_registration_payment'],
'data': ['views/golem_activity_registration_invoicing.xml']
}

View File

@ -0,0 +1,43 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * golem_activity_registration_payment_member_minor
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-11-01 17:44+0000\n"
"PO-Revision-Date: 2018-11-01 17: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_activity_registration_payment_member_minor
#: model:ir.model,name:golem_activity_registration_payment_member_minor.model_golem_activity_registration_invoicing
msgid "GOLEM Activity Registration Invoicing Wizard"
msgstr "GOLEM Activity Registration Invoicing Wizard"
#. module: golem_activity_registration_payment_member_minor
#: model:ir.model.fields,field_description:golem_activity_registration_payment_member_minor.field_golem_activity_registration_invoicing_guardian_ids
msgid "Guardian ids"
msgstr "Guardian ids"
#. module: golem_activity_registration_payment_member_minor
#: model:ir.model.fields,field_description:golem_activity_registration_payment_member_minor.field_golem_activity_registration_invoicing_is_minor
msgid "Is minor?"
msgstr "Est mineur?"
#. module: golem_activity_registration_payment_member_minor
#: model:ir.model.fields,field_description:golem_activity_registration_payment_member_minor.field_golem_activity_registration_invoicing_on_the_name_of
msgid "On the Name of"
msgstr "On the Name of"
#. module: golem_activity_registration_payment_member_minor
#: code:addons/golem_activity_registration_payment_member_minor/wizard/golem_activity_registration_invoicing.py:58
#, python-format
msgid "This member is a minor, please fill on the name of so you invoice this registration"
msgstr "This member is a minor, please fill on the name of so you invoice this registration"

View File

@ -0,0 +1,43 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * golem_activity_registration_payment_member_minor
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-11-01 17:44+0000\n"
"PO-Revision-Date: 2018-11-01 17: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_activity_registration_payment_member_minor
#: model:ir.model,name:golem_activity_registration_payment_member_minor.model_golem_activity_registration_invoicing
msgid "GOLEM Activity Registration Invoicing Wizard"
msgstr ""
#. module: golem_activity_registration_payment_member_minor
#: model:ir.model.fields,field_description:golem_activity_registration_payment_member_minor.field_golem_activity_registration_invoicing_guardian_ids
msgid "Guardian ids"
msgstr ""
#. module: golem_activity_registration_payment_member_minor
#: model:ir.model.fields,field_description:golem_activity_registration_payment_member_minor.field_golem_activity_registration_invoicing_is_minor
msgid "Is minor?"
msgstr ""
#. module: golem_activity_registration_payment_member_minor
#: model:ir.model.fields,field_description:golem_activity_registration_payment_member_minor.field_golem_activity_registration_invoicing_on_the_name_of
msgid "On the Name of"
msgstr ""
#. module: golem_activity_registration_payment_member_minor
#: code:addons/golem_activity_registration_payment_member_minor/wizard/golem_activity_registration_invoicing.py:58
#, python-format
msgid "This member is a minor, please fill on the name of so you invoice this registration"
msgstr ""

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="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/>.
-->
<odoo>
<data>
<!-- Form -->
<record id="golem_activity_registration_invoicing_view_form_inherit_member_minor"
model="ir.ui.view">
<field name="name">GOLEM Activity Registration Invoicing Form</field>
<field name="model">golem.activity.registration.invoicing</field>
<field name="inherit_id"
ref="golem_activity_registration_payment.golem_activity_registration_invoicing_view_form" />
<field name="arch" type="xml">
<field name="member_id" position="after">
<field name="on_the_name_of"
attrs="{'invisible': [('is_minor', '=', False)], 'required': [('is_minor', '=', True)]}"
options="{'no_create': True}"
domain="[('id', 'in', guardian_ids[0][2])]" />
<field name="is_minor" invisible="1" />
<field name="guardian_ids" invisible="1" widget="many2many_tags" />
</field>
</field>
</record>
</data>
</odoo>

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_activity_registration_invoicing

View File

@ -0,0 +1,62 @@
# -*- coding: utf-8 -*-
# Copyright 2017-2018 Fabien Bourgeois <fabien@yaltik.com>
# Copyright 2018 Youssef El Ouahby <youssef@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/>.
""" GOLEM Activity Registration Invoicing Wizard """
from odoo import models, fields, api, _
from odoo.exceptions import ValidationError
class GolemActivityRegistrationInvoicing(models.TransientModel):
""" GOLEM Activity Registration Invoicing Wizard """
_inherit = 'golem.activity.registration.invoicing'
guardian_ids = fields.Many2many('res.partner', compute='_compute_guardian_ids')
on_the_name_of = fields.Many2one('res.partner', 'On the Name of',
ondelete='cascade')
is_minor = fields.Boolean(related='member_id.is_minor')
@api.depends('member_id')
def _compute_guardian_ids(self):
for rec in self:
guardian_ids = rec.member_id.legal_guardian_ids.mapped('legal_guardian_id').ids
rec.guardian_ids = [(6, 0, guardian_ids)]
@api.multi
def _create_invoice(self):
""" Create invoice and lines """
self.ensure_one()
invoice = super(GolemActivityRegistrationInvoicing, self)._create_invoice()
if self[0].is_minor:
invoice.write({'': self[0].on_the_name_of.id,
'is_minor_invoice': True,
'partner_ids': [(6, 0, [self[0].on_the_name_of.id,
self[0].member_id.partner_id.id])]})
return invoice
@api.multi
def validate(self):
""" Validate and create invoice and payments """
self.ensure_one()
action = super(GolemActivityRegistrationInvoicing, self).validate()
if self.is_minor and not self.on_the_name_of:
err = _('This member is a minor, please fill on the name of so you '
'invoice this registration')
raise ValidationError(err)
return action