diff --git a/stock_quantity_history_location/tests/test_stock_quantity_history_location.py b/stock_quantity_history_location/tests/test_stock_quantity_history_location.py index 0bf7d2c..3f1b762 100644 --- a/stock_quantity_history_location/tests/test_stock_quantity_history_location.py +++ b/stock_quantity_history_location/tests/test_stock_quantity_history_location.py @@ -54,11 +54,20 @@ class TestStockQuantityHistoryLocation(SavepointCase): to_date="2019-08-10").qty_available, 0.0) def test_wizard_current(self): + wizard = self.env['stock.quantity.history'].create({ + "location_id": self.test_stock_loc.id, + "include_child_locations": False, + "compute_at_date": 0, + }) + action = wizard.with_context().open_table() + self.assertEquals(action['domain'], + [('location_id', '=', self.test_stock_loc.id)]) wizard = self.env['stock.quantity.history'].create({ "location_id": self.test_stock_loc.id, "include_child_locations": True, "compute_at_date": 0, }) action = wizard.with_context().open_table() - self.assertEquals(action['context']['location'], - self.test_stock_loc.id) + self.assertEquals(action['domain'], + [('location_id', 'child_of', + self.test_stock_loc.id)]) diff --git a/stock_quantity_history_location/wizards/stock_quantity_history.py b/stock_quantity_history_location/wizards/stock_quantity_history.py index 689ee4f..5849e68 100644 --- a/stock_quantity_history_location/wizards/stock_quantity_history.py +++ b/stock_quantity_history_location/wizards/stock_quantity_history.py @@ -20,8 +20,15 @@ class StockQuantityHistory(models.TransientModel): ctx = action['context'] if isinstance(ctx, str): ctx = ast.literal_eval(ctx) - action['domain'] = [('type', '=', 'product')] - if self.location_id: + # If we are opening the current quants, filter by domain + if self.location_id and not self.compute_at_date and not \ + self.env.context.get('valuation'): + if self.include_child_locations: + action['domain'] = [ + ('location_id', 'child_of', self.location_id.id)] + else: + action['domain'] = [('location_id', '=', self.location_id.id)] + elif self.location_id: ctx['location'] = self.location_id.id ctx['compute_child'] = self.include_child_locations if ctx.get('company_owned', False):