[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@f879cf2867

closes odoo/odoo#112465

X-original-commit: 7b9dd53a5573141275d41436189c782bccb96c3d
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
Thibault Libioulle
2023-02-11 00:41:45 +01:00
parent aca7beb2e2
commit ea780d1f71
+5 -2
View File
@@ -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')