[FIX] account: prevent group payment if multiple receivable/payable accounts

When creating a payment, we are expecting only one destination account.
However, when grouping payment by customer, it can happen that there are
more than one receivable or payable accounts, which can create
reconciliation issues afterward.

opw-2188632
opw-2166551

closes odoo/odoo#45396

X-original-commit: 779699297b9767438797ae3678eb9da1db0ce609
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Co-authored-by: Jorge Pinna Puissant <jpp@odoo.com>
This commit is contained in:
alt-odoo
2020-02-14 12:48:20 +00:00
committed by Jorge Pinna Puissant
co-authored by Jorge Pinna Puissant
parent 7a000acffd
commit 86b9106482
2 changed files with 10 additions and 0 deletions
+6
View File
@@ -10986,6 +10986,12 @@ msgid ""
"either post or delete them."
msgstr ""
#. module: account
#: code:addons/account/models/account_payment.py:0
#, python-format
msgid "There is more than one receivable/payable account in the concerned invoices. You cannot group payments in that case."
msgstr ""
#. module: account
#: code:addons/account/models/account_payment.py:0
#, python-format
+4
View File
@@ -744,6 +744,10 @@ class payment_register(models.TransientModel):
raise UserError(_("You can only register at the same time for payment that are all inbound or all outbound"))
if any(inv.company_id != invoices[0].company_id for inv in invoices):
raise UserError(_("You can only register at the same time for payment that are all from the same company"))
# Check the destination account is the same
destination_account = invoices.line_ids.filtered(lambda line: line.account_internal_type in ('receivable', 'payable')).mapped('account_id')
if len(destination_account) > 1:
raise UserError(_('There is more than one receivable/payable account in the concerned invoices. You cannot group payments in that case.'))
if 'invoice_ids' not in rec:
rec['invoice_ids'] = [(6, 0, invoices.ids)]
if 'journal_id' not in rec: