[FIX] auth_oauth: don't assume that google and facebook providers always exist

Before this commit, it was not possible to reach the general settings when one
of the "default" provider was delete.
After this commit, we don't assume anymore that there are google and facebook
providers.

opw-746907
This commit is contained in:
fwi-odoo 2017-06-12 13:53:19 +02:00 committed by Nicolas Martinelli
parent ed61da6793
commit 06141c34a5
1 changed files with 4 additions and 4 deletions

View File

@ -45,10 +45,10 @@ class base_config_settings(osv.TransientModel):
rg = self.pool.get('auth.oauth.provider').read(cr, uid, [google_id], ['enabled','client_id'], context=context)
rf = self.pool.get('auth.oauth.provider').read(cr, uid, [facebook_id], ['enabled','client_id'], context=context)
return {
'auth_oauth_google_enabled': rg[0]['enabled'],
'auth_oauth_google_client_id': rg[0]['client_id'],
'auth_oauth_facebook_enabled': rf[0]['enabled'],
'auth_oauth_facebook_client_id': rf[0]['client_id'],
'auth_oauth_google_enabled': rg[0]['enabled'] if rg else False,
'auth_oauth_google_client_id': rg[0]['client_id'] if rg else False,
'auth_oauth_facebook_enabled': rf[0]['enabled'] if rf else False,
'auth_oauth_facebook_client_id': rf[0]['client_id'] if rf else False,
}
def set_oauth_providers(self, cr, uid, ids, context=None):