Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] account_payment_order: Check correctly for duplicated lines on … #3

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions account_payment_order/models/account_payment_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,19 @@ def check_date_scheduled(self):
@api.constrains("payment_line_ids")
def _check_payment_lines(self):
for order in self:
if len(order.payment_line_ids.move_line_id) != len(order.payment_line_ids):
raise ValidationError(_("Duplicated lines found."))
found_lines = self.env["account.move.line"]
for pay_line in order.payment_line_ids:
move_line = pay_line.move_line_id
if move_line in found_lines:
raise ValidationError(
_(
"Duplicated lines found in order '%(order)s'. At least two "
"lines belong to the move line '%(move_line)s'.",
order=order.display_name,
move_line=move_line.display_name,
)
)
found_lines += move_line

@api.depends("payment_line_ids", "payment_line_ids.amount_company_currency")
def _compute_total(self):
Expand Down
Loading