[MERGE] OPW 574360: yaml_import: properly handle x2m default values

bzr revid: odo@openerp.com-20120625161954-pl0ma1kilq599yxe
This commit is contained in:
Olivier Dony
2012-06-25 18:19:54 +02:00
+8 -5
View File
@@ -366,14 +366,17 @@ class YamlInterpreter(object):
fields = fields or {}
def process_val(key, val):
if fg[key]['type']=='many2one':
if fg[key]['type'] == 'many2one':
if type(val) in (tuple,list):
val = val[0]
elif (fg[key]['type']=='one2many'):
if val is False:
val = []
if len(val) and type(val[0]) == dict:
elif fg[key]['type'] == 'one2many':
if val and isinstance(val,(list,tuple)) and \
isinstance(val[0], dict):
val = map(lambda x: (0,0,x), val)
elif fg[key]['type'] == 'many2many':
if val and isinstance(val,(list,tuple)) and \
isinstance(val[0], (int,long)):
val = [(6,0,val)]
return val
# Process all on_change calls