[FIX] product: recover a uom even when the default one is deleted

Delete the uom 'kg'(kilos, kilograms), open a product form view

Traceback will popup because the hardcoded xmlid cannot find the value
in the database since has been deleted. Adding a fallback fix the issue

opw-2194659

closes odoo/odoo#45265

X-original-commit: 62baf8ba12cdf4521c6d0d0fea61ff1aa2e3f4d8
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Andrea Grazioso (agr-odoo)
2020-02-13 08:57:59 +00:00
parent ea2d316687
commit ed17f560fa
+2 -2
View File
@@ -279,9 +279,9 @@ class ProductTemplate(models.Model):
"""
product_weight_in_lbs_param = self.env['ir.config_parameter'].sudo().get_param('product.weight_in_lbs')
if product_weight_in_lbs_param == '1':
return self.env.ref('uom.product_uom_lb')
return self.env.ref('uom.product_uom_lb', False) or self.env['uom.uom'].search([('measure_type', '=' , 'weight'), ('uom_type', '=', 'reference')], limit=1)
else:
return self.env.ref('uom.product_uom_kgm')
return self.env.ref('uom.product_uom_kgm', False) or self.env['uom.uom'].search([('measure_type', '=' , 'weight'), ('uom_type', '=', 'reference')], limit=1)
@api.model
def _get_length_uom_id_from_ir_config_parameter(self):