summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorAndrea Grazioso (agr-odoo) <agr@odoo.com>2020-02-12 13:21:03 +0000
committerAndrea Grazioso (agr-odoo) <agr@odoo.com>2020-02-13 08:57:59 +0000
commited17f560fa06e2d1c9e7495c9a4cbfe1cea5bce6 (patch)
tree7287a116c6ef497073274d2c94fcf8fced4a4a2a /addons
parentea2d3166871f72d19617929c55aed18fa3d4d8f3 (diff)
[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>
Diffstat (limited to 'addons')
-rw-r--r--addons/product/models/product_template.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/addons/product/models/product_template.py b/addons/product/models/product_template.py
index 7d150b4bf14..7a4eb015020 100644
--- a/addons/product/models/product_template.py
+++ b/addons/product/models/product_template.py
@@ -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):