Skip to content

[FIX] quantity per warehouse: use the warehouse_id context key - #1

Open
IJOL wants to merge 1 commit into
nikul-serpentcs:18_mig_pos_stock_available_onlinefrom
BITVAX:18.0-fix-pos_stock_available_online-warehouse
Open

IJOL wants to merge 1 commit into
nikul-serpentcs:18_mig_pos_stock_available_onlinefrom
BITVAX:18.0-fix-pos_stock_available_online-warehouse

Conversation

@IJOL

@IJOL IJOL commented Sep 1, 2026

Copy link
Copy Markdown

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.

stock reads only the warehouse_id context key since 18.0 (_get_domain_locations, addons/stock/models/product.py), so with_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:

  • as it is now → 384 / 384, total 768
  • with warehouse_id → 200 / 89, total 289

Note that warehouse_id alone is not enough until stock_available fixes its depends_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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant