From e33b3f4e0183eb921e599e5f4bb6fa03093f85fd Mon Sep 17 00:00:00 2001 From: "Adrien Widart (awt)" Date: Wed, 29 Mar 2023 15:05:26 +0000 Subject: [PATCH] [FIX] stock: display weight UoM on storage category On the form of a storage category, the UoM of the weight is hardcoded. This is incorrect as it could be `lb` thanks to the option in the Settings OPW-3204924 closes odoo/odoo#117236 X-original-commit: 57d3829d26d16d5360380aec4b7807fc381dd34a Signed-off-by: William Henrotin (whe) Signed-off-by: Adrien Widart --- addons/stock/models/stock_storage_category.py | 4 ++++ addons/stock/views/stock_storage_category_views.xml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/stock/models/stock_storage_category.py b/addons/stock/models/stock_storage_category.py index abc8a6f410b..f58b21e060b 100644 --- a/addons/stock/models/stock_storage_category.py +++ b/addons/stock/models/stock_storage_category.py @@ -20,6 +20,7 @@ class StorageCategory(models.Model): ('mixed', 'Allow mixed products')], default='mixed', required=True) location_ids = fields.One2many('stock.location', 'storage_category_id') company_id = fields.Many2one('res.company', 'Company') + weight_uom_name = fields.Char(string='Weight unit', compute='_compute_weight_uom_name') _sql_constraints = [ ('positive_max_weight', 'CHECK(max_weight >= 0)', 'Max weight should be a positive number.'), @@ -31,6 +32,9 @@ class StorageCategory(models.Model): storage_category.product_capacity_ids = storage_category.capacity_ids.filtered(lambda c: c.product_id) storage_category.package_capacity_ids = storage_category.capacity_ids.filtered(lambda c: c.package_type_id) + def _compute_weight_uom_name(self): + self.weight_uom_name = self.env['product.template']._get_weight_uom_name_from_ir_config_parameter() + def _set_storage_capacity_ids(self): for storage_category in self: storage_category.capacity_ids = storage_category.product_capacity_ids | storage_category.package_capacity_ids diff --git a/addons/stock/views/stock_storage_category_views.xml b/addons/stock/views/stock_storage_category_views.xml index cab8385103c..7abd91c8dc5 100644 --- a/addons/stock/views/stock_storage_category_views.xml +++ b/addons/stock/views/stock_storage_category_views.xml @@ -19,7 +19,7 @@