[19.0][FIX] subscription_oca: recompute totals on line subtotal change#1474
Open
alvaro-domatix wants to merge 1 commit into
Open
[19.0][FIX] subscription_oca: recompute totals on line subtotal change#1474alvaro-domatix wants to merge 1 commit into
alvaro-domatix wants to merge 1 commit into
Conversation
_compute_total only depended on the list of lines (sale_subscription_line_ids), not on the lines' subtotals. As recurring_total/amount_tax/amount_total are stored, any later change to an existing line's price (pricelist change, manual unit price edit, discount update) recomputed the line subtotals but did not trigger the parent totals, leaving them stale. Depend on the aggregated line fields (price_subtotal, amount_tax_line_amount) so the subscription totals are refreshed whenever a line value changes. Covered by a regression test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on nothing.
_compute_totalonly declared a dependency on the list of lines (sale_subscription_line_ids), not on the lines' subtotals. Sincerecurring_total,amount_taxandamount_totalare stored, any change to an existing line's price (pricelist change, manual unit price edit, discount update) recomputed the line subtotals but did not trigger the parent totals, leaving them stale.This is the root cause behind the issue reported in #1452 (change-customer wizard): when a subscription's pricelist is changed, line prices update correctly but
recurring_totaldoes not.The fix declares the dependency on the aggregated line fields (
price_subtotal,amount_tax_line_amount), so the subscription totals are refreshed whenever a line value changes. A regression test (edit the unit price of an existing line and assert the totals are refreshed) is included.