From c4dc4735c4295eb12db4818ec6235c6cf17d3cc8 Mon Sep 17 00:00:00 2001 From: prye-odoo Date: Mon, 8 May 2023 12:46:38 +0000 Subject: [PATCH] [FIX] delivery: prevent trace back while partner has no zip In delivery address, `country name` and in shipping method, `country name` will be same and no zip in delivery address. While creating new sale order along with product and clicking on "Add shipping", error will be generated. Steps to Reproduce -Install `sale_management' and 'delivery' modules -Go to the settings and enable the 'Customer Address'. -Go to the settings and enable 'Shipping Methods' and configure it. -Select a shipping method and go to the 'Destination Availability' tab and set to the 'Countries' and set to 'Zip Prefixes'. -Create a new customer and add the delivery address of the customer in res.partner. -The delivery address and shipping method of the 'Countries" or 'Country' name should be the same. -Set the 'Zip Prefixes' -Set the delivery address of zip code null. -Create a new quotation and add to the customer and delivery address -Add to the product in the sale order line. -Click on the 'Add Shipping' or 'Update Shipping Cost' button. A trace back will be generated. Applying this commit will resolve this issue. sentry-4147077852 closes odoo/odoo#120968 X-original-commit: 60d5c7d5668da542e251d7d6fb8774043cfddea8 Signed-off-by: Tiffany Chang --- addons/delivery/models/delivery_carrier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/delivery/models/delivery_carrier.py b/addons/delivery/models/delivery_carrier.py index 4084f9a2b65..39a9064b31e 100644 --- a/addons/delivery/models/delivery_carrier.py +++ b/addons/delivery/models/delivery_carrier.py @@ -139,7 +139,7 @@ class DeliveryCarrier(models.Model): return False if self.zip_prefix_ids: regex = re.compile('|'.join(['^' + zip_prefix for zip_prefix in self.zip_prefix_ids.mapped('name')])) - if not re.match(regex, partner.zip.upper()): + if not partner.zip or not re.match(regex, partner.zip.upper()): return False return True