Skip to content

Commit

Permalink
[FIX] account_invoice_refund_link: Exclude section/notes origin lines
Browse files Browse the repository at this point in the history
On the side by side comparison, exclude the lines that are not products, as that's what we do on the refund lines.
  • Loading branch information
Pedro Castro Silva authored and pedrocs-exo committed Mar 1, 2023
1 parent 912028e commit fcb2379
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
6 changes: 5 additions & 1 deletion account_invoice_refund_link/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def _reverse_moves(self, default_values_list=None, cancel=False):
refund_lines = move.line_ids.filtered(
lambda x: x.display_type == "product"
)
for i, line in enumerate(self.invoice_line_ids):
for i, line in enumerate(
self.invoice_line_ids.filtered(
lambda x: x.display_type == "product"
)
):
if i < len(refund_lines):
refund_lines[i].origin_line_id = line.id
return reverse_moves
17 changes: 13 additions & 4 deletions account_invoice_refund_link/tests/test_invoice_refund_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ def setUpClass(cls):
}
)
cls.invoice_lines = [
(
0,
False,
{
"name": "Test section",
"display_type": "line_section",
},
),
(
0,
False,
Expand Down Expand Up @@ -79,14 +87,15 @@ def _test_refund_link(self):
self.assertEqual(refund.ref, ref)
self.assertEqual(len(self.invoice.invoice_line_ids), len(self.invoice_lines))
self.assertEqual(len(refund.invoice_line_ids), len(self.invoice_lines))
self.assertTrue(refund.invoice_line_ids[0].origin_line_id)
self.assertEqual(
self.invoice.invoice_line_ids[0], refund.invoice_line_ids[0].origin_line_id
)
# We're checking only the 2nd and 3rd lines because the first is a line section
self.assertTrue(refund.invoice_line_ids[1].origin_line_id)
self.assertEqual(
self.invoice.invoice_line_ids[1], refund.invoice_line_ids[1].origin_line_id
)
self.assertTrue(refund.invoice_line_ids[2].origin_line_id)
self.assertEqual(
self.invoice.invoice_line_ids[2], refund.invoice_line_ids[2].origin_line_id
)


class TestInvoiceRefundLink(TestInvoiceRefundLinkBase):
Expand Down

0 comments on commit fcb2379

Please sign in to comment.