odoo/enterprise#84713

Created by fw-bot
Closed
label
odoo-dev:master-17.0-opw-4577091-safe_eval_is_within-abz-433584-fw
head
f771d1fe69620216c4071301092882ab6c146590
odoo/odoo odoo/enterprise
17.0 #204172 #82564
saas-17.4 #206507 #83635
18.0 #206708 #83738
saas-18.1 #207558 #84174
saas-18.2 #207601 #84203
saas-18.3 #208479 #84703
master #208491 #84713

[FW][FIX] marketing_automation, web_studio: Supports dynamic domain

Similar to: odoo/odoo#184830

We've recently introduced a new operator: “is within” in the domain
selector, which can be used to find out whether a date is within a
dynamic range (e.g. within a month, within 4 days, within 3 weeks, etc.).
To works, this domain needs dynamic elements, such as context_today,
which is defined in py_builtin.js and dynamically retrieves the
current date.

https://github.com/odoo/odoo/blob/17.0/addons/web/static/src/core/py_js/py_builtin.js#L77-L79

However, the problem isn't limited to this operator in the selector
domain, as it's only been available since 18.0, and this pr target is
17.0.s

In fact, it is possible in certain cases to use these fields via debug
mode, and there are several cases where uid, user, etc. are used.
There is therefore an inconsistency where users see the use of these
variables in these cases and when they try to use them elsewhere with,
for example, a field of this style:

("date", "=", context_today()), they get a traceback.
This happens mainly because, in Python, the domain is evaluated via
literal_eval, and since it contains variables that are designed for
the web, it causes a traceback because this function expects to receive
only a correctly formatted string, with no context and no variables.

The community commit (odoo/odoo#204172) handles:
- website/model_page.py:
https://github.com/odoo/odoo/blob/17.0/addons/website/controllers/model_page.py#L13-L18

https://github.com/odoo/odoo/blob/17.0/addons/website/controllers/model_page.py#L47-L50

This commit
handles two other cases:

In all three cases, the problem is the same: the problem is not only
present in is_within but in the fact that python has no way of
understanding the domain received from the web, so the same fix has been
applied everywhere:

opw-4551335
opw-4672902
opw-4678894
opw-4669315
opw-4577091

community: odoo/odoo#204172

Forward-Port-Of: #84203
Forward-Port-Of: #82564