10000 [FW][FIX] *: domain field: option allow_expressions by fw-bot · Pull Request #210145 · odoo/odoo · GitHub
[go: up one dir, main page]

Skip to content

[FW][FIX] *: domain field: option allow_expressions #210145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

fw-bot
Copy link
Contributor
@fw-bot fw-bot commented May 15, 2025

Some views use a domain widget to edit/save a domain and use it afterwards in several places where domains must have literals only. Typically, a literal_eval is used to evaluate the (string) domain. Thus expressions like "uid" or "context_today()"" should not be used in those contexts.
Here we introduce an option "allow_expressions" (default False) for the domain field and use it to mark as invalid domains that contain expressions when the option is set to False. A notification is displayed when a domain contains an unwanted expressions.

Since we cannot expect modules like base to be updated, we have to find another system to allow the usage of expressions in the form views for the models ir.filters and base.automation: we simply hardcode those models as allowing expressions. Since for these models, the evaluation of domains is done via safe_eval but with a restricted evaluation context, we also display a notification that alerts the user that the evaluation of expressions (although accepted by the domain field) can fail.

We revert the recent commit a678755 that introduced potentially problematic calls to safe_eval in order to allow evaluation of expressions.

Forward-Port-Of: #209960
Forward-Port-Of: #208876

Another fix is added here:

The domain field passes a new prop allowExpressions to the domain selector. If that prop is false (default true), the within operator is not proposed for selection for date/datetime fields. This is done to prevent users to introduce expressions in their domains when they are not supported.

@robodoo
Copy link
Contributor
robodoo commented May 15, 2025

Pull request status dashboard

@robodoo robodoo added forwardport This PR was created by @fw-bot conflict There was an error while creating this forward-port PR labels May 15, 2025
@fw-bot
Copy link
Contributor Author
fw-bot commented May 15, 2025

@Polymorphe57 @aab-odoo cherrypicking of pull request #208876 failed.

stdout:

Auto-merging addons/mail/tools/parser.py
CONFLICT (content): Merge conflict in addons/mail/tools/parser.py
Auto-merging addons/web/i18n/web.pot
Auto-merging addons/web/static/src/core/tree_editor/condition_tree.js
Auto-merging addons/web/static/src/views/fields/domain/domain_field.js
CONFLICT (content): Merge conflict in addons/web/static/src/views/fields/domain/domain_field.js
Auto-merging addons/web/static/tests/core/domain_field.test.js
CONFLICT (content): Merge conflict in addons/web/static/tests/core/domain_field.test.js
Auto-merging addons/website/controllers/model_page.py

Either perform the forward-port manually (and push to this branch, proceeding as usual) or close this PR (maybe?).

In the former case, you may want to edit this PR message as well.

⚠️ after resolving this conflict, you will need to merge it via @robodoo.

More info at https://github.com/odoo/odoo/wiki/Mergebot#forward-port

@C3POdoo C3POdoo added the RD research & development, internal work label May 15, 2025
@Polymorphe57 Polymorphe57 force-pushed the 18.0-17.0-literal-mode-for-domain-field-dam-436114-fw branch 3 times, most recently from 841b92f to ab457af Compare May 16, 2025 11:26
@C3POdoo C3POdoo requested review from a team, aab-odoo and kebeclibre and removed request for a team May 16, 2025 11:26
@Polymorphe57 Polymorphe57 force-pushed the 18.0-17.0-literal-mode-for-domain-field-dam-436114-fw branch from ab457af to 678a0fa Compare May 16, 2025 11:29
Some views use a domain widget to edit/save a domain and use it
afterwards in several places where domains must have literals only.
Typically, a literal_eval is used to evaluate the (string) domain. Thus
expressions like "uid" or "context_today()"" should not be used in those
contexts.
Here we introduce an option "allow_expressions" (default False) for the
domain field and use it to mark as invalid domains that contain
expressions when the option is set to False. A notification is displayed
when a domain contains an unwanted expressions.

Since we cannot expect modules like base to be updated, we have to find
another system to allow the usage of expressions in the form views for
the models ir.filters and base.automation: we simply hardcode those
models as allowing expressions. Since for these models, the evaluation
of domains is done via safe_eval but with a restricted evaluation
context, we also display a notification that alerts the user that the
evaluation of expressions (although accepted by the domain field) can
fail.

We revert the recent commit odoo@f95c494 that introduced potentially
problematic calls to safe_eval in order to allow evaluation of
expressions.

Forward-port-of: odoo#208876
X-original-commit: 329867a
@Polymorphe57 Polymorphe57 force-pushed the 18.0-17.0-literal-mode-for-domain-field-dam-436114-fw branch 5 times, most recently from 6fc45ae to a036f18 Compare May 16, 2025 12:03
The domain field passes a new prop allowExpressions to the domain
selector. If that prop is false (default true), the within operator is
not proposed for selection for date/datetime fields. This is done to
prevent users to introduce expressions in their domains when they are
not supported.
@Polymorphe57 Polymorphe57 force-pushed the 18.0-17.0-literal-mode-for-domain-field-dam-436114-fw branch from a036f18 to e287f35 Compare May 16, 2025 12:04
@Polymorphe57
Copy link
Contributor

@robodoo r+

@robodoo
Copy link
Contributor
robodoo commented May 16, 2025

@Polymorphe57 @aab-odoo because this PR has multiple commits, I need to know how to merge it:

  • merge to merge directly, using the PR as merge commit message
  • rebase-merge to rebase and merge, using the PR as merge commit message
  • rebase-ff to rebase and fast-forward

@Polymorphe57
Copy link
Contributor

robodoo rebase-ff

@robodoo
Copy link
Contributor
robodoo commented May 16, 2025

Merge method set to rebase and fast-forward.

robodoo pushed a commit that referenced this pull request May 17, 2025
Some views use a domain widget to edit/save a domain and use it
afterwards in several places where domains must have literals only.
Typically, a literal_eval is used to evaluate the (string) domain. Thus
expressions like "uid" or "context_today()"" should not be used in those
contexts.
Here we introduce an option "allow_expressions" (default False) for the
domain field and use it to mark as invalid domains that contain
expressions when the option is set to False. A notification is displayed
when a domain contains an unwanted expressions.

Since we cannot expect modules like base to be updated, we have to find
another system to allow the usage of expressions in the form views for
the models ir.filters and base.automation: we simply hardcode those
models as allowing expressions. Since for these models, the evaluation
of domains is done via safe_eval but with a restricted evaluation
context, we also display a notification that alerts the user that the
evaluation of expressions (although accepted by the domain field) can
fail.

We revert the recent commit f95c494 that introduced potentially
problematic calls to safe_eval in order to allow evaluation of
expressions.

Forward-port-of: #208876
X-original-commit: 329867a
Part-of: #210145
Related: odoo/enterprise#85620
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
@robodoo robodoo closed this in e22a5a3 May 17, 2025
acsonefho pushed a commit to acsone/odoo that referenced this pull request May 19, 2025
Some views use a domain widget to edit/save a domain and use it
afterwards in several places where domains must have literals only.
Typically, a literal_eval is used to evaluate the (string) domain. Thus
expressions like "uid" or "context_today()"" should not be used in those
contexts.
Here we introduce an option "allow_expressions" (default False) for the
domain field and use it to mark as invalid domains that contain
expressions when the option is set to False. A notification is displayed
when a domain contains an unwanted expressions.

Since we cannot expect modules like base to be updated, we have to find
another system to allow the usage of expressions in the form views for
the models ir.filters and base.automation: we simply hardcode those
models as allowing expressions. Since for these models, the evaluation
of domains is done via safe_eval but with a restricted evaluation
context, we also display a notification that alerts the user that the
evaluation of expressions (although accepted by the domain field) can
fail.

We revert the recent commit odoo@f95c494 that introduced potentially
problematic calls to safe_eval in order to allow evaluation of
expressions.

Forward-port-of: odoo#208876
X-original-commit: 329867a
Part-of: odoo#210145
Related: odoo/enterprise#85620
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
acsonefho pushed a commit to acsone/odoo that referenced this pull request May 19, 2025
The domain field passes a new prop allowExpressions to the domain
selector. If that prop is false (default true), the within operator is
not proposed for selection for date/datetime fields. This is done to
prevent users to introduce expressions in their domains when they are
not supported.

closes odoo#210145

Related: odoo/enterprise#85620
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
@fw-bot fw-bot deleted the 18.0-17.0-literal-mode-for-domain-field-dam-436114-fw branch May 24, 2025 04:11
ThomasSchneider-94 pushed a commit to odoo-dev/odoo that referenced this pull request Jun 4, 2025
Some views use a domain widget to edit/save a domain and use it
afterwards in several places where domains must have literals only.
Typically, a literal_eval is used to evaluate the (string) domain. Thus
expressions like "uid" or "context_today()"" should not be used in those
contexts.
Here we introduce an option "allow_expressions" (default False) for the
domain field and use it to mark as invalid domains that contain
expressions when the option is set to False. A notification is displayed
when a domain contains an unwanted expressions.

Since we cannot expect modules like base to be updated, we have to find
another system to allow the usage of expressions in the form views for
the models ir.filters and base.automation: we simply hardcode those
models as allowing expressions. Since for these models, the evaluation
of domains is done via safe_eval but with a restricted evaluation
context, we also display a notification that alerts the user that the
evaluation of expressions (although accepted by the domain field) can
fail.

We revert the recent commit odoo@f95c494 that introduced potentially
problematic calls to safe_eval in order to allow evaluation of
expressions.

Forward-port-of: odoo#208876
X-original-commit: 329867a
Part-of: odoo#210145
Related: odoo/enterprise#85620
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
ThomasSchneider-94 pushed a commit to odoo-dev/odoo that referenced this pull request Jun 4, 2025
The domain field passes a new prop allowExpressions to the domain
selector. If that prop is false (default true), the within operator is
not proposed for selection for date/datetime fields. This is done to
prevent users to introduce expressions in their domains when they are
not supported.

closes odoo#210145

Related: odoo/enterprise#85620
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
gamarino pushed a commit to numaes/numa-public-odoo that referenced this pull request Jun 4, 2025
Some views use a domain widget to edit/save a domain and use it
afterwards in several places where domains must have literals only.
Typically, a literal_eval is used to evaluate the (string) domain. Thus
expressions like "uid" or "context_today()"" should not be used in those
contexts.
Here we introduce an option "allow_expressions" (default False) for the
domain field and use it to mark as invalid domains that contain
expressions when the option is set to False. A notification is displayed
when a domain contains an unwanted expressions.

Since we cannot expect modules like base to be updated, we have to find
another system to allow the usage of expressions in the form views for
the models ir.filters and base.automation: we simply hardcode those
models as allowing expressions. Since for these models, the evaluation
of domains is done via safe_eval but with a restricted evaluation
context, we also display a notification that alerts the user that the
evaluation of expressions (although accepted by the domain field) can
fail.

We revert the recent commit odoo/odoo@f95c494 that introduced potentially
problematic calls to safe_eval in order to allow evaluation of
expressions.

Forward-port-of: #208876
X-original-commit: 329867ade9a6767388511b81fd0cb298a720657e
Part-of: odoo/odoo#210145
Related: odoo/enterprise#85620
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
gamarino pushed a commit to numaes/numa-public-odoo that referenced this pull request Jun 4, 2025
The domain field passes a new prop allowExpressions to the domain
selector. If that prop is false (default true), the within operator is
not proposed for selection for date/datetime fields. This is done to
prevent users to introduce expressions in their domains when they are
not supported.

closes odoo/odoo#210145

Related: odoo/enterprise#85620
Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
Signed-off-by: Mathieu Duckerts-Antoine (dam) <dam@odoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conflict There was an error while creating this forward-port PR forwardport This PR was created by @fw-bot RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0