Skip to content

[FIX] stock_inventory_preparation_filter: exclude virtual locations from domain filter - #2604

Open
SaraMohamedlorim wants to merge 1 commit into
OCA:17.0from
SaraMohamedlorim:fix-virtual-location-filter-2498
Open

SaraMohamedlorim wants to merge 1 commit into
OCA:17.0from
SaraMohamedlorim:fix-virtual-location-filter-2498

Conversation

@SaraMohamedlorim

Copy link
Copy Markdown

Problem

When using Filtered Products (domain) selection in Inventory Adjustment,
the results include quants from virtual locations (e.g. Customers, Inventory Adjustments),
which should not appear in a physical inventory count.

Fixes #2498

Root Cause

_get_quants() was searching quants by product_id only, without filtering
by location_id, causing virtual location quants to be included.

Solution

Added location_id filter to the quant search in _get_quants() when
product_selection == "domain", consistent with how other selection
modes handle location filtering.

Steps to Reproduce

  1. Create an Inventory Adjustment
  2. Set Filtered Products and define a domain (e.g. by category)
  3. Click Begin Adjustment
  4. ❌ Virtual location products appear in the results

After Fix

  • ✅ Only quants from the selected location are returned
  • ✅ Virtual locations (Customers, Inventory Adjustments, etc.) are excluded
  • ✅ Test added to cover this scenario

@rousseldenis

Copy link
Copy Markdown
Contributor

@SaraMohamedlorim Thanks for this.

You should follow this migration guide: https://github.com/OCA/maintainer-tools/wiki/Migration-to-version-17.0

You need to keep commits history

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

Hello @SaraMohamedlorim thank you for fixing this. I can not find the update on Runboat, could you follow the guide, please?

I would love to test and approve it. please let me know once you update and ready to test on Runboat. ;)

…rom quant search

_get_quants() searched quants by product_id only when using the
"Filtered Products" (domain) selection, without filtering by
location_id, so quants from virtual locations (Customers, Inventory
Adjustments, etc.) were included in the inventory count.

(cherry picked from commit 562e287)
@SaraMohamedlorim
SaraMohamedlorim force-pushed the fix-virtual-location-filter-2498 branch from 4b11a55 to 7125993 Compare August 18, 2026 09:53
@SaraMohamedlorim

Copy link
Copy Markdown
Author

@rousseldenis @nurinayati Thanks for the feedback. You're right — the same bug also exists on 16.0 and 18.0, so I've followed the OCA convention of fixing the oldest maintained branch first and forward-porting from there:

Opened a fix on 16.0 first: #[2604]
Cherry-picked that commit (with -x) into this branch, so the commit history is preserved and traceable back to the original fix: (cherry picked from commit 562e287)
I've just force-pushed the updated commit here, so this PR now has a single commit that keeps the history instead of a standalone rewrite. This should also trigger a fresh Runboat build.

Let me know if you'd like me to do the same for 18.0.

@nurinayati

Copy link
Copy Markdown

thank you @SaraMohamedlorim. Can we include the sublocations? It's missing for inventory adjustments
Please see example below I think the inventory adjustment should include the stock from WH/Stock/Shelf 2

Inventory Adjustment Current stock
image

WH/Stock: current stock including sublocations
image

@nurinayati

Copy link
Copy Markdown

Hi @rousseldenis, are there any other technical points to fix? Could you review again, please? thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants