summaryrefslogtreecommitdiff
path: root/addons/google_drive
diff options
context:
space:
mode:
authorYannick Tivisse <yti@odoo.com>2021-01-05 12:40:58 +0000
committerYannick Tivisse <yti@odoo.com>2021-01-06 17:29:12 +0000
commit1e1f55b07790ca31f7fbf43b38bb99644d3a2e93 (patch)
tree497062e852706f787db33d02c85ef322ed1de640 /addons/google_drive
parent1ecc79992cf9842777883c7ea4ba8f477fea7b0f (diff)
Revert "[FIX] google_drive: fix traceback when add filter"
This reverts commit 82f236d98e322efd84c873df54f8e728e1d2a1bf. The fix is actually not solving all the issues, and also introduce a behavior change. Actually, the expected result for filters like <filter string="My Pipeline" name="my" domain="[('user_id', '=', uid)]"/> will result into a evaluated filters, but invalid as the uid is set to the person configuring the google configuration, not the user who will use it. As it is tricky (or even impossible) to solve the issue properly in all the cases, we prefer to warn the user that the filter is invalid instead. closes odoo/odoo#64144 X-original-commit: 35fff5d26f20ad5cfacffaf9335fc8580a7f4793 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/google_drive')
-rw-r--r--addons/google_drive/i18n/google_drive.pot6
-rw-r--r--addons/google_drive/models/google_drive.py8
2 files changed, 13 insertions, 1 deletions
diff --git a/addons/google_drive/i18n/google_drive.pot b/addons/google_drive/i18n/google_drive.pot
index b6a61e4e162..86ab6983669 100644
--- a/addons/google_drive/i18n/google_drive.pot
+++ b/addons/google_drive/i18n/google_drive.pot
@@ -133,6 +133,12 @@ msgid "Creating google drive may only be done by one at a time."
msgstr ""
#. module: google_drive
+#: code:addons/google_drive/models/google_drive.py:161
+#, 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:ir.filters,name:google_drive.filter_partner
msgid "Customer"
msgstr ""
diff --git a/addons/google_drive/models/google_drive.py b/addons/google_drive/models/google_drive.py
index fc641c04c7f..6e3eeb9c79e 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:
@@ -218,6 +221,9 @@ class GoogleDrive(models.Model):
def _check_model_id(self):
if self.filter_id and self.model_id.model != self.filter_id.model_id:
return False
+ 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)
return True
def get_google_scope(self):