From 921fab992d51ce381b57798886ff1ede4caf89c7 Mon Sep 17 00:00:00 2001 From: David Dufresne <27902736+ddufresne@users.noreply.github.com> Date: Fri, 19 Jul 2019 14:46:40 +0000 Subject: [PATCH] [FIX] google_drive: do not reset refresh_token MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When setting the authorization code, a refresh token is generated in the background and stored in a system parameter. However, when saving the general settings (res.config.settings) without changing the authorization code, the refresh token is deleted. The refresh token should only be deleted if the authorization was removed. This was not the case as the set_param is always called and a value is only computed when the authorization code has changed. The current value was never retrieved. Set a ir.config_parameter only when it a value has changed. closes odoo/odoo#35028 Signed-off-by: Jérome Maes (jem) --- addons/google_drive/models/res_config_settings.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/addons/google_drive/models/res_config_settings.py b/addons/google_drive/models/res_config_settings.py index f2175d27e57..eff6e43bc0f 100644 --- a/addons/google_drive/models/res_config_settings.py +++ b/addons/google_drive/models/res_config_settings.py @@ -21,7 +21,9 @@ class ResConfigSettings(models.TransientModel): authorization_code_before = params.get_param('google_drive_authorization_code') super(ResConfigSettings, self).set_values() authorization_code = self.google_drive_authorization_code - refresh_token = False - if authorization_code and authorization_code != authorization_code_before: - refresh_token = self.env['google.service'].generate_refresh_token('drive', authorization_code) - params.set_param('google_drive_refresh_token', refresh_token) + if authorization_code != authorization_code_before: + refresh_token = ( + self.env['google.service'].generate_refresh_token('drive', authorization_code) + if authorization_code else False + ) + params.set_param('google_drive_refresh_token', refresh_token)