Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: Inventory

Entity: stock.picking

Compute Method: _compute_shipping_weight

View 18.0 View 20.0
Inputs Method Outputs
  • move_line_ids
  • move_line_ids.result_package_id
  • id
  • weight_bulk
  • move_line_ids.result_package_id.outermost_package_id
  • shipping_weight
for picking in self:
            # if shipping weight is not assigned => default to calculated product weight
-             packages_weight = picking.move_line_ids.result_package_id.sudo()._get_weight(picking.id)
-             picking.shipping_weight = (
-                 picking.weight_bulk +
-                 sum(pack.shipping_weight or packages_weight[pack] for pack in picking.move_line_ids.result_package_id)
-             )
+             shipping_weight = picking.weight_bulk
+             relevant_packages = picking.move_line_ids.result_package_id.outermost_package_id
+             packages_weight = relevant_packages.sudo()._get_weight(picking.id)
+             for package in relevant_packages:
+                 if package.shipping_weight:
+                     shipping_weight += package.shipping_weight
+                 else:
+                     shipping_weight += packages_weight.get(package, 0)
+             picking.shipping_weight = shipping_weight
  • shipping_weight

Back to entity