[17.0][IMP] stock_picking_report_valued: add sale.order.line values on sol_vals if sale_line._cache is empty. - #522
Open
ajfebres wants to merge 1 commit into
Conversation
…vals if sale_line._cache is empty.
Author
|
@rrebollo PING! |
|
please prefix the PR title with base branch: "[17.0] ..." |
|
The PR description if fine. Can you attach a traceback of the issue? Also, would you be open to adding a test that exposes the issue, so we can avoid regressions in the future? |
rrebollo
reviewed
Jun 30, 2026
rrebollo
left a comment
There was a problem hiding this comment.
Thanks for your contribution. Please consider my suggestions.
| ) | ||
| sol_vals.pop("price_subtotal", None) | ||
| valued_line = line.sale_line.new(sol_vals) | ||
| valued_line._compute_amount() |
There was a problem hiding this comment.
Suggested change
| valued_line._compute_amount() |
Are you sure this is really needed? From the description, the motivation seemed to be about safeguarding. An explicit call to something that should be ORM‑triggered feels a bit forced, and it also doesn't look very performance‑friendly.
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.
@BinhexTeam
This change fixes an issue in stock_picking_report_valued when rendering a valued picking report during email sending.
In this flow, sale_line._cache may be incomplete, so _convert_to_write(sale_line._cache) can return sol_vals without the minimum required sale.order.line fields (for example: product_id, order_id, discount, price_unit).
When that happens, creating the virtual line and triggering amount/tax computation can fail in order_line._compute_all().
What was changed
A fallback was added to complete sol_vals whenever key fields are missing:
product_id
order_id
discount
price_unit
Additionally, after creating the virtual line with new(sol_vals), _compute_amount() is explicitly called to ensure amounts and taxes are properly recomputed with complete values.
Expected result
Sending the email no longer breaks valued picking computation when sale.order.line cache is incomplete.
The valued report keeps consistent subtotal and tax values.