[FIX] delivery: do not always recompute estimated shipping price

When a SO is not in draft AND uses an external shipping provider, it
does not make sens to re-poll the provider for the price (and this is
quite slow)
This commit is contained in:
Richard Mathot
2015-08-05 16:43:15 +02:00
committed by Antony Lesuisse
parent 28ff2e9585
commit 271ab79666
+8 -1
View File
@@ -31,7 +31,14 @@ class SaleOrder(models.Model):
@api.depends('carrier_id', 'partner_id', 'order_line')
def _compute_delivery_price(self):
for order in self:
order.delivery_price = order.carrier_id.with_context(order_id=order.id).price
if order.state != 'draft':
# we do not want to recompute the shipping price of an already validated/done SO
continue
elif order.carrier_id.delivery_type != 'grid' and not order.order_line:
# prevent SOAP call to external shipping provider when SO has no lines yet
continue
else:
order.delivery_price = order.carrier_id.with_context(order_id=order.id).price
@api.multi
def delivery_set(self):