Skip to content

Commit

Permalink
[FIX] delivery: package UOM
Browse files Browse the repository at this point in the history
Since it is now possible to select the default UOM, do not hardcode `kg`
in the view.

opw-1920809

closes #30427
  • Loading branch information
nim-odoo committed Jan 22, 2019
1 parent 8f2267b commit 3eeb774
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions addons/delivery/wizard/choose_delivery_package.py
Expand Up @@ -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'):
Expand All @@ -45,6 +46,12 @@ def _default_shipping_weight(self):
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:
Expand Down
2 changes: 1 addition & 1 deletion addons/delivery/wizard/choose_delivery_package_views.xml
Expand Up @@ -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>
Expand Down

0 comments on commit 3eeb774

Please sign in to comment.