1 #----------------------------------------------------------
3 #----------------------------------------------------------
5 import StringIO,xml.dom.minidom
13 from config import config
17 class ConvertError(Exception):
18 def __init__(self, doc, orig_excpt):
20 self.orig = orig_excpt
23 return 'Exception:\n\t%s\nUsing file:\n%s' % (self.orig, self.d)
26 return lambda x: self.id_get(cr, False, x)
28 def _obj(pool, cr, uid, model_str, context=None):
29 model = pool.get(model_str)
30 return lambda x: model.browse(cr, uid, x, context=context)
32 def _eval_xml(self,node, pool, cr, uid, idref, context=None):
35 if node.nodeType == node.TEXT_NODE:
36 return node.data.encode("utf8")
37 elif node.nodeType == node.ELEMENT_NODE:
38 if node.nodeName in ('field','value'):
39 t = node.getAttribute('type') or 'char'
40 f_model = node.getAttribute("model").encode('ascii')
41 if len(node.getAttribute('search')):
42 f_search = node.getAttribute("search").encode('utf-8')
43 f_use = node.getAttribute("use").encode('ascii')
44 f_name = node.getAttribute("name").encode('utf-8')
47 q = eval(f_search, idref)
48 ids = pool.get(f_model).search(cr, uid, q)
50 ids = map(lambda x: x[f_use], pool.get(f_model).read(cr, uid, ids, [f_use]))
51 _cols = pool.get(f_model)._columns
52 if (f_name in _cols) and _cols[f_name]._type=='many2many':
57 if isinstance(f_val, tuple):
60 a_eval = node.getAttribute('eval')
65 idref['version'] = release.version.rsplit('.', 1)[0]
66 idref['ref'] = lambda x: self.id_get(cr, False, x)
68 idref['obj'] = _obj(self.pool, cr, uid, f_model, context=context)
72 logger = netsvc.Logger()
73 logger.notifyChannel("init", netsvc.LOG_INFO, 'could not find pytz library')
74 class pytzclass(object):
78 return eval(a_eval, idref)
80 def _process(s, idref):
81 m = re.findall('[^%]%\((.*?)\)[ds]', s)
84 idref[id]=self.id_get(cr, False, id)
86 txt = '<?xml version="1.0"?>\n'+_process("".join([i.toxml().encode("utf8") for i in node.childNodes]), idref)
87 # txt = '<?xml version="1.0"?>\n'+"".join([i.toxml().encode("utf8") for i in node.childNodes]) % idref
90 if t in ('char', 'int', 'float'):
92 for n in [i for i in node.childNodes]:
93 d+=str(_eval_xml(self,n,pool,cr,uid,idref))
103 elif t in ('list','tuple'):
105 for n in [i for i in node.childNodes if (i.nodeType == i.ELEMENT_NODE and i.nodeName=='value')]:
106 res.append(_eval_xml(self,n,pool,cr,uid,idref))
110 elif node.nodeName=="getitem":
111 for n in [i for i in node.childNodes if (i.nodeType == i.ELEMENT_NODE)]:
112 res=_eval_xml(self,n,pool,cr,uid,idref)
115 elif node.getAttribute('type') in ("int", "list"):
116 return res[int(node.getAttribute('index'))]
118 return res[node.getAttribute('index').encode("utf8")]
119 elif node.nodeName=="function":
121 a_eval = node.getAttribute('eval')
123 idref['ref'] = lambda x: self.id_get(cr, False, x)
124 args = eval(a_eval, idref)
125 for n in [i for i in node.childNodes if (i.nodeType == i.ELEMENT_NODE)]:
126 args.append(_eval_xml(self,n, pool, cr, uid, idref, context))
127 model = pool.get(node.getAttribute('model'))
128 method = node.getAttribute('name')
129 res = getattr(model, method)(cr, uid, *args)
131 elif node.nodeName=="test":
133 for n in [i for i in node.childNodes]:
134 d+=str(_eval_xml(self,n,pool,cr,uid,idref, context=context))
138 escape_re = re.compile(r'(?<!\\)/')
140 return x.replace('\\/', '/')
142 class assertion_report(object):
146 def record_assertion(self, success, severity):
148 Records the result of an assertion for the failed/success count
151 if severity in self._report:
152 self._report[severity][success] += 1
154 self._report[severity] = {success:1, not success: 0}
157 def get_report(self):
161 res = '\nAssertions report:\nLevel\tsuccess\tfailed\n'
163 for sev in self._report:
164 res += sev + '\t' + str(self._report[sev][True]) + '\t' + str(self._report[sev][False]) + '\n'
165 success += self._report[sev][True]
166 failed += self._report[sev][False]
167 res += 'total\t' + str(success) + '\t' + str(failed) + '\n'
168 res += 'end of report (' + str(success + failed) + ' assertion(s) checked)'
171 class xml_import(object):
173 def isnoupdate(self, data_node = None):
174 return self.noupdate or (data_node and data_node.getAttribute('noupdate'))
176 def get_context(self, data_node, node, eval_dict):
177 data_node_context = (data_node and data_node.getAttribute('context').encode('utf8'))
178 if data_node_context:
179 context = eval(data_node_context, eval_dict)
183 node_context = node.getAttribute("context").encode('utf8')
184 if len(node_context):
185 context.update(eval(node_context, eval_dict))
189 def get_uid(self, cr, uid, data_node, node):
190 node_uid = node.getAttribute('uid') or (data_node and data_node.getAttribute('uid'))
192 return self.id_get(cr, None, node_uid)
195 def _test_xml_id(self, xml_id):
198 base, id = xml_id.split('.')
200 self.logger.notifyChannel('init', netsvc.LOG_ERROR, 'id: %s is to long (max: 64)'%xml_id)
201 def _tag_delete(self, cr, rec, data_node=None):
202 d_model = rec.getAttribute("model")
203 d_search = rec.getAttribute("search")
204 d_id = rec.getAttribute("id")
207 ids = self.pool.get(d_model).search(cr,self.uid,eval(d_search))
209 ids.append(self.id_get(cr, d_model, d_id))
211 self.pool.get(d_model).unlink(cr, self.uid, ids)
212 #self.pool.get('ir.model.data')._unlink(cr, self.uid, d_model, ids, direct=True)
215 def _tag_report(self, cr, rec, data_node=None):
217 for dest,f in (('name','string'),('model','model'),('report_name','name')):
218 res[dest] = rec.getAttribute(f).encode('utf8')
219 assert res[dest], "Attribute %s of report is empty !" % (f,)
220 for field,dest in (('rml','report_rml'),('xml','report_xml'),('xsl','report_xsl')):
221 if rec.hasAttribute(field):
222 res[dest] = rec.getAttribute(field).encode('utf8')
223 if rec.hasAttribute('auto'):
224 res['auto'] = eval(rec.getAttribute('auto'))
225 if rec.hasAttribute('sxw'):
226 sxw_content = misc.file_open(rec.getAttribute('sxw')).read()
227 res['report_sxw_content'] = sxw_content
228 if rec.hasAttribute('header'):
229 res['header'] = eval(rec.getAttribute('header'))
230 res['multi'] = rec.hasAttribute('multi') and eval(rec.getAttribute('multi'))
231 xml_id = rec.getAttribute('id').encode('utf8')
232 self._test_xml_id(xml_id)
233 id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.report.xml", self.module, res, xml_id, mode=self.mode)
234 self.idref[xml_id] = int(id)
235 if not rec.hasAttribute('menu') or eval(rec.getAttribute('menu')):
236 keyword = str(rec.getAttribute('keyword') or 'client_print_multi')
237 keys = [('action',keyword),('res_model',res['model'])]
238 value = 'ir.actions.report.xml,'+str(id)
239 replace = rec.hasAttribute('replace') and rec.getAttribute("replace")
240 self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', keyword, res['name'], [res['model']], value, replace=replace, isobject=True, xml_id=xml_id)
243 def _tag_function(self, cr, rec, data_node=None):
244 if self.isnoupdate(data_node) and self.mode != 'init':
246 context = self.get_context(data_node, rec, {'ref': _ref(self, cr)})
247 uid = self.get_uid(cr, self.uid, data_node, rec)
248 _eval_xml(self,rec, self.pool, cr, uid, self.idref, context=context)
251 def _tag_wizard(self, cr, rec, data_node=None):
252 string = rec.getAttribute("string").encode('utf8')
253 model = rec.getAttribute("model").encode('utf8')
254 name = rec.getAttribute("name").encode('utf8')
255 xml_id = rec.getAttribute('id').encode('utf8')
256 self._test_xml_id(xml_id)
257 multi = rec.hasAttribute('multi') and eval(rec.getAttribute('multi'))
258 res = {'name': string, 'wiz_name': name, 'multi':multi}
260 id = self.pool.get('ir.model.data')._update(cr, self.uid, "ir.actions.wizard", self.module, res, xml_id, mode=self.mode)
261 self.idref[xml_id] = int(id)
263 if (not rec.hasAttribute('menu') or eval(rec.getAttribute('menu'))) and id:
264 keyword = str(rec.getAttribute('keyword') or 'client_action_multi')
265 keys = [('action',keyword),('res_model',model)]
266 value = 'ir.actions.wizard,'+str(id)
267 replace = rec.hasAttribute('replace') and rec.getAttribute("replace")
268 self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', keyword, string, [model], value, replace=replace, isobject=True, xml_id=xml_id)
271 def _tag_act_window(self, cr, rec, data_node=None):
272 name = rec.hasAttribute('name') and rec.getAttribute('name').encode('utf-8')
273 xml_id = rec.getAttribute('id').encode('utf8')
274 self._test_xml_id(xml_id)
275 type = rec.hasAttribute('type') and rec.getAttribute('type').encode('utf-8') or 'ir.actions.act_window'
277 if rec.hasAttribute('view'):
278 view_id = self.id_get(cr, 'ir.actions.act_window', rec.getAttribute('view').encode('utf-8'))
279 domain = rec.hasAttribute('domain') and rec.getAttribute('domain').encode('utf-8')
280 context = rec.hasAttribute('context') and rec.getAttribute('context').encode('utf-8') or '{}'
281 res_model = rec.getAttribute('res_model').encode('utf-8')
282 src_model = rec.hasAttribute('src_model') and rec.getAttribute('src_model').encode('utf-8')
283 view_type = rec.hasAttribute('view_type') and rec.getAttribute('view_type').encode('utf-8') or 'form'
284 view_mode = rec.hasAttribute('view_mode') and rec.getAttribute('view_mode').encode('utf-8') or 'tree,form'
285 usage = rec.hasAttribute('usage') and rec.getAttribute('usage').encode('utf-8')
287 res = {'name': name, 'type': type, 'view_id': view_id, 'domain': domain, 'context': context, 'res_model': res_model, 'src_model': src_model, 'view_type': view_type, 'view_mode': view_mode, 'usage': usage }
289 id = self.pool.get('ir.model.data')._update(cr, self.uid, 'ir.actions.act_window', self.module, res, xml_id, mode=self.mode)
290 self.idref[xml_id] = int(id)
293 keyword = 'client_action_relate'
294 keys = [('action', keyword), ('res_model', res_model)]
295 value = 'ir.actions.act_window,'+str(id)
296 replace = rec.hasAttribute('replace') and rec.getAttribute('replace')
297 self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', keyword, xml_id, [src_model], value, replace=replace, isobject=True, xml_id=xml_id)
298 # TODO add remove ir.model.data
301 def _tag_ir_set(self, cr, rec, data_node=None):
302 if not self.mode=='init':
305 for field in [i for i in rec.childNodes if (i.nodeType == i.ELEMENT_NODE and i.nodeName=="field")]:
306 f_name = field.getAttribute("name").encode('utf-8')
307 f_val = _eval_xml(self,field,self.pool, cr, self.uid, self.idref)
309 self.pool.get('ir.model.data').ir_set(cr, self.uid, res['key'], res['key2'], res['name'], res['models'], res['value'], replace=res.get('replace',True), isobject=res.get('isobject', False), meta=res.get('meta',None))
312 def _tag_workflow(self, cr, rec, data_node=None):
313 if self.isnoupdate(data_node) and self.mode != 'init':
315 model = str(rec.getAttribute('model'))
316 w_ref = rec.getAttribute('ref')
318 id = self.id_get(cr, model, w_ref)
320 assert rec.childNodes, 'You must define a child node if you dont give a ref'
321 element_childs = [i for i in rec.childNodes if i.nodeType == i.ELEMENT_NODE]
322 assert len(element_childs) == 1, 'Only one child node is accepted (%d given)' % len(rec.childNodes)
323 id = _eval_xml(self, element_childs[0], self.pool, cr, self.uid, self.idref)
325 uid = self.get_uid(cr, self.uid, data_node, rec)
326 wf_service = netsvc.LocalService("workflow")
327 wf_service.trg_validate(uid, model,
329 str(rec.getAttribute('action')), cr)
332 def _tag_menuitem(self, cr, rec, data_node=None):
333 rec_id = rec.getAttribute("id").encode('ascii')
334 self._test_xml_id(rec_id)
335 m_l = map(escape, escape_re.split(rec.getAttribute("name").encode('utf8')))
337 for idx, menu_elem in enumerate(m_l):
339 cr.execute('select id from ir_ui_menu where parent_id=%d and name=%s', (pid, menu_elem))
341 cr.execute('select id from ir_ui_menu where parent_id is null and name=%s', (menu_elem,))
344 # we are at the last menu element/level (it's a leaf)
345 values = {'parent_id': pid,'name':menu_elem}
347 if rec.hasAttribute('action'):
348 a_action = rec.getAttribute('action').encode('utf8')
349 a_type = rec.getAttribute('type').encode('utf8') or 'act_window'
351 "act_window": 'STOCK_NEW',
352 "report.xml": 'STOCK_PASTE',
353 "wizard": 'STOCK_EXECUTE',
355 values['icon'] = icons.get(a_type,'STOCK_NEW')
356 if a_type=='act_window':
357 a_id = self.id_get(cr, 'ir.actions.%s'% a_type, a_action)
358 cr.execute('select view_type,view_mode,name,view_id from ir_act_window where id=%d', (int(a_id),))
359 action_type,action_mode,action_name,view_id = cr.fetchone()
361 cr.execute('SELECT type FROM ir_ui_view WHERE id=%d', (int(view_id),))
362 action_mode, = cr.fetchone()
363 cr.execute('SELECT view_mode FROM ir_act_window_view WHERE act_window_id=%d ORDER BY sequence LIMIT 1', (int(a_id),))
365 action_mode, = cr.fetchone()
366 if action_type=='tree':
367 values['icon'] = 'STOCK_INDENT'
368 elif action_mode and action_mode.startswith('tree'):
369 values['icon'] = 'STOCK_JUSTIFY_FILL'
370 elif action_mode and action_mode.startswith('graph'):
371 values['icon'] = 'terp-graph'
372 elif action_mode and action_mode.startswith('calendar'):
373 values['icon'] = 'terp-calendar'
374 if not values['name']:
375 values['name'] = action_name
376 if rec.hasAttribute('sequence'):
377 values['sequence'] = int(rec.getAttribute('sequence'))
378 if rec.hasAttribute('icon'):
379 values['icon'] = str(rec.getAttribute('icon'))
380 if rec.hasAttribute('groups'):
381 g_names = rec.getAttribute('groups').split(',')
383 groups_obj = self.pool.get('res.groups')
384 for group in g_names:
385 if group.startswith('-'):
386 id = groups_obj.search(cr, self.uid,
387 [('name', '=', group[1:])])[0]
388 groups_value.append((3, id))
390 id = groups_obj.search(cr, self.uid,
391 [('name', '=', group)])[0]
392 groups_value.append((4, id))
393 values['groups_id'] = groups_value
394 xml_id = rec.getAttribute('id').encode('utf8')
395 self._test_xml_id(xml_id)
396 pid = self.pool.get('ir.model.data')._update(cr, self.uid, 'ir.ui.menu', self.module, values, xml_id, idx==len(m_l)-1, mode=self.mode, res_id=res and res[0] or False)
398 # the menuitem already exists
400 xml_id = idx==len(m_l)-1 and rec.getAttribute('id').encode('utf8')
402 npid = self.pool.get('ir.model.data')._update_dummy(cr, self.uid, 'ir.ui.menu', self.module, xml_id, idx==len(m_l)-1)
404 print 'Menu Error', self.module, xml_id, idx==len(m_l)-1
406 # the menuitem does't exist but we are in branch (not a leaf)
407 pid = self.pool.get('ir.ui.menu').create(cr, self.uid, {'parent_id' : pid, 'name' : menu_elem})
409 self.idref[rec_id] = int(pid)
411 if rec.hasAttribute('action') and pid:
412 a_action = rec.getAttribute('action').encode('utf8')
413 a_type = rec.getAttribute('type').encode('utf8') or 'act_window'
414 a_id = self.id_get(cr, 'ir.actions.%s' % a_type, a_action)
415 action = "ir.actions.%s,%d" % (a_type, a_id)
416 self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', 'tree_but_open', 'Menuitem', [('ir.ui.menu', int(pid))], action, True, True, xml_id=rec_id)
417 return ('ir.ui.menu', pid)
419 def _assert_equals(self, f1, f2, prec = 4):
420 return not round(f1 - f2, prec)
422 def _tag_assert(self, cr, rec, data_node=None):
423 if self.isnoupdate(data_node) and self.mode != 'init':
426 rec_model = rec.getAttribute("model").encode('ascii')
427 model = self.pool.get(rec_model)
428 assert model, "The model %s does not exist !" % (rec_model,)
429 rec_id = rec.getAttribute("id").encode('ascii')
430 self._test_xml_id(rec_id)
431 rec_src = rec.getAttribute("search").encode('utf8')
432 rec_src_count = rec.getAttribute("count")
434 severity = rec.getAttribute("severity").encode('ascii') or 'info'
436 rec_string = rec.getAttribute("string").encode('utf8') or 'unknown'
439 eval_dict = {'ref': _ref(self, cr)}
440 context = self.get_context(data_node, rec, eval_dict)
441 uid = self.get_uid(cr, self.uid, data_node, rec)
443 ids = [self.id_get(cr, rec_model, rec_id)]
445 q = eval(rec_src, eval_dict)
446 ids = self.pool.get(rec_model).search(cr, uid, q, context=context)
447 if len(rec_src_count):
448 count = int(rec_src_count)
449 if len(ids) != count:
450 self.assert_report.record_assertion(False, severity)
451 self.logger.notifyChannel('init', severity, 'assertion "' + rec_string + '" failed ! (search count is incorrect: ' + str(len(ids)) + ')' )
452 sevval = getattr(logging, severity.upper())
453 if sevval > config['assert_exit_level']:
454 # TODO: define a dedicated exception
455 raise Exception('Severe assertion failure')
458 assert ids != None, 'You must give either an id or a search criteria'
462 brrec = model.browse(cr, uid, id, context)
464 def __getitem__(self2, key):
467 return dict.__getitem__(self2, key)
469 globals['floatEqual'] = self._assert_equals
471 globals['_ref'] = ref
472 for test in [i for i in rec.childNodes if (i.nodeType == i.ELEMENT_NODE and i.nodeName=="test")]:
473 f_expr = test.getAttribute("expr").encode('utf-8')
474 f_val = _eval_xml(self, test, self.pool, cr, uid, self.idref, context=context) or True
475 if eval(f_expr, globals) != f_val: # assertion failed
476 self.assert_report.record_assertion(False, severity)
477 self.logger.notifyChannel('init', severity, 'assertion "' + rec_string + '" failed ! (tag ' + test.toxml() + ')' )
478 sevval = getattr(logging, severity.upper())
479 if sevval > config['assert_exit_level']:
480 # TODO: define a dedicated exception
481 raise Exception('Severe assertion failure')
483 else: # all tests were successful for this assertion tag (no break)
484 self.assert_report.record_assertion(True, severity)
486 def _tag_record(self, cr, rec, data_node=None):
487 rec_model = rec.getAttribute("model").encode('ascii')
488 model = self.pool.get(rec_model)
489 assert model, "The model %s does not exist !" % (rec_model,)
490 rec_id = rec.getAttribute("id").encode('ascii')
491 self._test_xml_id(rec_id)
493 # if not rec_id and not self.isnoupdate(data_node):
494 # print "Warning", rec_model
496 if self.isnoupdate(data_node) and not self.mode == 'init':
497 # check if the xml record has an id string
499 id = self.pool.get('ir.model.data')._update_dummy(cr, self.uid, rec_model, self.module, rec_id)
500 # check if the resource already existed at the last update
502 # if it existed, we don't update the data, but we need to
503 # know the id of the existing record anyway
504 self.idref[rec_id] = int(id)
507 # if the resource didn't exist
508 if rec.getAttribute("forcecreate"):
509 # we want to create it, so we let the normal "update" behavior happen
512 # otherwise do nothing
515 # otherwise it is skipped
519 for field in [i for i in rec.childNodes if (i.nodeType == i.ELEMENT_NODE and i.nodeName=="field")]:
520 #TODO: most of this code is duplicated above (in _eval_xml)...
521 f_name = field.getAttribute("name").encode('utf-8')
522 f_ref = field.getAttribute("ref").encode('ascii')
523 f_search = field.getAttribute("search").encode('utf-8')
524 f_model = field.getAttribute("model").encode('ascii')
525 if not f_model and model._columns.get(f_name,False):
526 f_model = model._columns[f_name]._obj
527 f_use = field.getAttribute("use").encode('ascii') or 'id'
531 q = eval(f_search, self.idref)
533 assert f_model, 'Define an attribute model="..." in your .XML file !'
534 f_obj = self.pool.get(f_model)
535 # browse the objects searched
536 s = f_obj.browse(cr, self.uid, f_obj.search(cr, self.uid, q))
537 # column definitions of the "local" object
538 _cols = self.pool.get(rec_model)._columns
539 # if the current field is many2many
540 if (f_name in _cols) and _cols[f_name]._type=='many2many':
541 f_val = [(6, 0, map(lambda x: x[f_use], s))]
543 # otherwise (we are probably in a many2one field),
544 # take the first element of the search
550 f_val = self.id_get(cr, f_model, f_ref)
552 f_val = _eval_xml(self,field, self.pool, cr, self.uid, self.idref)
553 if model._columns.has_key(f_name):
554 if isinstance(model._columns[f_name], osv.fields.integer):
557 id = self.pool.get('ir.model.data')._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode )
559 self.idref[rec_id] = int(id)
562 def id_get(self, cr, model, id_str):
563 if id_str in self.idref:
564 return self.idref[id_str]
567 mod,id_str = id_str.split('.')
568 result = self.pool.get('ir.model.data')._get_id(cr, self.uid, mod, id_str)
569 return int(self.pool.get('ir.model.data').read(cr, self.uid, [result], ['res_id'])[0]['res_id'])
571 def parse(self, xmlstr):
572 d = xml.dom.minidom.parseString(xmlstr)
573 de = d.documentElement
574 for n in [i for i in de.childNodes if (i.nodeType == i.ELEMENT_NODE and i.nodeName=="data")]:
575 for rec in n.childNodes:
576 if rec.nodeType == rec.ELEMENT_NODE:
577 if rec.nodeName in self._tags:
579 self._tags[rec.nodeName](self.cr, rec, n)
581 self.logger.notifyChannel("init", netsvc.LOG_INFO, '\n'+rec.toxml())
586 def __init__(self, cr, module, idref, mode, report=assertion_report(), noupdate = False):
587 self.logger = netsvc.Logger()
592 self.pool = pooler.get_pool(cr.dbname)
593 # self.pool = osv.osv.FakePool(module)
595 self.assert_report = report
596 self.noupdate = noupdate
598 'menuitem': self._tag_menuitem,
599 'record': self._tag_record,
600 'assert': self._tag_assert,
601 'report': self._tag_report,
602 'wizard': self._tag_wizard,
603 'delete': self._tag_delete,
604 'ir_set': self._tag_ir_set,
605 'function': self._tag_function,
606 'workflow': self._tag_workflow,
607 'act_window': self._tag_act_window,
612 def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init', noupdate=False):
619 model = ('.'.join(fname.split('.')[:-1]).split('-'))[0]
620 #remove folder path from model
621 head, model = os.path.split(model)
623 pool = pooler.get_pool(cr.dbname)
625 input=StringIO.StringIO(csvcontent)
626 reader = csv.reader(input, quotechar='"', delimiter=',')
627 fields = reader.next()
629 if not (mode == 'init' or 'id' in fields):
635 datas.append( map(lambda x:x.decode('utf8').encode('utf8'), line))
636 if len(datas) > CSV_STEP:
637 pool.get(model).import_data(cr, uid, fields, datas,mode, module,noupdate)
640 pool.get(model).import_data(cr, uid, fields, datas,mode, module,noupdate)
645 def convert_xml_import(cr, module, xmlstr, idref=None, mode='init', noupdate = False, report=None):
649 report=assertion_report()
650 obj = xml_import(cr, module, idref, mode, report=report, noupdate = noupdate)
655 def convert_xml_export(res):
657 pool=pooler.get_pool(cr.dbname)
658 cr=pooler.db.cursor()
660 d = xml.dom.minidom.getDOMImplementation().createDocument(None, "terp", None)
661 de = d.documentElement
662 data=d.createElement("data")
664 de.appendChild(d.createTextNode('Some textual content.'))