From ee96c84a60cd8e708a71a1e988e76cb6e6343641 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 21 Sep 2018 09:06:41 +0000 Subject: [PATCH] [FIX] stock: quant domain in valorisation - Create a Customer location (CL) and set a Company on it - Configure Product A in FIFO / Perpetual - Receive 2 Unit(s) of A in Stock - Create an Internal Transfer 1 Unit(s) of Product A Source location: Stock Destination Location: CL - Validate The Inventory Valuation report incorrectly retrieves a quantity of 2 in stock instead of 1. The error is first due to a misconfiguration: the CL should not have a Company set. However, we should not take into account any quantity in a customer location, even if there is a Company set. opw-1884675 opw-1884835 closes odoo/odoo#27145 --- addons/stock/models/product.py | 2 +- addons/stock_account/tests/test_stockvaluation.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/product.py b/addons/stock/models/product.py index 1e3c36c004b..9694ee5ed40 100644 --- a/addons/stock/models/product.py +++ b/addons/stock/models/product.py @@ -159,7 +159,7 @@ class Product(models.Model): if self.env.context.get('company_owned', False): company_id = self.env.user.company_id.id return ( - [('location_id.company_id', '=', company_id)], + [('location_id.company_id', '=', company_id), ('location_id.usage', 'in', ['internal', 'transit'])], [('location_id.company_id', '=', False), ('location_dest_id.company_id', '=', company_id)], [('location_id.company_id', '=', company_id), ('location_dest_id.company_id', '=', False), ]) diff --git a/addons/stock_account/tests/test_stockvaluation.py b/addons/stock_account/tests/test_stockvaluation.py index ce88777d13d..297217e8de7 100644 --- a/addons/stock_account/tests/test_stockvaluation.py +++ b/addons/stock_account/tests/test_stockvaluation.py @@ -3111,7 +3111,7 @@ class TestStockValuation(TransactionCase): self.assertEqual(move1.remaining_value, 10) self.assertEqual(move1.remaining_qty, 1) self.assertAlmostEqual(self.product1.qty_available, 0.0) - self.assertAlmostEqual(self.product1.qty_at_date, 2.0) + self.assertAlmostEqual(self.product1.qty_at_date, 1.0) self.assertEqual(self.product1.stock_value, 10) self.assertTrue(len(move1.account_move_ids), 1)