[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
This commit is contained in:
Lucas Perais (lpe)
2019-01-16 12:06:45 +00:00
parent 44585c2420
commit e79c35dcbc
2 changed files with 9 additions and 1 deletions
+7
View File
@@ -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):
@@ -77,7 +77,8 @@
<field name="qty_at_date"/>
<field name="uom_id" groups="uom.group_uom"/>
<field name="currency_id" invisible="1"/>
<field name="stock_value" sum="Stock Valuation" widget="monetary"/>
<field name="stock_value_currency_id" invisible="1"/>
<field name="stock_value" sum="Stock Valuation" widget="monetary" options="{'currency_field': 'stock_value_currency_id'}"/>
<field name="cost_method" invisible="1"/>
<button name="action_valuation_at_date_details" type="object" icon="fa-info-circle" aria-label="Valuation" title="Valuation" attrs="{'invisible': [('cost_method', '!=', 'fifo')]}" />
</tree>