[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
This commit is contained in:
commit
b87db84c0d
|
@ -22,6 +22,7 @@ import pickle
|
||||||
|
|
||||||
from openerp.osv import osv, fields
|
from openerp.osv import osv, fields
|
||||||
from openerp.osv.orm import except_orm
|
from openerp.osv.orm import except_orm
|
||||||
|
from openerp.tools.safe_eval import safe_eval as eval
|
||||||
|
|
||||||
EXCLUDED_FIELDS = set((
|
EXCLUDED_FIELDS = set((
|
||||||
'report_sxw_content', 'report_rml_content', 'report_sxw', 'report_rml',
|
'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)
|
record = self.browse(cursor, user, id, context=context)
|
||||||
if record.key == 'default':
|
if record.key == 'default':
|
||||||
# default values are pickled on the fly
|
# 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)
|
self.write(cursor, user, id, {name[:-9]: value}, context=ctx)
|
||||||
|
|
||||||
def onchange_object_id(self, cr, uid, ids, object_id, context=None):
|
def onchange_object_id(self, cr, uid, ids, object_id, context=None):
|
||||||
|
|
Loading…
Reference in New Issue