From 2bf1af77fbb232c2e09059ea68a4b62fb7b582bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Rahir?= Date: Tue, 25 Sep 2018 13:06:29 +0000 Subject: [PATCH] [FIX] iap: fixing get() for non-amin users closes odoo/odoo#27219 --- addons/iap/models/iap.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/iap/models/iap.py b/addons/iap/models/iap.py index 6f24205f8d4..2f7053b7c74 100644 --- a/addons/iap/models/iap.py +++ b/addons/iap/models/iap.py @@ -146,7 +146,8 @@ class IapAccount(models.Model): def get(self, service_name): account = self.search([('service_name', '=', service_name), ('company_id', 'in', [self.env.user.company_id.id, False])]) if not account: - account = self.create({'service_name': service_name}) + # TODO: remove this sudo in v12 as we change the user rights. + account = self.sudo().create({'service_name': service_name}).with_env(self.env) # Since the account did not exist yet, we will encounter a NoCreditError, # which is going to rollback the database and undo the account creation, # preventing the process to continue any further.