Skip to content

[19.0][IMP] website_sale_stock_provisioning_date: reuse computed free quantity- #1364 - #1365

Merged
OCA-git-bot merged 2 commits into
OCA:19.0from
Tecnativa:19.0-imp-website_sale_stock_provisioning_date
Oct 20, 2026
Merged

OCA-git-bot merged 2 commits into
OCA:19.0from
Tecnativa:19.0-imp-website_sale_stock_provisioning_date

Conversation

@pilarvargas-tecnativa

Copy link
Copy Markdown
Contributor

fwp #1345

The combination info already contains the available quantity computed by website_sale_stock, but website_sale_stock_provisioning_date calculates it again.

For products with many variants displayed in a matrix, this redundant computation is repeated for every combination, increasing the number of queries and the page loading time.

This PR introduces two changes:

website_sale_stock_provisioning_date: Reuses the already computed free_qty instead of calculating it again, explicitly disabling the website_sale_stock_available context when retrieving combination info.

website_sale_stock_available: Respects an explicitly defined context value instead of always forcing it to True, while preserving its default behavior.

Both changes are needed to reuse the standard free quantity without altering the provisioning date calculation when website_sale_stock_available is installed.

@Tecnativa TT64745

@pedrobaeza @carlos-lopez-tecnativa please review

@OCA-git-bot OCA-git-bot added series:19.0 mod:website_sale_stock_available Module website_sale_stock_available mod:website_sale_stock_provisioning_date Module website_sale_stock_provisioning_date labels Oct 16, 2026

@carlos-lopez-tecnativa carlos-lopez-tecnativa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please check the CI. I think it could be related to this change in v19: now, if the context doesn't have the key, it only returns the super value and doesn't set free_qty.
https://github.com/odoo/odoo/blob/621f27d320588c575bc71bbccc72d82c7719ac46/addons/website_sale_stock/models/product_template.py#L44
I got the error when I tried to go to the shop:
Image

The combination info already contains the available quantity computed by
`website_sale_stock`, but the provisioning date computation calculates it
again.

For products with many variants displayed in a matrix, this redundant stock
computation is repeated for every combination, increasing the number of
queries and the page loading time.

Explicitly disable the `website_sale_stock_available` context when retrieving
combination info to preserve the standard free quantity, and reuse the
computed `free_qty` instead.

TT64745
@pilarvargas-tecnativa
pilarvargas-tecnativa force-pushed the 19.0-imp-website_sale_stock_provisioning_date branch from 898a077 to 1b745f3 Compare October 19, 2026 11:40
Enable website_sale_stock_available by default only when the context key
is not already defined.

This allows other modules to explicitly disable the context flag when
they need the standard free quantity, without changing the default behavior.

TT64745
@pilarvargas-tecnativa
pilarvargas-tecnativa force-pushed the 19.0-imp-website_sale_stock_provisioning_date branch from 1b745f3 to de69ccb Compare October 19, 2026 11:52
@pedrobaeza pedrobaeza added this to the 19.0 milestone Oct 20, 2026

@pedrobaeza pedrobaeza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

On my way to merge this fine PR!
Prepared branch 19.0-ocabot-merge-pr-1365-by-pedrobaeza-bump-patch, awaiting test results.

@OCA-git-bot
OCA-git-bot merged commit 63b9436 into OCA:19.0 Oct 20, 2026
8 of 9 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 69a2898. Thanks a lot for contributing to OCA. ❤️

@carlos-lopez-tecnativa
carlos-lopez-tecnativa deleted the 19.0-imp-website_sale_stock_provisioning_date branch October 20, 2026 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved merged 🎉 mod:website_sale_stock_available Module website_sale_stock_available mod:website_sale_stock_provisioning_date Module website_sale_stock_provisioning_date series:19.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants