From d40cef681e52ac6a57c5cfed26dedb8057989a31 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Mon, 22 Jun 2020 10:06:06 +0000 Subject: [PATCH] [FIX] stock_account: quant currency - Create 2 companies A & B, with different currencies - Create a product in company B Set the company on the product Automated valuation - Receive some stock in company B - Switch to company A, and keep B available - Go to Inventory > Reporting > Inventory Report The currency on the product is the currency of the product company instead of the currency of the current company. The value is computed in the current company currency: https://github.com/odoo/odoo/blob/bc3d1f2dc408fa91d42743d6a7063042e0f6c42b/addons/stock_account/models/product.py#L115 The currency should be consistent. opw-2278751 closes odoo/odoo#53426 X-original-commit: 8aa952d18acca5a0ac3b32579e812158e641c13c Signed-off-by: Nicolas Martinelli (nim) --- addons/stock_account/models/stock_quant.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/stock_account/models/stock_quant.py b/addons/stock_account/models/stock_quant.py index 8226d1c8cce..a3cc36d866c 100644 --- a/addons/stock_account/models/stock_quant.py +++ b/addons/stock_account/models/stock_quant.py @@ -9,7 +9,7 @@ class StockQuant(models.Model): _inherit = 'stock.quant' value = fields.Monetary('Value', compute='_compute_value', groups='stock.group_stock_manager') - currency_id = fields.Many2one(related='product_id.currency_id', groups='stock.group_stock_manager') + currency_id = fields.Many2one('res.currency', compute='_compute_value', groups='stock.group_stock_manager') @api.depends('company_id', 'location_id', 'owner_id', 'product_id', 'quantity') def _compute_value(self): @@ -20,6 +20,7 @@ class StockQuant(models.Model): average cost is the same for all location and the valuation field is a estimation more than a real value). """ + self.currency_id = self.env.company.currency_id for quant in self: # If the user didn't enter a location yet while enconding a quant. if not quant.location_id: