Support for Partial Commit
bzr revid: fp@tinyerp.com-20080819130311-bzlschcnywx2voot
This commit is contained in:
parent
84c2b58ea3
commit
83b19dbcec
|
@ -327,6 +327,9 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
|
|||
if force_demo:
|
||||
force.append('demo')
|
||||
if update_module:
|
||||
for module in tools.config['init']:
|
||||
cr.execute('update ir_module_module set state=%s where state=%s and name=%s', ('to install', 'uninstalled', module))
|
||||
cr.commit()
|
||||
cr.execute("select name from ir_module_module where state in ('installed', 'to install', 'to upgrade','to remove')")
|
||||
else:
|
||||
cr.execute("select name from ir_module_module where state in ('installed', 'to upgrade', 'to remove')")
|
||||
|
|
|
@ -593,28 +593,28 @@ class orm_template(object):
|
|||
|
||||
while len(datas):
|
||||
res = {}
|
||||
try:
|
||||
(res, other, warning, translate, data_id) = \
|
||||
process_liness(self, datas, [], fields_def)
|
||||
if warning:
|
||||
cr.rollback()
|
||||
return (-1, res, warning, '')
|
||||
id = self.pool.get('ir.model.data')._update(cr, uid, self._name,
|
||||
current_module, res, xml_id=data_id, mode=mode,
|
||||
noupdate=noupdate)
|
||||
for lang in translate:
|
||||
context2 = context.copy()
|
||||
context2['lang'] = lang
|
||||
self.write(cr, uid, [id], translate[lang], context2)
|
||||
if config.get('commit_mode', False):
|
||||
cr.commit()
|
||||
except Exception, e:
|
||||
logger.notifyChannel("import", netsvc.LOG_ERROR, e)
|
||||
#try:
|
||||
(res, other, warning, translate, data_id) = \
|
||||
process_liness(self, datas, [], fields_def)
|
||||
if warning:
|
||||
cr.rollback()
|
||||
try:
|
||||
return (-1, res, e[0], warning)
|
||||
except:
|
||||
return (-1, res, e[0], '')
|
||||
return (-1, res, warning, '')
|
||||
id = self.pool.get('ir.model.data')._update(cr, uid, self._name,
|
||||
current_module, res, xml_id=data_id, mode=mode,
|
||||
noupdate=noupdate)
|
||||
for lang in translate:
|
||||
context2 = context.copy()
|
||||
context2['lang'] = lang
|
||||
self.write(cr, uid, [id], translate[lang], context2)
|
||||
if config.get('import_partial', False):
|
||||
cr.commit()
|
||||
#except Exception, e:
|
||||
# logger.notifyChannel("import", netsvc.LOG_ERROR, e)
|
||||
# cr.rollback()
|
||||
# try:
|
||||
# return (-1, res, e[0], warning)
|
||||
# except:
|
||||
# return (-1, res, e[0], '')
|
||||
done += 1
|
||||
#
|
||||
# TODO: Send a request with the result and multi-thread !
|
||||
|
|
|
@ -726,7 +726,9 @@ def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init',
|
|||
|
||||
import pickle
|
||||
if config.get('import_partial'):
|
||||
data = pickle.load(config.get('import_partial'))
|
||||
if not os.path.isfile(config.get('import_partial')):
|
||||
pickle.dump({}, file(config.get('import_partial'),'w+'))
|
||||
data = pickle.load(file(config.get('import_partial')))
|
||||
if fname in data:
|
||||
if not data[fname]:
|
||||
return
|
||||
|
@ -746,9 +748,9 @@ def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init',
|
|||
datas.append( map(lambda x:x.decode('utf8').encode('utf8'), line))
|
||||
pool.get(model).import_data(cr, uid, fields, datas,mode, module,noupdate)
|
||||
if config.get('import_partial'):
|
||||
data = pickle.load(config.get('import_partial'))
|
||||
data = pickle.load(file(config.get('import_partial')))
|
||||
data[fname] = 0
|
||||
pickle.save(config.get('import_partial'), data)
|
||||
pickle.dump(data, file(config.get('import_partial'),'wb'))
|
||||
|
||||
#
|
||||
# xml import/export
|
||||
|
|
Loading…
Reference in New Issue