summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic/basic_controller.js
diff options
context:
space:
mode:
authorstd-odoo <std@odoo.com>2020-06-18 06:33:42 +0000
committerstd-odoo <std@odoo.com>2020-06-19 12:49:07 +0000
commit91b61d5cd501c4318c69a6ba0078e5ad1d83d9ef (patch)
treefa22df9c7e014c184e84f1be6ed8b3d76365eda2 /addons/web/static/src/js/views/basic/basic_controller.js
parent7394a68224e9d53761e5eae23408a1f1e19fab8f (diff)
[FIX] iap: fix IAP account creation
Bug === Install CRM, then go to the lead kanban view and try to generate leads. An error will be raised. Technical ========= In the "iap.account" model, in the `get` method, we can create the IAP account if it doesn't exist yet. Since 5307f47d975c3b3ebd87c7f7e2248802a1aa5be7 the operation is done in a different SQL cursor than the current one. The reason is that we need to commit the change, and committing the current SQL cursor can cause issue and break some flows (mainly if it's not done at the very beginning/end of the flow). In the current code, we cache the `account_token` to be able to read it with the current SQL cursor (otherwise, the current cursor has no access to the field because change has not yet being committing for it). But, the cache is invalidated when the "IAP account SQL cursor" is closed. ```python with self.pool.cursor() as cr: ... IapAccount = self.with_env(self.env(cr=cr)) account = IapAccount.search(domain, order='id desc', limit=1) if not account: if not force_create: return account 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 # <---- Cache is invalidated here ... ``` So we can not access the the field value after the invalidation. Solution ======== The solution is the store the `account_token` value before closing the "IAP account SQL cursor" and then, after closing it, we add it in the cache. Task-2277733 closes odoo/odoo#53323 X-original-commit: 32caf74ff10052d2a303fa24d5cc7b37538dd406 Signed-off-by: Rémi Rahir (rar) <rar@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_controller.js')
0 files changed, 0 insertions, 0 deletions