Skip to content

[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
OCA:17.0from
BinhexTeam:17.0-imp-stock_picking_report_valued_from_email
Open

[17.0][IMP] stock_picking_report_valued: add sale.order.line values on sol_vals if sale_line._cache is empty.#522
ajfebres wants to merge 1 commit into
OCA:17.0from
BinhexTeam:17.0-imp-stock_picking_report_valued_from_email

Conversation

@ajfebres

Copy link
Copy Markdown

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

@OCA-git-bot OCA-git-bot added series:17.0 mod:stock_picking_report_valued Module stock_picking_report_valued labels Jun 26, 2026
@ajfebres

Copy link
Copy Markdown
Author

@rrebollo PING!

@rrebollo

Copy link
Copy Markdown

please prefix the PR title with base branch: "[17.0] ..."

@rrebollo

Copy link
Copy Markdown

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

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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@ajfebres ajfebres changed the title [IMP] stock_picking_report_valued: add sale.order.line values on sol_vals if sale_line._cache is empty. [17.0][IMP] stock_picking_report_valued: add sale.order.line values on sol_vals if sale_line._cache is empty. Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:stock_picking_report_valued Module stock_picking_report_valued series:17.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants