Do not crash if weight is None.

This commit is contained in:
Albert Cervera i Areny 2023-10-17 18:50:42 +02:00
parent 377383b11a
commit 3de4337486
1 changed files with 3 additions and 2 deletions

View File

@ -119,7 +119,8 @@ class ShipmentOut(metaclass=PoolMeta):
weight = 1
if api.weight and hasattr(shipment, 'manual_weight'):
weight = shipment.manual_weight or shipment.weight
weight = 1 if weight == 0.0 else weight
if not weight:
weight = 1
if api.weight_api_unit:
if shipment.weight_uom:
@ -129,7 +130,7 @@ class ShipmentOut(metaclass=PoolMeta):
weight = Uom.compute_qty(
api.weight_unit, weight, api.weight_api_unit)
# weight is integer value, not float
# weight must integer value, not float
weight = int(round(weight))
weight = 1 if weight == 0 else weight