From 9a2cc36ce9c0b2344fc9e115c6cb932eb7fb4149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 18 Apr 2014 19:30:49 +0200 Subject: [PATCH] Add test for product_by_location with stock_skip_warehouse and no product_ids issue3843 review5171002 --- tests/test_stock.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/test_stock.py b/tests/test_stock.py index 5cac48ee74..4f260a9514 100644 --- a/tests/test_stock.py +++ b/tests/test_stock.py @@ -367,7 +367,7 @@ class StockTestCase(unittest.TestCase): self.period.close([period]) test_products_by_location() - # Test with_childs + # Test with_childs and stock_skip_warehouse with Transaction().start(DB_NAME, USER, context=CONTEXT) as transaction: company, = self.company.search([ @@ -394,6 +394,7 @@ class StockTestCase(unittest.TestCase): lost_found, = self.location.search([('type', '=', 'lost_found')]) warehouse, = self.location.search([('type', '=', 'warehouse')]) storage, = self.location.search([('code', '=', 'STO')]) + input_, = self.location.search([('code', '=', 'IN')]) storage1, = self.location.create([{ 'name': 'Storage 1', 'type': 'view', @@ -419,6 +420,15 @@ class StockTestCase(unittest.TestCase): 'planned_date': today, 'effective_date': today, 'company': company.id, + }, { + 'product': product.id, + 'uom': unit.id, + 'quantity': 1, + 'from_location': input_.id, + 'to_location': storage.id, + 'planned_date': today, + 'effective_date': today, + 'company': company.id, }]) self.move.do(moves) @@ -427,6 +437,16 @@ class StockTestCase(unittest.TestCase): self.assertEqual(products_by_location[(warehouse.id, product.id)], 1) + with Transaction().set_context(stock_skip_warehouse=True): + products_by_location = self.product.products_by_location( + [warehouse.id], [product.id], with_childs=True) + products_by_location_all = self.product.products_by_location( + [warehouse.id], None, with_childs=True) + self.assertEqual(products_by_location[(warehouse.id, product.id)], + 2) + self.assertEqual( + products_by_location_all[(warehouse.id, product.id)], 2) + def test0030period(self): 'Test period' with Transaction().start(DB_NAME, USER,