Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions account_payment_return/models/payment_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,7 @@ def match_invoice(self):
invoice = self.env["account.move"].search(domain)
if invoice:
invoice_line_ids = invoice.line_ids.filtered(
lambda line: line.account_id.user_type_id.type
in ("receivable", "payable")
lambda line: line.account_internal_type == "receivable"
)
payment_lines = invoice_line_ids.mapped(
"matched_debit_ids.debit_move_id"
Expand All @@ -375,7 +374,8 @@ def match_invoice(self):
"matched_credit_ids.credit_move_id"
)
if payment_lines:
line.move_line_ids = payment_lines[0].ids
# Get last payment if several payments
line.move_line_ids = payment_lines[-1].ids
if not line.concept:
line.concept = _("Invoice: %s") % invoice.name

Expand All @@ -384,12 +384,12 @@ def match_move_lines(self):
domain = line.partner_id and [("partner_id", "=", line.partner_id.id)] or []
if line.return_id.journal_id:
domain += [
("journal_id", "=", line.return_id.journal_id.id),
("credit", ">", 0.0),
("move_id.type", "=", "entry"),
]
domain.extend(
[
("account_id.internal_type", "=", "receivable"),
("account_internal_type", "=", "receivable"),
("reconciled", "=", True),
"|",
("name", "=", line.reference),
Expand Down
10 changes: 6 additions & 4 deletions account_payment_return/views/payment_return_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@
name="move_line_ids"
widget="many2many_tags"
options="{'no_create': True}"
domain="[('partner_id', '=', partner_id),
('journal_id', '=', parent.journal_id),
('account_id.internal_type', '=', 'receivable'),
('reconciled', '=', True)]"
domain="[
('partner_id', '=', partner_id),
('credit', '>', 0.0),
('account_internal_type', '=', 'receivable'),
('reconciled', '=', True)
]"
/>
<field name="amount" sum="Total amount" />
<field
Expand Down