diff --git a/addons/google_drive/i18n/google_drive.pot b/addons/google_drive/i18n/google_drive.pot index e13014f9c83..883d1cccf6f 100644 --- a/addons/google_drive/i18n/google_drive.pot +++ b/addons/google_drive/i18n/google_drive.pot @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server saas~14.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-12-11 07:29+0000\n" -"PO-Revision-Date: 2020-12-11 07:29+0000\n" +"POT-Creation-Date: 2021-01-12 10:19+0000\n" +"PO-Revision-Date: 2021-01-12 10:19+0000\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -295,6 +295,14 @@ msgstr "" msgid "The URL to generate the authorization code from Google" msgstr "" +#. module: google_drive +#: code:addons/google_drive/models/google_drive.py:0 +#, python-format +msgid "" +"The document filter must not include any 'dynamic' part, so it should not be" +" based on the current time or current user, for example." +msgstr "" + #. module: google_drive #: model_terms:ir.ui.view,arch_db:google_drive.view_google_drive_config_form msgid "" diff --git a/addons/google_drive/models/google_drive.py b/addons/google_drive/models/google_drive.py index d3fe8b18740..b8b8aff5bea 100644 --- a/addons/google_drive/models/google_drive.py +++ b/addons/google_drive/models/google_drive.py @@ -165,7 +165,10 @@ class GoogleDrive(models.Model): if config.filter_id.user_id and config.filter_id.user_id.id != self.env.user.id: #Private continue - domain = [('id', 'in', [res_id])] + ast.literal_eval(config.filter_id.domain) + try: + domain = [('id', 'in', [res_id])] + ast.literal_eval(config.filter_id.domain) + except: + raise UserError(_("The document filter must not include any 'dynamic' part, so it should not be based on the current time or current user, for example.")) additionnal_context = ast.literal_eval(config.filter_id.context) google_doc_configs = self.env[config.filter_id.model_id].with_context(**additionnal_context).search(domain) if google_doc_configs: @@ -222,6 +225,9 @@ class GoogleDrive(models.Model): "Incoherent Google Drive %(drive)s: the model of the selected filter %(filter)r is not matching the model of current template (%(filter_model)r, %(drive_model)r)", drive=drive.name, filter=drive.filter_id.name, filter_model=drive.filter_id.model_id.model, drive_model=drive.model_id.model, )) + if self.model_id.model and self.filter_id: + # force an execution of the filter to verify compatibility + self.get_google_drive_config(self.model_id.model, 1) def get_google_scope(self): return 'https://www.googleapis.com/auth/drive https://www.googleapis.com/auth/drive.file'