[MIG] account_payment_partner

This commit is contained in:
etobella
2017-10-17 16:05:26 +02:00
committed by Thomas Binsfeld
parent 3956808a68
commit 4fcedc53bc
9 changed files with 54 additions and 41 deletions

View File

@@ -38,7 +38,7 @@ Invoices without any payment mode are displayed to.
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/173/10.0
:target: https://runbot.odoo-community.org/runbot/173/11.0
Known issues / Roadmap
======================
@@ -71,12 +71,12 @@ Contributors
Maintainer
----------
.. image:: http://odoo-community.org/logo.png
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: http://odoo-community.org
:target: https://odoo-community.org
This module is maintained by the OCA.
OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.
To contribute to this module, please visit https://odoo-community.org.

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# © 2014 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from . import models

View File

@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
# © 2014 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
# © 2014 Tecnativa - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
{
'name': 'Account Payment Partner',
'version': '10.0.1.1.0',
'version': '11.0.1.0.0',
'category': 'Banking addons',
'license': 'AGPL-3',
'summary': 'Adds payment mode on partners and invoices',

View File

@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# © 2014-2016 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api
@@ -22,20 +22,25 @@ class AccountInvoice(models.Model):
res = super(AccountInvoice, self)._onchange_partner_id()
if self.partner_id:
if self.type == 'in_invoice':
pay_mode = self.partner_id.supplier_payment_mode_id
pay_mode = self.with_context(
company_id=self.company_id.id
).partner_id.supplier_payment_mode_id
self.payment_mode_id = pay_mode
if (
pay_mode and
pay_mode.payment_type == 'outbound' and
pay_mode.payment_method_id.bank_account_required and
self.commercial_partner_id.bank_ids):
self.partner_bank_id =\
pay_mode and
pay_mode.payment_type == 'outbound' and
pay_mode.payment_method_id.bank_account_required and
self.commercial_partner_id.bank_ids
):
self.partner_bank_id = \
self.commercial_partner_id.bank_ids[0]
elif self.type == 'out_invoice':
pay_mode = self.partner_id.customer_payment_mode_id
pay_mode = self.with_context(
company_id=self.company_id.id
).partner_id.customer_payment_mode_id
self.payment_mode_id = pay_mode
if pay_mode and pay_mode.bank_account_link == 'fixed':
self.partner_bank_id = pay_mode.fixed_journal_id.\
self.partner_bank_id = pay_mode.fixed_journal_id. \
bank_account_id
else:
self.payment_mode_id = False
@@ -43,6 +48,18 @@ class AccountInvoice(models.Model):
self.partner_bank_id = False
return res
@api.onchange('payment_mode_id')
def _onchange_payment_mode_id(self):
pay_mode = self.payment_mode_id
if (
pay_mode and
pay_mode.payment_type == 'outbound' and not
pay_mode.payment_method_id.bank_account_required
):
self.partner_bank_id = False
elif not self.payment_mode_id:
self.partner_bank_id = False
@api.model
def create(self, vals):
"""Fill the payment_mode_id from the partner if none is provided on
@@ -61,17 +78,6 @@ class AccountInvoice(models.Model):
)
return super(AccountInvoice, self).create(vals)
@api.onchange('payment_mode_id')
def payment_mode_id_change(self):
if (
self.payment_mode_id and
self.payment_mode_id.payment_type == 'outbound' and
not self.payment_mode_id.payment_method_id.
bank_account_required):
self.partner_bank_id = False
elif not self.payment_mode_id:
self.partner_bank_id = False
@api.model
def line_get_convert(self, line, part):
"""Copy payment mode from invoice to account move line"""

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# © 2016 Akretion (http://www.akretion.com/)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# © 2016 Akretion (https://www.akretion.com/)
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models, fields
@@ -9,4 +9,8 @@ class AccountMoveLine(models.Model):
_inherit = 'account.move.line'
payment_mode_id = fields.Many2one(
'account.payment.mode', string='Payment Mode', ondelete='restrict')
'account.payment.mode',
string='Payment Mode',
domain="[('company_id', '=', company_id)]",
ondelete='restrict'
)

View File

@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# © 2014 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
from odoo import models, fields, api
@@ -13,12 +13,14 @@ class ResPartner(models.Model):
supplier_payment_mode_id = fields.Many2one(
'account.payment.mode', string='Supplier Payment Mode',
company_dependent=True,
domain=[('payment_type', '=', 'outbound')],
domain="[('payment_type', '=', 'outbound'), "
"('company_id', '=', company_id)]",
help="Select the default payment mode for this supplier.")
customer_payment_mode_id = fields.Many2one(
'account.payment.mode', string='Customer Payment Mode',
company_dependent=True,
domain=[('payment_type', '=', 'inbound')],
domain="[('payment_type', '=', 'inbound'), "
"('company_id', '=', company_id)]",
help="Select the default payment mode for this customer.")
@api.model

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2014-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>
@@ -26,7 +26,7 @@
<field name="arch" type="xml">
<field name="payment_term_id" position="after">
<field name="payment_mode_id"
domain="[('payment_type', '=', 'inbound')]"
domain="[('payment_type', '=', 'inbound'), ('company_id', '=', company_id)]"
widget="selection"/>
<field name="commercial_partner_id" invisible="1"/>
</field>
@@ -44,13 +44,14 @@
<field name="arch" type="xml">
<field name="payment_term_id" position="after">
<field name="payment_mode_id"
domain="[('payment_type', '=', 'outbound')]"
domain="[('payment_type', '=', 'outbound'), ('company_id', '=', company_id)]"
widget="selection"/>
<field name="commercial_partner_id" invisible="1"/>
<field name="bank_account_required" invisible="1"/>
</field>
<field name="partner_bank_id" position="attributes">
<attribute name="domain">[('partner_id', '=', commercial_partner_id)]</attribute>
<attribute name="domain">[('partner_id', '=', commercial_partner_id),
'|',('company_id', '=', company_id),('company_id', '=', False)]</attribute>
<attribute name="invisible">0</attribute>
<attribute name="attrs">{'invisible': [('bank_account_required', '=', False)], 'required': [('bank_account_required', '=', True)]}</attribute>
</field>

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2016 Akretion (http://www.akretion.com/)
© 2016 Akretion (https://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
© 2014-2016 Akretion (http://www.akretion.com/)
© 2014-2016 Akretion (https://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
-->
<odoo>