Add partner_ids to account_invoice

This commit is contained in:
Youssef Elouahby 2018-10-08 14:37:14 +01:00
parent 841d91bb41
commit afddb3c58d
5 changed files with 83 additions and 2 deletions

View File

@ -27,5 +27,6 @@
'installable': True,
'depends': ['golem_member'],
'data': ['views/golem_member_views.xml',
'views/golem_membership_invoice.xml']
'views/golem_membership_invoice.xml',
'views/account_invoice.xml']
}

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
from . import golem_member, golem_membership, account_invoice

View File

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Copyright 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/>.
""" Account Invoice adaptations """
from odoo import models, fields, api
class AccountInvoice(models.Model):
""" Account Invoice adaptations """
_inherit = 'account.invoice'
partner_ids = fields.Many2many('res.partner')

View File

@ -39,3 +39,18 @@ class GolemMembershipInvoice(models.TransientModel):
[('id', 'in', record.src_member_id.legal_guardian_ids.ids)]
}
}
@api.multi
def membership_invoice(self):
""" Create invoice and redirect to partner invoice list """
self.ensure_one()
res = super(GolemMembershipInvoice, self).membership_invoice()
if self.src_member_id and self.src_member_id.is_minor:
invoice_id = (res['domain'][0][2] if
res['domain'][0][2] else False)
if invoice_id:
self.env['account.invoice'].browse(invoice_id).partner_ids = [
(6, 0, [self.partner_id.id,
self.src_member_id.partner_id.id])]
self.src_member_id.partner_id.membership_state = self.partner_id.membership_state
self.partner_id.membership_state = 'none'
return res

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 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/>.
-->
<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>
<field name="model">account.invoice</field>
<field name="inherit_id" ref="account.invoice_form" />
<field name="arch" type="xml">
<field name='partner_id' position='after'>
<field name="partner_ids"
widget="many2many_tags"
readonly="1"/>
<!-- attrs="{'invisible': [('src_member_id', '=', False)]}"-->
</field>
</field>
</record>
</data>
</odoo>