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#66042
X-original-commit: 5df2c1d10318cc53f1c3e90256cba6a48d246dcb
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
This commit is contained in:
committed by
Martin Trigaux
parent
b986b116da
commit
60aa239897
@@ -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 ""
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user