mirror of
https://github.com/OCA/bank-payment.git
synced 2025-02-02 10:37:31 +02:00
[IMP] account_payment_partner: Several things:
* Change copyright and author after company merging * Fill payment mode in invoices if none is provided Using same method as in upstream, payment mode is filled on invoice creation if no payment method is provided. This way, we don't need to install account_payment_sale if we don't want to handle several payment modes at sales level. Even more, if we install the module later and we have already existing sales orders without payment mode filled, those orders will be invoiced with the customer payment mode. * Signature changed in convert_to_write
This commit is contained in:
committed by
Thomas Binsfeld
parent
9a0f233051
commit
a6f035cfa8
@@ -1,11 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# © 2014 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# © 2014 Serv. Tecnol. Avanzados - Pedro M. Baeza
|
||||
# © 2014 Tecnativa - Pedro M. Baeza
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
||||
|
||||
{
|
||||
'name': 'Account Payment Partner',
|
||||
'version': '10.0.1.0.0',
|
||||
'version': '10.0.1.1.0',
|
||||
'category': 'Banking addons',
|
||||
'license': 'AGPL-3',
|
||||
'summary': 'Adds payment mode on partners and invoices',
|
||||
|
||||
@@ -19,7 +19,7 @@ class AccountInvoice(models.Model):
|
||||
|
||||
@api.onchange('partner_id', 'company_id')
|
||||
def _onchange_partner_id(self):
|
||||
super(AccountInvoice, self)._onchange_partner_id()
|
||||
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
|
||||
@@ -41,6 +41,25 @@ class AccountInvoice(models.Model):
|
||||
self.payment_mode_id = False
|
||||
if self.type == 'in_invoice':
|
||||
self.partner_bank_id = False
|
||||
return res
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
"""Fill the payment_mode_id from the partner if none is provided on
|
||||
creation, using same method as upstream."""
|
||||
onchanges = {
|
||||
'_onchange_partner_id': ['payment_mode_id'],
|
||||
}
|
||||
for onchange_method, changed_fields in onchanges.items():
|
||||
if any(f not in vals for f in changed_fields):
|
||||
invoice = self.new(vals)
|
||||
getattr(invoice, onchange_method)()
|
||||
for field in changed_fields:
|
||||
if field not in vals and invoice[field]:
|
||||
vals[field] = invoice._fields[field].convert_to_write(
|
||||
invoice[field], invoice,
|
||||
)
|
||||
return super(AccountInvoice, self).create(vals)
|
||||
|
||||
@api.onchange('payment_mode_id')
|
||||
def payment_mode_id_change(self):
|
||||
|
||||
Reference in New Issue
Block a user