From 6701df08b478c75c4b5e6d2dd00244c438578cf3 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Dufays Date: Tue, 6 Dec 2022 10:48:23 +0000 Subject: [PATCH] [IMP] website_sale, purchase: fix condition on portal_customer existence Small correction to make the code more robust. Technical note: we encountered a case where the group 'portal_customer' (to classify recipient for mail_thread) where not present although it is added by portal.mixin inherited by sale.order. That problem has been fixed since. So it doesn't fix an actual problem but a potential one (condition of the "if" cannot be false because the generator will generate an exception before). Task-2674649 Part-of: odoo/odoo#103966 --- addons/website_sale/models/sale_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/website_sale/models/sale_order.py b/addons/website_sale/models/sale_order.py index a19dc92c62b..629f7817c2c 100644 --- a/addons/website_sale/models/sale_order.py +++ b/addons/website_sale/models/sale_order.py @@ -410,7 +410,7 @@ class SaleOrder(models.Model): return groups self.ensure_one() - customer_portal_group = next(group for group in groups if group[0] == 'portal_customer') + customer_portal_group = next((group for group in groups if group[0] == 'portal_customer'), None) if customer_portal_group: access_opt = customer_portal_group[2].setdefault('button_access', {}) if self._context.get('website_sale_send_recovery_email'):