fix: adjust payment validation to support payments with amount_substract by relaxing line count checks for liquidity and counterpart lines.
This commit is contained in:
parent
fbb48b893c
commit
38b3f179a1
Binary file not shown.
Binary file not shown.
@ -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(_(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user