[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) <whe@odoo.com>
Signed-off-by: Adrien Widart <awt@odoo.com>
This commit is contained in:
Adrien Widart (awt)
2023-03-31 09:48:41 +02:00
parent 560243aefa
commit e33b3f4e01
2 changed files with 6 additions and 2 deletions
@@ -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
@@ -19,7 +19,7 @@
<label for="max_weight"/>
<div class="o_row">
<field name="max_weight"/>
<span>kg</span>
<span><field name="weight_uom_name"/></span>
</div>
<field name="company_id" groups="base.group_multi_company"/>
</group>
@@ -56,7 +56,7 @@
<field name="arch" type="xml">
<tree string="Storage Categories" multi_edit="1">
<field name="name"/>
<field name="max_weight" string="Max Weight (kg)"/>
<field name="max_weight" string="Max Weight"/>
<field name="allow_new_product"/>
<field name="company_id" groups="base.group_multi_company"/>
</tree>