Fix import data for selection field where selection is a function

bzr revid: ced-8dd3ea98c4f9874cd442505c3e30628ccdd7edb1
This commit is contained in:
ced 2007-10-16 06:27:28 +00:00
parent 1a9e1e798f
commit ffb8d85d0a
1 changed files with 11 additions and 3 deletions

View File

@ -655,11 +655,19 @@ class orm(object):
res =line[i] and float(line[i])
elif fields_def[field[len(prefix)]]['type']=='selection':
res = False
for key,val in fields_def[field[len(prefix)]]['selection']:
if key==line[i]: #val==line[i] if from the client !
if isinstance(fields_def[field[len(prefix)]]['selection'],
(tuple, list)):
sel = fields_def[field[len(prefix)]]['selection']
else:
sel = fields_def[field[len(prefix)]]['selection'](self,
cr, uid, context)
for key, val in sel:
if key == line[i]:
res = key
if line[i] and not res:
logger.notifyChannel("import", netsvc.LOG_WARNING, "key '%s' not found in selection field '%s'" %(line[i], field[len(prefix)]))
logger.notifyChannel("import", netsvc.LOG_WARNING,
"key '%s' not found in selection field '%s'" % \
(line[i], field[len(prefix)]))
elif fields_def[field[len(prefix)]]['type']=='many2one':
res = False
if line[i]: