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
|
all_lines = move.line_ids
|
||||||
liquidity_lines, counterpart_lines, writeoff_lines = pay._seek_for_lines()
|
liquidity_lines, counterpart_lines, writeoff_lines = pay._seek_for_lines()
|
||||||
|
|
||||||
if len(liquidity_lines) != 1:
|
# Skip validation if payment has amount_substract (from vendor_payment_diff_amount module)
|
||||||
raise UserError(_(
|
# This module creates additional lines that don't fit the standard pattern
|
||||||
"Journal Entry %s is not valid. In order to proceed, the journal items must "
|
has_substract = hasattr(pay, 'amount_substract') and pay.amount_substract and pay.amount_substract > 0
|
||||||
"include one and only one outstanding payments/receipts account.",
|
|
||||||
move.display_name,
|
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:
|
# Allow for additional lines (like substract account from vendor_payment_diff_amount)
|
||||||
raise UserError(_(
|
# Check if we have at least one counterpart line, not exactly one
|
||||||
"Journal Entry %s is not valid. In order to proceed, the journal items must "
|
if len(counterpart_lines) < 1:
|
||||||
"include one and only one receivable/payable account (with an exception of "
|
raise UserError(_(
|
||||||
"internal transfers).",
|
"Journal Entry %s is not valid. In order to proceed, the journal items must "
|
||||||
move.display_name,
|
"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):
|
if any(line.currency_id != all_lines[0].currency_id for line in all_lines):
|
||||||
raise UserError(_(
|
raise UserError(_(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user