[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
This commit is contained in:
Pierre-Yves Dufays
2023-02-23 14:53:50 +01:00
committed by Thibault Delavallée
parent c3873cb1e1
commit 6701df08b4
+1 -1
View File
@@ -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'):