forked from Yaltik/golem
Add partner_ids to account_invoice
This commit is contained in:
parent
841d91bb41
commit
afddb3c58d
@ -27,5 +27,6 @@
|
|||||||
'installable': True,
|
'installable': True,
|
||||||
'depends': ['golem_member'],
|
'depends': ['golem_member'],
|
||||||
'data': ['views/golem_member_views.xml',
|
'data': ['views/golem_member_views.xml',
|
||||||
'views/golem_membership_invoice.xml']
|
'views/golem_membership_invoice.xml',
|
||||||
|
'views/account_invoice.xml']
|
||||||
}
|
}
|
||||||
|
@ -16,4 +16,4 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# 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/>.
|
# 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
|
||||||
|
27
golem_member_minor/models/account_invoice.py
Normal file
27
golem_member_minor/models/account_invoice.py
Normal 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')
|
@ -39,3 +39,18 @@ class GolemMembershipInvoice(models.TransientModel):
|
|||||||
[('id', 'in', record.src_member_id.legal_guardian_ids.ids)]
|
[('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
|
||||||
|
38
golem_member_minor/views/account_invoice.xml
Normal file
38
golem_member_minor/views/account_invoice.xml
Normal 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>
|
Loading…
Reference in New Issue
Block a user