From c6464dad169f485424fb932cf6abe46aea198d3c Mon Sep 17 00:00:00 2001 From: "robin.keunen" Date: Mon, 7 Oct 2019 16:54:42 +0200 Subject: [PATCH] [IMP] emc: add user error if cooperator account is not set --- easy_my_coop/models/coop.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/easy_my_coop/models/coop.py b/easy_my_coop/models/coop.py index df95c26..a88c472 100644 --- a/easy_my_coop/models/coop.py +++ b/easy_my_coop/models/coop.py @@ -404,7 +404,13 @@ class SubscriptionRequest(models.Model): if self.company_id.property_cooperator_account: account = self.company_id.property_cooperator_account else: - account = account_obj.search([('code', '=', '416000')])[0] + accounts = account_obj.search([('code', '=', '416000')]) + if accounts: + account = accounts[0] + else: + raise UserError(_( + 'You must set a cooperator account on you company.' + )) return account def get_invoice_vals(self, partner):