From de2725c173cfe028c3c0f411e613ba732be14772 Mon Sep 17 00:00:00 2001 From: William Henrotin Date: Thu, 12 Sep 2019 13:38:45 +0000 Subject: [PATCH] [FIX] stock: remove dummy field from depends_context This commit removes 'location' and 'warehouse' from the api.depends_context of _compute_quantities() as: 1. They are not needed. They are never changed in a single transaction in the current code 2. The ORM doens't support the fact that they are sometimes passed as list instead of integer closes odoo/odoo#36788 Signed-off-by: Simon Lejeune (sle) --- addons/sale_mrp/tests/test_sale_mrp_flow.py | 6 ++++-- addons/stock/models/product.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/sale_mrp/tests/test_sale_mrp_flow.py b/addons/sale_mrp/tests/test_sale_mrp_flow.py index 274ed6b90a3..e7ee1afb040 100644 --- a/addons/sale_mrp/tests/test_sale_mrp_flow.py +++ b/addons/sale_mrp/tests/test_sale_mrp_flow.py @@ -1047,11 +1047,12 @@ class TestSaleMrpFlow(common.SavepointCase): # Check that not enough enough quantities are available in the warehouse set in the SO # but there are enough quantities in Warehouse 1 for 1 kit_parent kit_parent_wh_order = self.kit_parent.with_context(warehouse=so.warehouse_id.id) - kit_parent_wh1 = self.kit_parent.with_context(warehouse=warehouse_1.id) # Check that not enough enough quantities are available in the warehouse set in the SO # but there are enough quantities in Warehouse 1 for 1 kit_parent self.assertEquals(kit_parent_wh_order.virtual_available, 0) + kit_parent_wh_order.invalidate_cache() + kit_parent_wh1 = self.kit_parent.with_context(warehouse=warehouse_1.id) self.assertEquals(kit_parent_wh1.virtual_available, 1) # Check there arn't enough quantities available for the sale order @@ -1072,8 +1073,9 @@ class TestSaleMrpFlow(common.SavepointCase): # As 'Warehouse 2' is the warehouse linked to the SO, 3 kits should be available # But the quantity available in Warehouse 1 should stay 1 kit_parent_wh_order = self.kit_parent.with_context(warehouse=so.warehouse_id.id) - kit_parent_wh1 = self.kit_parent.with_context(warehouse=warehouse_1.id) self.assertEquals(kit_parent_wh_order.virtual_available, 3) + kit_parent_wh_order.invalidate_cache() + kit_parent_wh1 = self.kit_parent.with_context(warehouse=warehouse_1.id) self.assertEquals(kit_parent_wh1.virtual_available, 1) # Check there arn't enough quantities available for the sale order diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index 3bd67a33ffe..f3da4c34a37 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -94,7 +94,7 @@ class Product(models.Model): @api.depends('stock_move_ids.product_qty', 'stock_move_ids.state') @api.depends_context( 'lot_id', 'owner_id', 'package_id', 'from_date', 'to_date', - 'company_owned', 'location', 'warehouse', 'force_company', + 'company_owned', 'force_company', ) def _compute_quantities(self): products = self.filtered(lambda p: p.type != 'service') @@ -616,7 +616,7 @@ class ProductTemplate(models.Model): 'product_variant_ids.stock_move_ids.product_qty', 'product_variant_ids.stock_move_ids.state', ) - @api.depends_context('company_owned', 'location', 'warehouse', 'force_company') + @api.depends_context('company_owned', 'force_company') def _compute_quantities(self): res = self._compute_quantities_dict() for template in self: