[FIX] sale_management: avoid useless error shown to portal user

On the portal, if you 'spamclick' to reduce the quantity of an optional 
line on the portal, when the quantity hits 0, the line is removed, but 
you might receive a MissingError saying the record doesn't exist anymore 
(if you clicked more times than the qty of the optional line).

To avoid showing this error to the customer, we check the existence of 
the option before trying to read its content (and checking it belongs to 
the right order).

Part-of: odoo/odoo#88366
This commit is contained in:
Victor Feyens
2022-05-05 17:33:50 +02:00
parent f0f14bf25a
commit d68929407e
+3 -2
View File
@@ -45,8 +45,9 @@ class CustomerPortal(portal.CustomerPortal):
if order_sudo.state not in ('draft', 'sent'):
return False
order_line = request.env['sale.order.line'].sudo().browse(int(line_id))
if order_line.order_id != order_sudo:
order_line = request.env['sale.order.line'].sudo().browse(int(line_id)).exists()
if not order_line or order_line.order_id != order_sudo:
return False
if input_quantity is not False: