From 470981822220b9d212a73c92e4b49f424c8fde9c Mon Sep 17 00:00:00 2001 From: Goffin Simon Date: Fri, 30 Oct 2015 10:10:21 +0100 Subject: [PATCH] [FIX] account: Register payment with several bills When a payment is created for a bill, this is always the 'commercial_partner_id' which is used as 'partner_id'. Then: -When registering a payment with several bills, the 'commercial_partner_id' field of these bills must be the same. -When grouping bills by partner, the groups must contain all the bills from the same 'commercial_partner_id'. opw:653005 --- addons/account/models/account_payment.py | 6 +++--- addons/account/views/account_invoice_view.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index 183b16fc676..7e8b51ce2f9 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -120,8 +120,8 @@ class account_register_payments(models.TransientModel): invoices = self.env[active_model].browse(active_ids) if any(invoice.state != 'open' for invoice in invoices): raise UserError(_("You can only register payments for open invoices")) - if any(inv.partner_id != invoices[0].partner_id for inv in invoices): - raise UserError(_("In order to pay multiple invoices at once, they must belong to the same partner.")) + if any(inv.commercial_partner_id != invoices[0].commercial_partner_id for inv in invoices): + raise UserError(_("In order to pay multiple invoices at once, they must belong to the same commercial partner.")) if any(MAP_INVOICE_TYPE_PARTNER_TYPE[inv.type] != MAP_INVOICE_TYPE_PARTNER_TYPE[invoices[0].type] for inv in invoices): raise UserError(_("You cannot mix customer invoices and vendor bills in a single payment.")) if any(inv.currency_id != invoices[0].currency_id for inv in invoices): @@ -132,7 +132,7 @@ class account_register_payments(models.TransientModel): 'amount': abs(total_amount), 'currency_id': invoices[0].currency_id.id, 'payment_type': total_amount > 0 and 'inbound' or 'outbound', - 'partner_id': invoices[0].partner_id.id, + 'partner_id': invoices[0].commercial_partner_id.id, 'partner_type': MAP_INVOICE_TYPE_PARTNER_TYPE[invoices[0].type], }) return rec diff --git a/addons/account/views/account_invoice_view.xml b/addons/account/views/account_invoice_view.xml index 3cb5c0ef0e8..deb16e0e958 100644 --- a/addons/account/views/account_invoice_view.xml +++ b/addons/account/views/account_invoice_view.xml @@ -516,7 +516,7 @@ - +