Steps to reproduce the bug:
- Install `delivery_dhl`
- Create a storable product “P1”:
- make sure the weight of the product is equal to 0
- create a transfert:
- Type: delivery orders
- Add the product “P1”
- Go to “Additional info” tab and select “DHL” in the carrier field
- Mark as Todo
- Validate
Problem:
A traceback is triggered, because in order to set the shipment details,
a package should be created, so the `_get_packages_from_picking`
function is called:
https://github.com/odoo/enterprise/blob/aed802ee17dba5ebe12b42594503732a2662be68/delivery_dhl/models/dhl_request.py#L166
But as the total weight of the products is equal to 0, the package is
not created:
https://github.com/odoo/odoo/blob/6b0ab28791f4a29254d294f8a116545d4c124e8b/addons/delivery/models/delivery_carrier.py#L324-L325
then, the result is used without checking if the package has been
created:
https://github.com/odoo/enterprise/blob/aed802ee17dba5ebe12b42594503732a2662be68/delivery_dhl/models/dhl_request.py#L185
Solution:
If the total products weight is equal to 0, raise a UserError
opw-3076826
opw-3075562
closes odoo/odoo#106894
X-original-commit: c18064d717312287f5acba2fabeb77b2e1c01fb9
Signed-off-by: William Henrotin (whe) <whe@odoo.com>
Signed-off-by: Djamel Touati (otd) <otd@odoo.com>