From 8603b89a525d4a9081aea92bbc43be9fa90bc5ac Mon Sep 17 00:00:00 2001 From: alt-odoo Date: Fri, 18 Jun 2021 11:42:15 +0000 Subject: [PATCH] [FIX] mrp_account: correctly retrieve rounding factor of currency The company is not mandatory on the analytic account, and the currency on it is a related field to the currency of that company, if set. In case it is not set, we should add a default fallback on the currency of the company of the manufacturing order. closes odoo/odoo#72482 X-original-commit: 4fc2ec31861d4602357f130066ec3507b96d8dc8 Signed-off-by: Arnold Moyaux Signed-off-by: Alex Tuyls --- addons/mrp_account/models/mrp_production.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/mrp_account/models/mrp_production.py b/addons/mrp_account/models/mrp_production.py index 74b10914178..460e5a6deac 100644 --- a/addons/mrp_account/models/mrp_production.py +++ b/addons/mrp_account/models/mrp_production.py @@ -63,7 +63,7 @@ class MrpProduction(models.Model): AccountAnalyticLine = self.env['account.analytic.line'].sudo() for wc_line in self.workorder_ids.filtered('workcenter_id.costs_hour_account_id'): vals = self._prepare_wc_analytic_line(wc_line) - precision_rounding = wc_line.workcenter_id.costs_hour_account_id.currency_id.rounding + precision_rounding = (wc_line.workcenter_id.costs_hour_account_id.currency_id or self.company_id.currency_id).rounding if not float_is_zero(vals.get('amount', 0.0), precision_rounding=precision_rounding): # we use SUPERUSER_ID as we do not guarantee an mrp user # has access to account analytic lines but still should be