Skip to content
Snippets Groups Projects
Commit b87db84c authored by Martin Trigaux's avatar Martin Trigaux
Browse files

[FIX] ir_values: try to evaluate the given expression before saving it in pickle form (opw 607398)

The value_unpickled given by xml data is usualy already evaluated but when it is given by the web client, a str is recieved by the method (as the field is a text field). In the later case, we need to evaluate the field before storing to be correctly evaluated as a default value.

bzr revid: mat@openerp.com-20140509130412-ki211x7qdccdnv5w
parents 3a0b6394 1aaebff0
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@ import pickle
from openerp.osv import osv, fields
from openerp.osv.orm import except_orm
from openerp.tools.safe_eval import safe_eval as eval
EXCLUDED_FIELDS = set((
'report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml',
......@@ -121,7 +122,13 @@ class ir_values(osv.osv):
record = self.browse(cursor, user, id, context=context)
if record.key == 'default':
# default values are pickled on the fly
value = pickle.dumps(value)
if isinstance(value, (str, unicode)):
try:
value = pickle.dumps(eval(value))
except Exception:
value = pickle.dumps(value)
else:
value = pickle.dumps(value)
self.write(cursor, user, id, {name[:-9]: value}, context=ctx)
def onchange_object_id(self, cr, uid, ids, object_id, context=None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment