Skip to content

[19.0][FIX] subscription_oca: recompute totals on line subtotal change#1474

Open
alvaro-domatix wants to merge 1 commit into
OCA:19.0from
alvaro-domatix:19.0-fix-subscription_oca-recompute-totals
Open

[19.0][FIX] subscription_oca: recompute totals on line subtotal change#1474
alvaro-domatix wants to merge 1 commit into
OCA:19.0from
alvaro-domatix:19.0-fix-subscription_oca-recompute-totals

Conversation

@alvaro-domatix

Copy link
Copy Markdown

Depends on nothing.

_compute_total only declared a dependency on the list of lines (sale_subscription_line_ids), not on the lines' subtotals. Since recurring_total, amount_tax and amount_total are 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_total does 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.

_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.

@stferraro stferraro left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants