summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Perais (lpe) <lpe@odoo.com>2019-01-15 16:46:57 +0000
committerLucas Perais (lpe) <lpe@odoo.com>2019-01-16 12:06:45 +0000
commite79c35dcbc1525196263cca6aa9da14ca30d2c0a (patch)
tree69d20116deb4fe90d25eb1a96a2e309ac41fdd61
parent44585c242002805fdb625ae73791b3dc83cef847 (diff)
[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
-rw-r--r--addons/stock_account/models/product.py7
-rw-r--r--addons/stock_account/views/stock_account_views.xml3
2 files changed, 9 insertions, 1 deletions
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(
@@ -177,6 +178,12 @@ class ProductProduct(models.Model):
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):
StockMove = self.env['stock.move']
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 @@
<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>