[FIX] website_sale_delivery: update shopping cart

The delivery must be updated when the cart is updated.
The method "_check_carrier_quotation" called by "_cart_update" deletes sale order line related to delivery.
Then each line passed to "_cart_update" must be checked with "exists" to be sure that the record is not
missing.
Related to the task : 12239
opw:641913
This commit is contained in:
Goffin Simon, Nicolas Lempereur 2015-03-04 15:34:13 +01:00 committed by Goffin Simon
parent 018435c6d7
commit 98a72a2604
2 changed files with 14 additions and 1 deletions

View File

@ -190,7 +190,8 @@ class website(orm.Model):
values.update(sale_order.onchange_pricelist_id(pricelist_id, None)['value'])
sale_order.write(values)
for line in sale_order.order_line:
sale_order._cart_update(product_id=line.product_id.id, line_id=line.id, add_qty=0)
if line.exists():
sale_order._cart_update(product_id=line.product_id.id, line_id=line.id, add_qty=0)
# update browse record
if (code and code != sale_order.pricelist_id.code) or sale_order.partner_id.id != partner.id:

View File

@ -123,3 +123,15 @@ class SaleOrder(orm.Model):
values['deliveries'] = DeliveryCarrier.browse(cr, SUPERUSER_ID, delivery_ids, context=delivery_ctx)
return values
def _cart_update(self, cr, uid, ids, product_id=None, line_id=None, add_qty=0, set_qty=0, context=None, **kwargs):
""" Override to update carrier quotation if quantity changed """
values = super(SaleOrder, self)._cart_update(
cr, uid, ids, product_id, line_id, add_qty, set_qty, context, **kwargs)
if add_qty or set_qty is not None:
for sale_order in self.browse(cr, uid, ids, context=context):
self._check_carrier_quotation(cr, uid, sale_order, context=context)
return values