[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) <nim@odoo.com>
This commit is contained in:
Nicolas Martinelli
2020-06-22 13:32:35 +00:00
parent 221ee7d5b2
commit d40cef681e
+2 -1
View File
@@ -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: