diff --git a/cooperator/readme/newsfragments/86.bugfix.17.rst b/cooperator/readme/newsfragments/86.bugfix.17.rst new file mode 100644 index 000000000..f79e41a43 --- /dev/null +++ b/cooperator/readme/newsfragments/86.bugfix.17.rst @@ -0,0 +1,2 @@ +Display an error message instead of failing when trying to create a +subscription request from a partner and no share products are available. diff --git a/cooperator/wizard/partner_create_subscription.py b/cooperator/wizard/partner_create_subscription.py index 18d09081d..ea3135b37 100644 --- a/cooperator/wizard/partner_create_subscription.py +++ b/cooperator/wizard/partner_create_subscription.py @@ -29,8 +29,12 @@ def _default_product_id(self): domain.append(("by_company", "=", True)) else: domain.append(("by_individual", "=", True)) - - return self.env["product.product"].search(domain)[0] + products = self.env["product.product"].search(domain) + if not products: + raise UserError( + _("No default share product found for this type of partner.") + ) + return products[0] def _get_representative(self): partner = self._get_partner()