From ea780d1f71096674f2f18965ce98da51d8e9a41a Mon Sep 17 00:00:00 2001 From: Thibault Libioulle Date: Fri, 10 Feb 2023 16:48:45 +0000 Subject: [PATCH] [FIX] purchase: fix StopIteration when notify recipients This commit fixes the case where portal_customer is not added in the recipients group by the portal mixin. Steps to reproduce: - Go on a purchase - Log a note and tag a user who handles notification by email - Traceback: ``` File "/home/odoo/src/odoo/addons/purchase/models/purchase.py", line 346, in _notify_get_recipients_groups customer_portal_group = next(group for group in groups if group[0] == 'portal_customer') StopIteration ``` Current Behavior: - Traceback StopIteration Expected Behavior: - Log a note with the tagged (boomer) user. See odoo/odoo@f879cf28677a516b0cc01c671166de68d9c992e6 closes odoo/odoo#112465 X-original-commit: 7b9dd53a5573141275d41436189c782bccb96c3d Signed-off-by: Thibault Delavallee (tde) --- addons/purchase/models/purchase.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/purchase/models/purchase.py b/addons/purchase/models/purchase.py index 16d82fe08da..1986112de45 100644 --- a/addons/purchase/models/purchase.py +++ b/addons/purchase/models/purchase.py @@ -346,8 +346,11 @@ class PurchaseOrder(models.Model): return groups self.ensure_one() - customer_portal_group = next(group for group in groups if group[0] == 'portal_customer') - if customer_portal_group: + try: + customer_portal_group = next(group for group in groups if group[0] == 'portal_customer') + except StopIteration: + pass + else: access_opt = customer_portal_group[2].setdefault('button_access', {}) if self.env.context.get('is_reminder'): access_opt['title'] = _('View')