odoo/odoo#233680

Created by fw-bot
Merged at c131396939ca2e59f480fd6dfa32c34e3fdf3a42

Statuses:

label
odoo-dev:saas-18.2-17-fix-oauth-not-found-issue-473829-fw
head
097a53b4bd9d917b0f8c3f9ee09ebfbf6971b9f4
merged
6 days ago by Framework (ORM), Xavier Morel (xmo)
odoo/odoo
17.0 #233633
18.0 #233675
saas-18.2 #233680
saas-18.3 #233689
saas-18.4 #233693
19.0 #233701
master #233704

[FIX] auth_oauth: Fix oauth provider reference to handle not found case

Description of the issue/feature this PR addresses:

When a user has deleted the Odoo Oauth provider, an error occurs when restoring the database.

Current behavior before PR:

You'll get this error:

odoo.service.db.restore_db(dbname, backup, copy, **extra_kwargs)
File "<decorator-gen-27>", line 2, in restore_db
File "/opt/ou/odoo/odoo/service/db.py", line 44, in if_db_mgt_enabled
return method(self, *args, **kwargs)
File "/opt/ou/odoo/odoo/service/db.py", line 360, in restore_db
env['ir.config_parameter'].init(force=True)
File "/opt/ou/odoo/addons/auth_oauth/models/ir_config_parameter.py", line 13, in init
oauth_oe = self.env.ref('auth_oauth.provider_openerp')
File "/opt/ou/odoo/odoo/api.py", line 611, in ref
res_model, res_id = self['ir.model.data']._xmlid_to_res_model_res_id(
File "/opt/ou/odoo/odoo/addons/base/models/ir_model.py", line 2059, in _xmlid_to_res_model_res_id
return self._xmlid_lookup(xmlid)[1:3]
File "<decorator-gen-43>", line 2, in _xmlid_lookup
File "/opt/ou/odoo/odoo/tools/cache.py", line 90, in lookup
value = d[key] = self.method(*args, **kwargs)
File "/opt/ou/odoo/odoo/addons/base/models/ir_model.py", line 2052, in _xmlid_lookup
raise ValueError('External ID not found in the system: %s' % xmlid)
ValueError: External ID not found in the system: auth_oauth.provider_openerp
Error: External ID not found in the system: auth_oauth.provider_openerp

Desired behavior after PR is merged:

No error will occur

The afflicted versions are AFAIK, 16.0, 17.0, 18.0, and 19.0


I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

Forward-Port-Of: #233633