Skip to content
Open
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
1 change: 0 additions & 1 deletion sale_discount_display_amount/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def _update_discount_display_fields(self):
if not line.discount:
line.price_subtotal_no_discount = line.price_subtotal
line.price_total_no_discount = line.price_total
continue
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jay2163 Thanks for this. Could you add a test for that case ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I’ll add a test for this case and update the PR.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The root cause is that discount_subtotal is not initialized to 0 at the top of the loop (lines 36-38 reset the other three fields but omit this one). Removing continue works around the bug but forces every zero-discount line through the full tax_id.compute_all() computation unnecessarily.

Preferred fix: keep continue, add line.discount_subtotal = 0 to the initialization block at line 38:

    line.discount_total = 0
    line.discount_subtotal = 0  # add this line

This directly addresses the missing reset and preserves the early-exit optimization.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review @alexey-pelykh.

I’ll check the suggested changes and update the code accordingly:

Restore the continue

Add line.discount_subtotal = 0 to the initialization block

Add the missing regression test for the apply-then-remove scenario

I’ll push the updated changes shortly.

price = line.price_unit
taxes = line.tax_id.compute_all(
price,
Expand Down