[FIX] stock_quantity_history_location: stock.quant action fixup!

This commit is contained in:
hveficent
2019-08-30 11:48:39 +02:00
committed by hveficent
parent eae5a58434
commit 7d108009cf
2 changed files with 20 additions and 4 deletions

View File

@@ -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)])

View File

@@ -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):