Skip to content

Commit

Permalink
[FIX] display error in case of no available shares
Browse files Browse the repository at this point in the history
display an error message instead of failing when trying to create a
subscription request from a partner and no share products are available.
  • Loading branch information
huguesdk committed Nov 29, 2023
1 parent fd98a75 commit 6633e88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cooperator/readme/newsfragments/86.bugfix.17.rst
Original file line number Diff line number Diff line change
@@ -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.
8 changes: 6 additions & 2 deletions cooperator/wizard/partner_create_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 6633e88

Please sign in to comment.