Repository navigation
[FIX] quantity per warehouse: use the warehouse_id context key - #1
Open
IJOL wants to merge 1 commit into
Conversation
Since 18.0, stock reads only the `warehouse_id` context key in `_get_domain_locations`, so `with_context(warehouse=...)` is ignored and every warehouse gets the company-wide quantity.
IJOL
added a commit
to BITVAX/pos
that referenced
this pull request
Sep 1, 2026
Squashed content of OCA#1457 plus the warehouse_id context key fix proposed in nikul-serpentcs#1. Kept in this fork until the upstream PR is merged.
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.
Thanks for the migration. One line is missing for it to work on 18.0, and it is the one your own 19.0 migration (OCA#1567) already has.
stockreads only thewarehouse_idcontext key since 18.0 (_get_domain_locations,addons/stock/models/product.py), sowith_context(warehouse=self.id)is silently ignored and every warehouse shows the company-wide figure. With a single warehouse configured it looks correct — it only shows when there is more than one, which is when the module is useful.Measured on a database with two warehouses whose real quantities are 200 and 89:
warehouse_id→ 200 / 89, total 289Note that
warehouse_idalone is not enough untilstock_availablefixes itsdepends_context, which is what OCA/stock-logistics-availability#82 does for 19.0 — without that backport to 18.0 the ORM caches the first warehouse's value and reuses it. I have asked there about a 18.0 backport.Tested on a real 18.0 database: install, product cards, and the live bus refresh all working.