[FIX] delivery: don't crash ecommerce when no grid has been found

(+ improve a bit the error message)
This commit is contained in:
Richard Mathot
2017-08-01 09:35:46 +02:00
parent 0cc7d4ef9d
commit e449291f28
+8 -2
View File
@@ -53,7 +53,13 @@ class ProviderGrid(models.Model):
'error_message': _('Error: no matching grid.'),
'warning_message': False}
price_unit = self._get_price_available(order)
try:
price_unit = self._get_price_available(order)
except UserError as e:
return {'success': False,
'price': 0.0,
'error_message': e.name,
'warning_message': False}
if order.company_id.currency_id.id != order.pricelist_id.currency_id.id:
price_unit = order.company_id.currency_id.with_context(date=order.date_order).compute(price_unit, order.pricelist_id.currency_id)
@@ -94,7 +100,7 @@ class ProviderGrid(models.Model):
criteria_found = True
break
if not criteria_found:
raise UserError(_("Selected product in the delivery method doesn't fulfill any of the delivery carrier(s) criteria."))
raise UserError(_("No price rule matching this order; delivery cost cannot be computed."))
return price