[FIX] delivery: don't crash ecommerce when no grid has been found
(+ improve a bit the error message)
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user