[FW][FIX] sale_management: dispense temp cache records #159628
Closed
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.
Current behavior:
If a recurring sale order has an associated sale order option and the recurring plan of the order is changed, a trace back occurs.
Expected behavior:
The recurring plan can be changed as it ordinarily would.
Steps to reproduce:
Add a recurring product to a sale order
Add an optional recurring product to the order
Try to change the recurring plan of the order to encounter the trace back
Cause of the issue:
This flow causes some 'phantom' sale order lines to have their price recalculated (phantom because they have no price, qty, currency, nor order_id field values). During this recalculation a currency_id is expected either in the line itself or in the sale order it is a part of. Because there is no value for either of these, it fails the ensure_one() method in the sequence (0 vals, expects 1).
The phantom lines are created in the
sale.order.option
model in thesale_management
module, in_compute_price_unit()
and_compute_discount()
.Fix:
Call
invalidate_recorset(flush=False)
on these cached records at the end of the methods in which they are created.Test added in https://github.com/odoo/enterprise/pull/58264
opw-3754297
Forward-Port-Of: #158950
Forward-Port-Of: #157515