Skip to content
Snippets Groups Projects
Commit cd773e79 authored by Sébastien Theys's avatar Sébastien Theys
Browse files

[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: default avatarLucas Perais (lpe) <lpe@odoo.com>
parent 77584bee
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment