[FIX] account: negative invoices in batch payments

Avoid the user to use batch payment with negative invoices (credit notes
or refund) and positive invoices (customer invoices and vendor bills).
This will create two different payment, one for the negative invoices
and one for the positive invoices, it will not partially reconcile them
before register the payment.

The normal behaviour is to add the negative invoice (outstanding debits
of the supplier or the customer credit notes) to the positive invoice
(vendor bill or the customer invoice), and after register the payment of
the balance.

opw-1959687

closes odoo/odoo#32250

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
Jorge Pinna Puissant
2019-04-10 12:21:42 +00:00
parent 49eb24a467
commit b2d2668f85
2 changed files with 22 additions and 0 deletions
+12
View File
@@ -10907,6 +10907,18 @@ msgstr ""
msgid "You cannot put/take money in/out for a bank statement which is closed."
msgstr ""
#. module: account
#: code:addons/account/models/account_payment.py:99
#, python-format
msgid "You cannot register payments for customer invoices and credit notes at the same time."
msgstr ""
#. module: account
#: code:addons/account/models/account_payment.py:96
#, python-format
msgid "You cannot register payments for vendor bills and supplier refunds at the same time."
msgstr ""
#. module: account
#: code:addons/account/models/account.py:644
#, python-format
+10
View File
@@ -87,6 +87,16 @@ class account_abstract_payment(models.AbstractModel):
# Check all invoices have the same currency
if any(inv.currency_id != invoices[0].currency_id for inv in invoices):
raise UserError(_("In order to pay multiple invoices at once, they must use the same currency."))
# Check if, in batch payments, there are not negative invoices and positive invoices
dtype = invoices[0].type
for inv in invoices[1:]:
if inv.type != dtype:
if ((dtype == 'in_refund' and inv.type == 'in_invoice') or
(dtype == 'in_invoice' and inv.type == 'in_refund')):
raise UserError(_("You cannot register payments for vendor bills and supplier refunds at the same time."))
if ((dtype == 'out_refund' and inv.type == 'out_invoice') or
(dtype == 'out_invoice' and inv.type == 'out_refund')):
raise UserError(_("You cannot register payments for customer invoices and credit notes at the same time."))
# Look if we are mixin multiple commercial_partner or customer invoices with vendor bills
multi = any(inv.commercial_partner_id != invoices[0].commercial_partner_id