From 3d21e61e4b13fce06af505f333e5d0f4e5dd9cfb Mon Sep 17 00:00:00 2001 From: Ahmad Khanalizadeh Date: Thu, 11 May 2023 09:31:45 +0000 Subject: [PATCH] [FIX] delivery: exclude service lines from commodities Steps to reproduce: configure easypost for international shipping (e.g. using USPS) Make a sale order for a customer in another country Add a discount program (e.g. 10% off) Attempt to add shipping and get the rates Get traceback: `Easypost returned an error: Wrong parameter type. - value: must be greater than or equal to 0` To fix this we need to exclude service type products when creating commodities from order lines (similar to creating commodities from stock move lines) opw-3269467 closes odoo/odoo#122869 X-original-commit: c4904454d46036374ea5e9ae7047f1546e9cab44 Signed-off-by: Tiffany Chang Signed-off-by: Khanalizadeh Ahmad (khah) --- addons/stock_delivery/models/delivery_carrier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock_delivery/models/delivery_carrier.py b/addons/stock_delivery/models/delivery_carrier.py index f4d108445e2..7a6618838d7 100644 --- a/addons/stock_delivery/models/delivery_carrier.py +++ b/addons/stock_delivery/models/delivery_carrier.py @@ -185,7 +185,7 @@ class DeliveryCarrier(models.Model): def _get_commodities_from_order(self, order): commodities = [] - for line in order.order_line.filtered(lambda line: not line.is_delivery and not line.display_type): + for line in order.order_line.filtered(lambda line: not line.is_delivery and not line.display_type and line.product_id.type in ['product', 'consu']): unit_quantity = line.product_uom._compute_quantity(line.product_uom_qty, line.product_id.uom_id) rounded_qty = max(1, float_round(unit_quantity, precision_digits=0)) country_of_origin = line.product_id.country_of_origin.code or order.warehouse_id.partner_id.country_id.code