[FIX] website_sale: prevent crash if setting qty to 0 in cart update

When there is an optional product for which the quantity is set to 0 because
there is no stock available, the cart update would raise because it tried to
read the order line even though it was deleted above.

Now we apply the logic only if the order_line actually exists.

Part of task 1950712

closes odoo/odoo#31779

Signed-off-by: Lucas Perais (lpe) <lpe@odoo.com>
This commit is contained in:
Sébastien Theys
2019-03-12 10:59:27 +00:00
parent 77584bee3c
commit cd773e79df
+8 -8
View File
@@ -280,14 +280,14 @@ class SaleOrder(models.Model):
order_line.write(values)
# link a product to the sales order
if kwargs.get('linked_line_id'):
linked_line = SaleOrderLineSudo.browse(kwargs['linked_line_id'])
order_line.write({
'linked_line_id': linked_line.id,
'name': order_line.name + "\n" + _("Option for:") + ' ' + linked_line.product_id.display_name,
})
linked_line.write({"name": linked_line.name + "\n" + _("Option:") + ' ' + order_line.product_id.display_name})
# link a product to the sales order
if kwargs.get('linked_line_id'):
linked_line = SaleOrderLineSudo.browse(kwargs['linked_line_id'])
order_line.write({
'linked_line_id': linked_line.id,
'name': order_line.name + "\n" + _("Option for:") + ' ' + linked_line.product_id.display_name,
})
linked_line.write({"name": linked_line.name + "\n" + _("Option:") + ' ' + order_line.product_id.display_name})
option_lines = self.order_line.filtered(lambda l: l.linked_line_id.id == order_line.id)
for option_line_id in option_lines: