From e79c35dcbc1525196263cca6aa9da14ca30d2c0a Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Tue, 15 Jan 2019 16:46:57 +0000 Subject: [PATCH] [FIX] stock_account: inventory valuation value in company currency In multicompany, Have company B with a different currency than company A With a shared product catalog Open the inventory valuation report for company B Before this commit the stock Value is expressed in company A's currency, even though the value itself is correct After this commit, the stock value is expressed in the right currency OPW 1912511 closes odoo/odoo#30242 --- addons/stock_account/models/product.py | 7 +++++++ addons/stock_account/views/stock_account_views.xml | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/addons/stock_account/models/product.py b/addons/stock_account/models/product.py index c8817b777ef..dcd197489fb 100644 --- a/addons/stock_account/models/product.py +++ b/addons/stock_account/models/product.py @@ -101,6 +101,7 @@ class ProductTemplate(models.Model): class ProductProduct(models.Model): _inherit = 'product.product' + stock_value_currency_id = fields.Many2one('res.currency', compute='_compute_stock_value_currency') stock_value = fields.Float( 'Value', compute='_compute_stock_value') qty_at_date = fields.Float( @@ -176,6 +177,12 @@ class ProductProduct(models.Model): moves = StockMove.search(domain) return sum(moves.mapped('remaining_value')), moves + @api.multi + def _compute_stock_value_currency(self): + currency_id = self.env.user.company_id.currency_id + for product in self: + product.stock_value_currency_id = currency_id + @api.multi @api.depends('stock_move_ids.product_qty', 'stock_move_ids.state', 'stock_move_ids.remaining_value', 'product_tmpl_id.cost_method', 'product_tmpl_id.standard_price', 'product_tmpl_id.property_valuation', 'product_tmpl_id.categ_id.property_valuation') def _compute_stock_value(self): diff --git a/addons/stock_account/views/stock_account_views.xml b/addons/stock_account/views/stock_account_views.xml index 7dde572369a..2d295145921 100644 --- a/addons/stock_account/views/stock_account_views.xml +++ b/addons/stock_account/views/stock_account_views.xml @@ -77,7 +77,8 @@ - + +