diff --git a/product_catalog_tree/models/product_catalog_mixin.py b/product_catalog_tree/models/product_catalog_mixin.py index ee908952f..0253e5d1b 100644 --- a/product_catalog_tree/models/product_catalog_mixin.py +++ b/product_catalog_tree/models/product_catalog_mixin.py @@ -9,4 +9,9 @@ def action_add_from_catalog(self): action = super().action_add_from_catalog() tree_view_id = self.env.ref("product_catalog_tree.product_view_tree_catalog").id action["views"] = [(tree_view_id, "list")] + action["views"] + # add warehouse location filter if order has warehouse + context = action.get("context", {}) + if "order_id" in context and self._name == "sale.order": + if self._fields.get("warehouse_id") and self.warehouse_id: + action["context"]["search_default_location_id"] = self.warehouse_id.lot_stock_id.id return action