|
12 | 12 | import logging
|
13 | 13 | import re
|
14 | 14 | import warnings
|
| 15 | +from ast import literal_eval |
15 | 16 |
|
16 | 17 | import psycopg2
|
17 | 18 | from psycopg2 import sql
|
|
25 | 26 | try:
|
26 | 27 | from odoo import release
|
27 | 28 | from odoo.tools.misc import mute_logger
|
28 |
| - from odoo.tools.safe_eval import safe_eval |
29 | 29 | except ImportError:
|
30 | 30 | from openerp import release
|
31 | 31 | from openerp.tools.misc import mute_logger
|
32 |
| - from openerp.tools.safe_eval import safe_eval |
33 | 32 |
|
34 | 33 | from .domains import FALSE_LEAF, TRUE_LEAF
|
35 | 34 |
|
@@ -117,7 +116,7 @@ def _remove_field_from_filters(cr, model, field):
|
117 | 116 | [model, r"\y{}\y".format(field)],
|
118 | 117 | )
|
119 | 118 | for id_, name, context_s in cr.fetchall():
|
120 |
| - context = safe_eval(context_s or "{}", SelfPrintEvalContext(), nocopy=True) |
| 119 | + context = SelfPrintEvalContext().safe_eval(context_s or "{}") |
121 | 120 | changed = _remove_field_from_context(context, field)
|
122 | 121 | cr.execute("UPDATE ir_filters SET context = %s WHERE id = %s", [unicode(context), id_])
|
123 | 122 | if changed:
|
@@ -206,7 +205,7 @@ def remove_field(cr, model, fieldname, cascade=False, drop_column=True, skip_inh
|
206 | 205 |
|
207 | 206 | # clean dashboard's contexts
|
208 | 207 | for id_, action in _dashboard_actions(cr, r"\y{}\y".format(fieldname), model):
|
209 |
| - context = safe_eval(action.get("context", "{}"), SelfPrintEvalContext(), nocopy=True) |
| 208 | + context = SelfPrintEvalContext().safe_eval(action.get("context", "{}")) |
210 | 209 | changed = _remove_field_from_context(context, fieldname)
|
211 | 210 | action.set("context", unicode(context))
|
212 | 211 | if changed:
|
@@ -350,7 +349,7 @@ def adapter(leaf, is_or, negated):
|
350 | 349 | )
|
351 | 350 | for alias_id, defaults_s in cr.fetchall():
|
352 | 351 | try:
|
353 |
| - defaults = dict(safe_eval(defaults_s)) # XXX literal_eval should works. |
| 352 | + defaults = dict(literal_eval(defaults_s)) |
354 | 353 | except Exception:
|
355 | 354 | continue
|
356 | 355 | defaults.pop(fieldname, None)
|
@@ -1387,7 +1386,7 @@ def adapt_dict(d):
|
1387 | 1386 | adapt_dict(d[vt])
|
1388 | 1387 |
|
1389 | 1388 | for _, act in _dashboard_actions(cr, match, *only_models or ()):
|
1390 |
| - context = safe_eval(act.get("context", "{}"), eval_context, nocopy=True) |
| 1389 | + context = eval_context.safe_eval(act.get("context", "{}")) |
1391 | 1390 | adapt_dict(context)
|
1392 | 1391 |
|
1393 | 1392 | if def_old in context:
|
|
0 commit comments