Skip to content
Open
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
8 changes: 4 additions & 4 deletions account_payment_return/models/payment_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,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.account_type
in ("asset_receivable", "liability_payable")
lambda line: line.account_id.account_type == "asset_receivable"
)
payment_lines = invoice_line_ids.mapped(
"matched_debit_ids.debit_move_id"
Expand All @@ -335,7 +334,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 @@ -344,7 +344,7 @@ 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.move_type", "=", "entry"),
]
domain.extend(
Expand Down
16 changes: 5 additions & 11 deletions account_payment_return/tests/test_payment_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,12 @@ def test_find_match_invoice(self):

def test_find_match_move_line(self):
self.payment_line.name = "test match move line 001"
self.payment_return.write(
self.payment_return.line_ids.update(
{
"line_ids": [
Command.create(
{
"partner_id": False,
"move_line_ids": [],
"amount": 0.0,
"reference": self.payment_line.name,
}
)
]
"partner_id": False,
"move_line_ids": [Command.clear()],
"amount": 0.0,
"reference": self.payment_line.name,
}
)
self.payment_return.button_match()
Expand Down
1 change: 1 addition & 0 deletions account_payment_return/views/payment_return_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
options="{'no_create': True}"
domain="[('partner_id', '=', partner_id),
('journal_id', '=', parent.journal_id),
('credit', '>', 0.0),
('account_id.account_type', '=', 'asset_receivable'),
('reconciled', '=', True)]"
/>
Expand Down