Skip to content
Snippets Groups Projects
Commit 76131748 authored by Richard Mathot's avatar Richard Mathot
Browse files

[FIX] iap: avoid a crash when multiple accounts are found


Before the fix, if you had multiple accounts for a specific service, the
settings page was crashing.
(eg: for a service, you have one account specific to a company and
another account with no company set).

We now prefer accounts specific to the current company and tie-break on
the most recently created one

opw-2003744

closes odoo/odoo#33736

Signed-off-by: default avatarPierre Rousseau (pro) <pro@odoo.com>
parent edf90bb1
Branches
Tags
No related merge requests found
......@@ -162,7 +162,7 @@ class IapAccount(models.Model):
@api.model
def get(self, service_name, force_create=True):
account = self.search([('service_name', '=', service_name), ('company_id', 'in', [self.env.user.company_id.id, False])])
account = self.search([('service_name', '=', service_name), ('company_id', 'in', [self.env.user.company_id.id, False])], limit=1, order='company_id desc, id desc')
if not account and force_create:
account = self.create({'service_name': service_name})
# Since the account did not exist yet, we will encounter a NoCreditError,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment