[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:
parent
018435c6d7
commit
98a72a2604
|
@ -190,6 +190,7 @@ class website(orm.Model):
|
||||||
values.update(sale_order.onchange_pricelist_id(pricelist_id, None)['value'])
|
values.update(sale_order.onchange_pricelist_id(pricelist_id, None)['value'])
|
||||||
sale_order.write(values)
|
sale_order.write(values)
|
||||||
for line in sale_order.order_line:
|
for line in sale_order.order_line:
|
||||||
|
if line.exists():
|
||||||
sale_order._cart_update(product_id=line.product_id.id, line_id=line.id, add_qty=0)
|
sale_order._cart_update(product_id=line.product_id.id, line_id=line.id, add_qty=0)
|
||||||
|
|
||||||
# update browse record
|
# update browse record
|
||||||
|
|
|
@ -123,3 +123,15 @@ class SaleOrder(orm.Model):
|
||||||
|
|
||||||
values['deliveries'] = DeliveryCarrier.browse(cr, SUPERUSER_ID, delivery_ids, context=delivery_ctx)
|
values['deliveries'] = DeliveryCarrier.browse(cr, SUPERUSER_ID, delivery_ids, context=delivery_ctx)
|
||||||
return values
|
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
|
||||||
|
|
Loading…
Reference in New Issue