From d68929407e870ced271ec1bd33ac2a25d44bf4dc Mon Sep 17 00:00:00 2001 From: Victor Feyens Date: Fri, 29 Apr 2022 10:50:58 +0000 Subject: [PATCH] [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 --- addons/sale_management/controllers/portal.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/addons/sale_management/controllers/portal.py b/addons/sale_management/controllers/portal.py index c3763df6a84..63f54229fb6 100644 --- a/addons/sale_management/controllers/portal.py +++ b/addons/sale_management/controllers/portal.py @@ -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: