diff --git a/models/__pycache__/account_payment.cpython-310.pyc b/models/__pycache__/account_payment.cpython-310.pyc index 2836bab..44437af 100644 Binary files a/models/__pycache__/account_payment.cpython-310.pyc and b/models/__pycache__/account_payment.cpython-310.pyc differ diff --git a/models/__pycache__/account_payment.cpython-312.pyc b/models/__pycache__/account_payment.cpython-312.pyc index 1ba693a..3560ac7 100644 Binary files a/models/__pycache__/account_payment.cpython-312.pyc and b/models/__pycache__/account_payment.cpython-312.pyc differ diff --git a/models/account_payment.py b/models/account_payment.py index bef1a2b..aed736c 100644 --- a/models/account_payment.py +++ b/models/account_payment.py @@ -125,20 +125,27 @@ class AccountPayment(models.Model): all_lines = move.line_ids liquidity_lines, counterpart_lines, writeoff_lines = pay._seek_for_lines() - if len(liquidity_lines) != 1: - raise UserError(_( - "Journal Entry %s is not valid. In order to proceed, the journal items must " - "include one and only one outstanding payments/receipts account.", - move.display_name, - )) + # Skip validation if payment has amount_substract (from vendor_payment_diff_amount module) + # This module creates additional lines that don't fit the standard pattern + has_substract = hasattr(pay, 'amount_substract') and pay.amount_substract and pay.amount_substract > 0 + + if not has_substract: + if len(liquidity_lines) != 1: + raise UserError(_( + "Journal Entry %s is not valid. In order to proceed, the journal items must " + "include one and only one outstanding payments/receipts account.", + move.display_name, + )) - if len(counterpart_lines) != 1: - raise UserError(_( - "Journal Entry %s is not valid. In order to proceed, the journal items must " - "include one and only one receivable/payable account (with an exception of " - "internal transfers).", - move.display_name, - )) + # Allow for additional lines (like substract account from vendor_payment_diff_amount) + # Check if we have at least one counterpart line, not exactly one + if len(counterpart_lines) < 1: + raise UserError(_( + "Journal Entry %s is not valid. In order to proceed, the journal items must " + "include at least one receivable/payable account (with an exception of " + "internal transfers).", + move.display_name, + )) if any(line.currency_id != all_lines[0].currency_id for line in all_lines): raise UserError(_(