[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 <tic@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user