diff --git a/addons/account/i18n/account.pot b/addons/account/i18n/account.pot index 8af8a88254a..0bc13348c7e 100644 --- a/addons/account/i18n/account.pot +++ b/addons/account/i18n/account.pot @@ -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 diff --git a/addons/account/models/account_payment.py b/addons/account/models/account_payment.py index fb2e7d59f30..3b0e8800d6c 100644 --- a/addons/account/models/account_payment.py +++ b/addons/account/models/account_payment.py @@ -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