Skip to content

Commit

Permalink
Merge pull request #280 from royleviindoo/fix_disable_invalid_filters
Browse files Browse the repository at this point in the history
[FIX] disable_invalid_filters: <module 'time' (built-in)> can not be used in evaluation contexts
  • Loading branch information
pedrobaeza authored Apr 28, 2022
2 parents 99c20f6 + faf7ec3 commit ad153a2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions openupgradelib/openupgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -2366,13 +2366,17 @@ def format_message(f):
columns = (
getattr(model, '_columns', False) or getattr(model, '_fields')
)

globaldict = {'uid': env.uid}
if version_info[0] < 14:
globaldict.update({'time': time})
# DOMAIN
try:
with savepoint(env.cr):
# Strange artifact found in a filter
domain = f.domain.replace('%%', '%')
model.search(
safe_eval(domain, {'time': time, 'uid': env.uid}),
safe_eval(domain, globaldict),
limit=1,
)
except Exception:
Expand All @@ -2383,7 +2387,7 @@ def format_message(f):
continue
# CONTEXT GROUP BY
try:
context = safe_eval(f.context, {'time': time, 'uid': env.uid})
context = safe_eval(f.context, globaldict)
assert(isinstance(context, dict))
except Exception:
logger.warning(
Expand Down

0 comments on commit ad153a2

Please sign in to comment.