[FIX] delivery: package UOM
Since it is now possible to select the default UOM, do not hardcode `kg` in the view. opw-1920809 closes odoo/odoo#30427
This commit is contained in:
@@ -21,6 +21,7 @@ class ChooseDeliveryPackage(models.TransientModel):
|
||||
string='Shipping Weight',
|
||||
default=lambda self: self._default_shipping_weight()
|
||||
)
|
||||
weight_uom_name = fields.Char(string='Weight unit of measure label', compute='_compute_weight_uom_name')
|
||||
|
||||
def _default_stock_quant_package_id(self):
|
||||
if self.env.context.get('default_stock_quant_package_id'):
|
||||
@@ -45,6 +46,12 @@ class ChooseDeliveryPackage(models.TransientModel):
|
||||
total_weight = sum([po.qty_done * po.product_id.weight for po in move_line_ids])
|
||||
return total_weight
|
||||
|
||||
@api.depends('stock_quant_package_id', 'delivery_packaging_id')
|
||||
def _compute_weight_uom_name(self):
|
||||
weight_uom_id = self.env['product.template']._get_weight_uom_id_from_ir_config_parameter()
|
||||
for package in self:
|
||||
package.weight_uom_name = weight_uom_id.name
|
||||
|
||||
@api.onchange('delivery_packaging_id', 'shipping_weight')
|
||||
def _onchange_packaging_weight(self):
|
||||
if self.delivery_packaging_id.max_weight and self.shipping_weight > self.delivery_packaging_id.max_weight:
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<label for="shipping_weight" attrs="{'invisible': [('delivery_packaging_id', '=', False)]}"/>
|
||||
<div class="o_row" attrs="{'invisible': [('delivery_packaging_id', '=', False)]}">
|
||||
<field name="shipping_weight"/>
|
||||
<span>kg</span>
|
||||
<field name="weight_uom_name"/>
|
||||
</div>
|
||||
</group>
|
||||
<footer>
|
||||
|
||||
Reference in New Issue
Block a user