diff --git a/addons/iap/models/iap.py b/addons/iap/models/iap.py
index a36a741b1a33255c8b9e2a2f9f1999896ac03461..a89f501ec041f5f828115d5184cfec3fd25805f9 100644
--- a/addons/iap/models/iap.py
+++ b/addons/iap/models/iap.py
@@ -171,6 +171,17 @@ class IapAccount(models.Model):
                 ('company_ids', '=', False)
         ]
         accounts = self.search(domain, order='id desc')
+        accounts_without_token = accounts.filtered(lambda acc: not acc.account_token)
+        if accounts_without_token:
+            with self.pool.cursor() as cr:
+                # In case of a further error that will rollback the database, we should
+                # use a different SQL cursor to avoid undo the accounts deletion.
+
+                # Flush the pending operations to avoid a deadlock.
+                self.flush()
+                IapAccount = self.with_env(self.env(cr=cr))
+                IapAccount.search(domain + [('account_token', '=', False)]).unlink()
+                accounts = accounts - accounts_without_token
         if not accounts:
             with self.pool.cursor() as cr:
                 # Since the account did not exist yet, we will encounter a NoCreditError,