Repository navigation
[19.0][FIX] stock_available: fix the context keys the quantities depend on - #82
CarlosRoca13 wants to merge 1 commit into
Conversation
Since 19.0, `stock` only filters the quantities by the `warehouse_id` context key: `warehouse` isn't read anymore (https://github.com/odoo/odoo/blob/b0907482898d097054a432974a68eb1ecee65326/addons/stock/models/product.py#L370). As it was the key declared in `depends_context`, the ORM cache key of `immediately_usable_qty` didn't take the warehouse into account, so once the field was computed for one warehouse, every other warehouse got that very same value. `allowed_company_ids` was missing as well, although `virtual_available`, which this field is computed from, does depend on it.
IJOL
left a comment
There was a problem hiding this comment.
Independently confirmed, and 18.0 is affected the same way: there too stock reads only the warehouse_id context key (_get_domain_locations, addons/stock/models/product.py, no fallback to warehouse), while _compute_available_quantities still declares warehouse — so immediately_usable_qty is cached once and every other warehouse gets that first value.
Measured on a database with two warehouses whose real quantities are 200 and 89:
with_context(warehouse=wh.id).immediately_usable_qty→ 384 / 384 (the company-wide figure)with_context(warehouse_id=wh.id).immediately_usable_qty→ 200 / 200 (first value reused)with_context(warehouse_id=wh.id).qty_available→ 200 / 89 (correct)
It surfaced through pos_stock_available_online, which displays one figure per warehouse in the POS: with a single warehouse it looks correct, and it only lies when there is more than one.
What is missing to get this merged? And would a backport to 18.0 be welcome? I can open it.
|
This PR has the |
|
/ocabot merge patch |
|
This PR looks fantastic, let's merge it! |
|
Congratulations, your PR was merged at f9f67ed. Thanks a lot for contributing to OCA. ❤️ |
|
@pedrobaeza I think this PR have been closed but not merged |
|
Uhm, it's true that I don't see the commit in https://github.com/OCA/stock-logistics-availability/commits/19.0/, so the GitHub error suffered yesterday is harder than thought. Let's try again another merge command: /ocabot merge patch |
|
On my way to merge this fine PR! |
|
Congratulations, your PR was merged at f9f67ed. Thanks a lot for contributing to OCA. ❤️ |

Since 19.0,
stockonly filters the quantities by thewarehouse_idcontext key:warehouseisn't read anymore (https://github.com/odoo/odoo/blob/b0907482898d097054a432974a68eb1ecee65326/addons/stock/models/product.py#L370). As it was the key declared independs_context, the ORM cache key ofimmediately_usable_qtydidn't take the warehouse into account, so once the field was computed for one warehouse, every other warehouse got that very same value.allowed_company_idswas missing as well, althoughvirtual_available, which this field is computed from, does depend on it.cc @Tecnativa
ping @sergio-teruel @Andrii9090-tecnativa