[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 GuillemCForgeFlow
parent 59b354f129
commit d733cd5058
3 changed files with 21 additions and 5 deletions

View File

@@ -5,7 +5,7 @@
{
'name': 'Stock Quantity History Location',
'summary': "Provides stock quantity by location on past date",
'version': '12.0.1.0.0',
'version': '12.0.1.0.1',
'license': 'AGPL-3',
'author': 'Eficent,'
'Odoo Community Association (OCA)',

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