diff --git a/addons/iap/models/iap.py b/addons/iap/models/iap.py index 3bd79296faa..eb235a0ab5f 100644 --- a/addons/iap/models/iap.py +++ b/addons/iap/models/iap.py @@ -186,8 +186,10 @@ class IapAccount(models.Model): account = IapAccount.create({'service_name': service_name}) # fetch 'account_token' into cache with this cursor, # as self's cursor cannot see this account - account.account_token - return self.browse(account.id) + account_token = account.account_token + account = self.browse(account.id) + self.env.cache.set(account, IapAccount._fields['account_token'], account_token) + return account accounts_with_company = accounts.filtered(lambda acc: acc.company_ids) if accounts_with_company: return accounts_with_company[0] diff --git a/addons/iap/tests/__init__.py b/addons/iap/tests/__init__.py new file mode 100644 index 00000000000..3c032a13d8b --- /dev/null +++ b/addons/iap/tests/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import test_iap diff --git a/addons/iap/tests/test_iap.py b/addons/iap/tests/test_iap.py new file mode 100644 index 00000000000..64ffaeaf598 --- /dev/null +++ b/addons/iap/tests/test_iap.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo.tests.common import TransactionCase + + +class TestIAP(TransactionCase): + def test_get_account(self): + account = self.env["iap.account"].get("random_service_name") + self.assertTrue(account.account_token, "Must be able to read the field")