improvements_bugfixes
bzr revid: fp@tinyerp.com-20081214164647-hku6dlqkd65fe8ry
This commit is contained in:
parent
2b5971f125
commit
8cb88b6054
|
@ -138,7 +138,7 @@ def get_module_path(module):
|
||||||
if os.path.exists(opj(_ad, module)) or os.path.exists(opj(_ad, '%s.zip' % module)):
|
if os.path.exists(opj(_ad, module)) or os.path.exists(opj(_ad, '%s.zip' % module)):
|
||||||
return opj(_ad, module)
|
return opj(_ad, module)
|
||||||
|
|
||||||
logger.notifyChannel('init', netsvc.LOG_WARNING, 'addon %s: module not found' % (module,))
|
logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: module not found' % (module,))
|
||||||
return False
|
return False
|
||||||
raise IOError, 'Module not found : %s' % module
|
raise IOError, 'Module not found : %s' % module
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ def create_graph(module_list, force=None):
|
||||||
try:
|
try:
|
||||||
info = eval(tools.file_open(terp_file).read())
|
info = eval(tools.file_open(terp_file).read())
|
||||||
except:
|
except:
|
||||||
logger.notifyChannel('init', netsvc.LOG_ERROR, 'addon %s: eval file %s' % (module, terp_file))
|
logger.notifyChannel('init', netsvc.LOG_ERROR, 'module %s: eval file %s' % (module, terp_file))
|
||||||
raise
|
raise
|
||||||
if info.get('installable', True):
|
if info.get('installable', True):
|
||||||
packages.append((module, info.get('depends', []), info))
|
packages.append((module, info.get('depends', []), info))
|
||||||
|
@ -246,18 +246,25 @@ def create_graph(module_list, force=None):
|
||||||
|
|
||||||
for package in later:
|
for package in later:
|
||||||
unmet_deps = filter(lambda p: p not in graph, dependencies[package])
|
unmet_deps = filter(lambda p: p not in graph, dependencies[package])
|
||||||
logger.notifyChannel('init', netsvc.LOG_ERROR, 'addon %s: Unmet dependencies: %s' % (package, ', '.join(unmet_deps)))
|
logger.notifyChannel('init', netsvc.LOG_ERROR, 'module %s: Unmet dependencies: %s' % (package, ', '.join(unmet_deps)))
|
||||||
|
|
||||||
return graph
|
return graph
|
||||||
|
|
||||||
def init_module_objects(cr, module_name, obj_list):
|
def init_module_objects(cr, module_name, obj_list):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
logger.notifyChannel('init', netsvc.LOG_INFO, 'addon %s: creating or updating database tables' % module_name)
|
logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: creating or updating database tables' % module_name)
|
||||||
|
todo = []
|
||||||
for obj in obj_list:
|
for obj in obj_list:
|
||||||
if hasattr(obj, 'init'):
|
if hasattr(obj, 'init'):
|
||||||
obj.init(cr)
|
obj.init(cr)
|
||||||
obj._auto_init(cr, {'module': module_name})
|
result = obj._auto_init(cr, {'module': module_name})
|
||||||
|
if result:
|
||||||
|
todo += result
|
||||||
cr.commit()
|
cr.commit()
|
||||||
|
todo.sort()
|
||||||
|
for t in todo:
|
||||||
|
t[1](cr, *t[2])
|
||||||
|
cr.commit()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Register module named m, if not already registered
|
# Register module named m, if not already registered
|
||||||
|
@ -266,7 +273,7 @@ def register_class(m):
|
||||||
global loaded
|
global loaded
|
||||||
if m in loaded:
|
if m in loaded:
|
||||||
return
|
return
|
||||||
logger.notifyChannel('init', netsvc.LOG_INFO, 'addon %s: registering classes' % m)
|
logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: registering objects' % m)
|
||||||
loaded.append(m)
|
loaded.append(m)
|
||||||
mod_path = get_module_path(m)
|
mod_path = get_module_path(m)
|
||||||
if not os.path.isfile(mod_path+'.zip'):
|
if not os.path.isfile(mod_path+'.zip'):
|
||||||
|
@ -401,13 +408,13 @@ class MigrationManager(object):
|
||||||
mod = None
|
mod = None
|
||||||
try:
|
try:
|
||||||
mod = imp.load_source(name, pyfile, fp)
|
mod = imp.load_source(name, pyfile, fp)
|
||||||
logger.notifyChannel('migration', netsvc.LOG_INFO, 'addon %(addon)s: Running migration %(version)s %(name)s"' % mergedict({'name': mod.__name__},strfmt))
|
logger.notifyChannel('migration', netsvc.LOG_INFO, 'module %(addon)s: Running migration %(version)s %(name)s"' % mergedict({'name': mod.__name__},strfmt))
|
||||||
mod.migrate(self.cr, pkg.installed_version)
|
mod.migrate(self.cr, pkg.installed_version)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
logger.notifyChannel('migration', netsvc.LOG_ERROR, 'addon %(addon)s: Unable to load %(stage)-migration file %(file)s' % mergedict({'file': opj(modulename,pyfile)}, strfmt))
|
logger.notifyChannel('migration', netsvc.LOG_ERROR, 'module %(addon)s: Unable to load %(stage)-migration file %(file)s' % mergedict({'file': opj(modulename,pyfile)}, strfmt))
|
||||||
raise
|
raise
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
logger.notifyChannel('migration', netsvc.LOG_ERROR, 'addon %(addon)s: Each %(stage)-migration file must have a "migrate(cr, installed_version)" function' % strfmt)
|
logger.notifyChannel('migration', netsvc.LOG_ERROR, 'module %(addon)s: Each %(stage)-migration file must have a "migrate(cr, installed_version)" function' % strfmt)
|
||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
fp.close()
|
fp.close()
|
||||||
|
@ -444,6 +451,7 @@ def load_module_graph(cr, graph, status=None, check_access_rules=True, **kwargs)
|
||||||
|
|
||||||
migrations = MigrationManager(cr, graph)
|
migrations = MigrationManager(cr, graph)
|
||||||
|
|
||||||
|
check_rules = False
|
||||||
for package in graph:
|
for package in graph:
|
||||||
status['progress'] = (float(statusi)+0.1)/len(graph)
|
status['progress'] = (float(statusi)+0.1)/len(graph)
|
||||||
m = package.name
|
m = package.name
|
||||||
|
@ -452,19 +460,20 @@ def load_module_graph(cr, graph, status=None, check_access_rules=True, **kwargs)
|
||||||
migrations.migrate_module(package, 'pre')
|
migrations.migrate_module(package, 'pre')
|
||||||
|
|
||||||
register_class(m)
|
register_class(m)
|
||||||
logger.notifyChannel('init', netsvc.LOG_INFO, 'addon %s' % m)
|
logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s loading objects' % m)
|
||||||
modules = pool.instanciate(m, cr)
|
modules = pool.instanciate(m, cr)
|
||||||
|
|
||||||
idref = {}
|
idref = {}
|
||||||
status['progress'] = (float(statusi)+0.4)/len(graph)
|
status['progress'] = (float(statusi)+0.4)/len(graph)
|
||||||
if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'):
|
if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'):
|
||||||
|
check_rules = True
|
||||||
init_module_objects(cr, m, modules)
|
init_module_objects(cr, m, modules)
|
||||||
for kind in ('init', 'update'):
|
for kind in ('init', 'update'):
|
||||||
for filename in package.data.get('%s_xml' % kind, []):
|
for filename in package.data.get('%s_xml' % kind, []):
|
||||||
mode = 'update'
|
mode = 'update'
|
||||||
if hasattr(package, 'init') or package.state=='to install':
|
if hasattr(package, 'init') or package.state=='to install':
|
||||||
mode = 'init'
|
mode = 'init'
|
||||||
logger.notifyChannel('init', netsvc.LOG_INFO, 'addon %s: loading %s' % (m, filename))
|
logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: loading %s' % (m, filename))
|
||||||
name, ext = os.path.splitext(filename)
|
name, ext = os.path.splitext(filename)
|
||||||
fp = tools.file_open(opj(m, filename))
|
fp = tools.file_open(opj(m, filename))
|
||||||
if ext == '.csv':
|
if ext == '.csv':
|
||||||
|
@ -482,7 +491,7 @@ def load_module_graph(cr, graph, status=None, check_access_rules=True, **kwargs)
|
||||||
status['progress'] = (float(statusi)+0.75)/len(graph)
|
status['progress'] = (float(statusi)+0.75)/len(graph)
|
||||||
for xml in package.data.get('demo_xml', []):
|
for xml in package.data.get('demo_xml', []):
|
||||||
name, ext = os.path.splitext(xml)
|
name, ext = os.path.splitext(xml)
|
||||||
logger.notifyChannel('init', netsvc.LOG_INFO, 'addon %s: loading %s' % (m, xml))
|
logger.notifyChannel('init', netsvc.LOG_INFO, 'module %s: loading %s' % (m, xml))
|
||||||
fp = tools.file_open(opj(m, xml))
|
fp = tools.file_open(opj(m, xml))
|
||||||
if ext == '.csv':
|
if ext == '.csv':
|
||||||
tools.convert_csv_import(cr, m, os.path.basename(xml), fp.read(), idref, noupdate=True)
|
tools.convert_csv_import(cr, m, os.path.basename(xml), fp.read(), idref, noupdate=True)
|
||||||
|
@ -503,16 +512,14 @@ def load_module_graph(cr, graph, status=None, check_access_rules=True, **kwargs)
|
||||||
if modobj:
|
if modobj:
|
||||||
modobj.update_translations(cr, 1, [mid], None)
|
modobj.update_translations(cr, 1, [mid], None)
|
||||||
cr.commit()
|
cr.commit()
|
||||||
|
|
||||||
|
|
||||||
migrations.migrate_module(package, 'post')
|
migrations.migrate_module(package, 'post')
|
||||||
|
|
||||||
statusi+=1
|
statusi+=1
|
||||||
|
|
||||||
if check_access_rules:
|
if check_access_rules and check_rules:
|
||||||
cr.execute("""select model,name from ir_model where id not in (select model_id from ir_model_access)""")
|
cr.execute("""select model,name from ir_model where id not in (select model_id from ir_model_access)""")
|
||||||
for (model,name) in cr.fetchall():
|
for (model,name) in cr.fetchall():
|
||||||
logger.notifyChannel('init', netsvc.LOG_WARNING, 'addon object %s (%s) has no access rules!' % (model,name))
|
logger.notifyChannel('init', netsvc.LOG_WARNING, 'object %s (%s) has no access rules!' % (model,name))
|
||||||
|
|
||||||
|
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
|
@ -535,9 +542,12 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
|
||||||
if update_module:
|
if update_module:
|
||||||
basegraph = create_graph(['base'], force)
|
basegraph = create_graph(['base'], force)
|
||||||
load_module_graph(cr, basegraph, status, check_access_rules=False, report=report)
|
load_module_graph(cr, basegraph, status, check_access_rules=False, report=report)
|
||||||
|
|
||||||
modobj = pool.get('ir.module.module')
|
modobj = pool.get('ir.module.module')
|
||||||
modobj.update_list(cr, 1)
|
logger.notifyChannel('init', netsvc.LOG_INFO, 'updating modules list')
|
||||||
|
cr.execute("select id from ir_module_module where state in ('to install','to upgrade') and name=%s", ('base',))
|
||||||
|
if cr.rowcount:
|
||||||
|
modobj.update_list(cr, 1)
|
||||||
|
|
||||||
mods = [k for k in tools.config['init'] if tools.config['init'][k]]
|
mods = [k for k in tools.config['init'] if tools.config['init'][k]]
|
||||||
if mods:
|
if mods:
|
||||||
|
@ -547,25 +557,27 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
|
||||||
|
|
||||||
mods = [k for k in tools.config['update'] if tools.config['update'][k]]
|
mods = [k for k in tools.config['update'] if tools.config['update'][k]]
|
||||||
if mods:
|
if mods:
|
||||||
ids = modobj.search(cr, 1, ['&', '&',('state', '=', 'installed'), ('name', 'in', mods), '!', ('name', '=', 'base')])
|
ids = modobj.search(cr, 1, ['&',('state', '=', 'installed'), ('name', 'in', mods)])
|
||||||
if ids:
|
if ids:
|
||||||
modobj.button_upgrade(cr, 1, ids)
|
modobj.button_upgrade(cr, 1, ids)
|
||||||
|
|
||||||
cr.execute("select name from ir_module_module where state in ('installed', 'to install', 'to upgrade','to remove')")
|
cr.execute("update ir_module_module set state=%s where name=%s", ('installed', 'base'))
|
||||||
|
cr.execute("select name from ir_module_module where state in ('installed', 'to install', 'to upgrade')")
|
||||||
else:
|
else:
|
||||||
cr.execute("select name from ir_module_module where state in ('installed', 'to upgrade', 'to remove')")
|
cr.execute("select name from ir_module_module where state in ('installed', 'to upgrade')")
|
||||||
module_list = [name for (name,) in cr.fetchall()]
|
module_list = [name for (name,) in cr.fetchall()]
|
||||||
graph = create_graph(module_list, force)
|
graph = create_graph(module_list, force)
|
||||||
|
|
||||||
# the 'base' module has already been updated
|
# the 'base' module has already been updated
|
||||||
base = graph['base']
|
base = graph['base']
|
||||||
|
base.state = 'installed'
|
||||||
for kind in ('init', 'demo', 'update'):
|
for kind in ('init', 'demo', 'update'):
|
||||||
if hasattr(base, kind):
|
if hasattr(base, kind):
|
||||||
delattr(base, kind)
|
delattr(base, kind)
|
||||||
|
|
||||||
load_module_graph(cr, graph, status, report=report)
|
load_module_graph(cr, graph, status, report=report)
|
||||||
if report.get_report():
|
if report.get_report():
|
||||||
logger.notifyChannel('init', netsvc.LOG_INFO, 'assert: %s' % report)
|
logger.notifyChannel('init', netsvc.LOG_INFO, report)
|
||||||
|
|
||||||
for kind in ('init', 'demo', 'update'):
|
for kind in ('init', 'demo', 'update'):
|
||||||
tools.config[kind]={}
|
tools.config[kind]={}
|
||||||
|
@ -577,29 +589,29 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
cr.execute('select model,res_id from ir_model_data where not noupdate and module=%s order by id desc', (mod_name,))
|
cr.execute('select model,res_id from ir_model_data where not noupdate and module=%s order by id desc', (mod_name,))
|
||||||
for rmod,rid in cr.fetchall():
|
for rmod,rid in cr.fetchall():
|
||||||
#
|
|
||||||
# TO BE Improved:
|
|
||||||
# I can not use the class_pool has _table could be defined in __init__
|
|
||||||
# and I can not use the pool has the module could not be loaded in the pool
|
|
||||||
#
|
|
||||||
uid = 1
|
uid = 1
|
||||||
pool.get(rmod).unlink(cr, uid, [rid])
|
pool.get(rmod).unlink(cr, uid, [rid])
|
||||||
cr.commit()
|
cr.commit()
|
||||||
#
|
#
|
||||||
# TODO: remove menu without actions of childs
|
# TODO: remove menu without actions of childs
|
||||||
#
|
#
|
||||||
cr.execute('''delete from
|
while True:
|
||||||
ir_ui_menu
|
cr.execute('''delete from
|
||||||
where
|
ir_ui_menu
|
||||||
(id not in (select parent_id from ir_ui_menu where parent_id is not null))
|
where
|
||||||
and
|
(id not in (select parent_id from ir_ui_menu where parent_id is not null))
|
||||||
(id not in (select res_id from ir_values where model='ir.ui.menu'))
|
and
|
||||||
and
|
(id not in (select res_id from ir_values where model='ir.ui.menu'))
|
||||||
(id not in (select res_id from ir_model_data where model='ir.ui.menu'))''')
|
and
|
||||||
|
(id not in (select res_id from ir_model_data where model='ir.ui.menu'))''')
|
||||||
|
if not cr.rowcount:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
logger.notifyChannel('init', netsvc.LOG_INFO, 'removed %d unused menus' % (cr.rowcount,))
|
||||||
|
|
||||||
cr.execute("update ir_module_module set state=%s where state in ('to remove')", ('uninstalled', ))
|
cr.execute("update ir_module_module set state=%s where state in ('to remove')", ('uninstalled', ))
|
||||||
cr.commit()
|
cr.commit()
|
||||||
pooler.restart_pool(cr.dbname)
|
#pooler.restart_pool(cr.dbname)
|
||||||
cr.close()
|
cr.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,17 +25,15 @@ from osv.orm import except_orm
|
||||||
import tools
|
import tools
|
||||||
|
|
||||||
class ir_attachment(osv.osv):
|
class ir_attachment(osv.osv):
|
||||||
|
|
||||||
def check(self, cr, uid, ids, mode):
|
def check(self, cr, uid, ids, mode):
|
||||||
if not ids:
|
if not ids:
|
||||||
return
|
return
|
||||||
ima = self.pool.get('ir.model.access')
|
ima = self.pool.get('ir.model.access')
|
||||||
if isinstance(ids, (int, long)):
|
if isinstance(ids, (int, long)):
|
||||||
ids = [ids]
|
ids = [ids]
|
||||||
objs = self.browse(cr, uid, ids) or []
|
cr.execute('select distinct res_model from ir_attachment where id in ('+','.join(map(str, ids))+')')
|
||||||
for o in objs:
|
for obj in cr.fetchall():
|
||||||
if o and o.res_model:
|
ima.check(cr, uid, obj[0], mode)
|
||||||
ima.check(cr, uid, o.res_model, mode)
|
|
||||||
|
|
||||||
def search(self, cr, uid, args, offset=0, limit=None, order=None,
|
def search(self, cr, uid, args, offset=0, limit=None, order=None,
|
||||||
context=None, count=False):
|
context=None, count=False):
|
||||||
|
|
|
@ -122,15 +122,19 @@ class module(osv.osv):
|
||||||
view_id = model_data_obj.search(cr,uid,[('module','in', mnames.keys()),
|
view_id = model_data_obj.search(cr,uid,[('module','in', mnames.keys()),
|
||||||
('model','in',('ir.ui.view','ir.actions.report.xml','ir.ui.menu'))])
|
('model','in',('ir.ui.view','ir.actions.report.xml','ir.ui.menu'))])
|
||||||
for data_id in model_data_obj.browse(cr,uid,view_id,context):
|
for data_id in model_data_obj.browse(cr,uid,view_id,context):
|
||||||
key = data_id['model']
|
# We use try except, because views or menus may not exist
|
||||||
if key=='ir.ui.view':
|
try:
|
||||||
v = view_obj.browse(cr,uid,data_id.res_id)
|
key = data_id['model']
|
||||||
aa = v.inherit_id and '* INHERIT ' or ''
|
if key=='ir.ui.view':
|
||||||
res[mnames[data_id.module]]['views_by_module'] += aa + v.name + ' ('+v.type+')\n'
|
v = view_obj.browse(cr,uid,data_id.res_id)
|
||||||
elif key=='ir.actions.report.xml':
|
aa = v.inherit_id and '* INHERIT ' or ''
|
||||||
res[mnames[data_id.module]]['reports_by_module'] += report_obj.browse(cr,uid,data_id.res_id).name + '\n'
|
res[mnames[data_id.module]]['views_by_module'] += aa + v.name + ' ('+v.type+')\n'
|
||||||
elif key=='ir.ui.menu':
|
elif key=='ir.actions.report.xml':
|
||||||
res[mnames[data_id.module]]['menus_by_module'] += menu_obj.browse(cr,uid,data_id.res_id).complete_name + '\n'
|
res[mnames[data_id.module]]['reports_by_module'] += report_obj.browse(cr,uid,data_id.res_id).name + '\n'
|
||||||
|
elif key=='ir.ui.menu':
|
||||||
|
res[mnames[data_id.module]]['menus_by_module'] += menu_obj.browse(cr,uid,data_id.res_id).complete_name + '\n'
|
||||||
|
except KeyError, e:
|
||||||
|
pass
|
||||||
return res
|
return res
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# OpenERP, Open Source Management Solution
|
# OpenERP, Open Source Management Solution
|
||||||
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
|
@ -398,12 +398,14 @@ class TinySocketClientThread(threading.Thread):
|
||||||
ts.mysend(r)
|
ts.mysend(r)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||||
s = str(e)
|
print e
|
||||||
|
print tb_s
|
||||||
import tools
|
import tools
|
||||||
if tools.config['debug_mode']:
|
if tools.config['debug_mode']:
|
||||||
import pdb
|
import pdb
|
||||||
tb = sys.exc_info()[2]
|
tb = sys.exc_info()[2]
|
||||||
pdb.post_mortem(tb)
|
pdb.post_mortem(tb)
|
||||||
|
e = Exception(e.message)
|
||||||
ts.mysend(e, exception=True, traceback=tb_s)
|
ts.mysend(e, exception=True, traceback=tb_s)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -107,10 +107,16 @@ import service
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
# import addons
|
# import addons
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
|
|
||||||
import addons
|
import addons
|
||||||
|
|
||||||
if tools.config['init'] or tools.config['update']:
|
#----------------------------------------------------------
|
||||||
pooler.get_db_and_pool(tools.config['db_name'], update_module=True)
|
# Load and update databases if requested
|
||||||
|
#----------------------------------------------------------
|
||||||
|
|
||||||
|
if tools.config['db_name']:
|
||||||
|
for db in tools.config['db_name'].split(','):
|
||||||
|
pooler.get_db_and_pool(db, update_module=tools.config['init'] or tools.config['update'])
|
||||||
|
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
# translation stuff
|
# translation stuff
|
||||||
|
|
|
@ -196,6 +196,7 @@ class binary(_column):
|
||||||
_symbol_c = '%s'
|
_symbol_c = '%s'
|
||||||
_symbol_f = lambda symb: symb and Binary(symb) or None
|
_symbol_f = lambda symb: symb and Binary(symb) or None
|
||||||
_symbol_set = (_symbol_c, _symbol_f)
|
_symbol_set = (_symbol_c, _symbol_f)
|
||||||
|
_symbol_get = lambda self, x: x and str(x)
|
||||||
|
|
||||||
_classic_read = False
|
_classic_read = False
|
||||||
|
|
||||||
|
@ -208,7 +209,6 @@ class binary(_column):
|
||||||
context = {}
|
context = {}
|
||||||
if not values:
|
if not values:
|
||||||
values = []
|
values = []
|
||||||
|
|
||||||
res = {}
|
res = {}
|
||||||
for i in ids:
|
for i in ids:
|
||||||
val = None
|
val = None
|
||||||
|
@ -216,10 +216,10 @@ class binary(_column):
|
||||||
if v['id'] == i:
|
if v['id'] == i:
|
||||||
val = v[name]
|
val = v[name]
|
||||||
break
|
break
|
||||||
res.setdefault(i, val)
|
|
||||||
if context.get('bin_size', False):
|
if context.get('bin_size', False):
|
||||||
res[i] = tools.human_size(val)
|
res[i] = tools.human_size(val)
|
||||||
|
else:
|
||||||
|
res[i] = val
|
||||||
return res
|
return res
|
||||||
|
|
||||||
get = get_memory
|
get = get_memory
|
||||||
|
@ -276,6 +276,9 @@ class many2one(_column):
|
||||||
_classic_read = False
|
_classic_read = False
|
||||||
_classic_write = True
|
_classic_write = True
|
||||||
_type = 'many2one'
|
_type = 'many2one'
|
||||||
|
_symbol_c = '%s'
|
||||||
|
_symbol_f = lambda x: x or None
|
||||||
|
_symbol_set = (_symbol_c, _symbol_f)
|
||||||
|
|
||||||
def __init__(self, obj, string='unknown', **args):
|
def __init__(self, obj, string='unknown', **args):
|
||||||
_column.__init__(self, string=string, **args)
|
_column.__init__(self, string=string, **args)
|
||||||
|
|
138
bin/osv/orm.py
138
bin/osv/orm.py
|
@ -1376,10 +1376,31 @@ class orm(orm_template):
|
||||||
browse_rec(None)
|
browse_rec(None)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _update_store(self, cr, f, k):
|
||||||
|
logger = netsvc.Logger()
|
||||||
|
logger.notifyChannel('init', netsvc.LOG_INFO, "storing computed values of fields.function '%s'" % (k,))
|
||||||
|
ss = self._columns[k]._symbol_set
|
||||||
|
update_query = 'UPDATE "%s" SET "%s"=%s WHERE id=%%s' % (self._table, k, ss[0])
|
||||||
|
cr.execute('select id from '+self._table)
|
||||||
|
ids_lst = map(lambda x: x[0], cr.fetchall())
|
||||||
|
while ids_lst:
|
||||||
|
iids = ids_lst[:40]
|
||||||
|
ids_lst = ids_lst[40:]
|
||||||
|
res = f.get(cr, self, iids, k, 1, {})
|
||||||
|
for key,val in res.items():
|
||||||
|
if f._multi:
|
||||||
|
val = val[k]
|
||||||
|
# if val is a many2one, just write the ID
|
||||||
|
if type(val)==tuple:
|
||||||
|
val = val[0]
|
||||||
|
if (val<>False) or (type(val)<>bool):
|
||||||
|
cr.execute(update_query, (ss[1](val), key))
|
||||||
|
|
||||||
def _auto_init(self, cr, context={}):
|
def _auto_init(self, cr, context={}):
|
||||||
store_compute = False
|
store_compute = False
|
||||||
logger = netsvc.Logger()
|
logger = netsvc.Logger()
|
||||||
create = False
|
create = False
|
||||||
|
todo_end = []
|
||||||
self._field_create(cr, context=context)
|
self._field_create(cr, context=context)
|
||||||
if not hasattr(self, "_auto") or self._auto:
|
if not hasattr(self, "_auto") or self._auto:
|
||||||
cr.execute("SELECT relname FROM pg_class WHERE relkind in ('r','v') AND relname='%s'" % self._table)
|
cr.execute("SELECT relname FROM pg_class WHERE relkind in ('r','v') AND relname='%s'" % self._table)
|
||||||
|
@ -1479,10 +1500,17 @@ class orm(orm_template):
|
||||||
default = self._defaults[k](self, cr, 1, {})
|
default = self._defaults[k](self, cr, 1, {})
|
||||||
ss = self._columns[k]._symbol_set
|
ss = self._columns[k]._symbol_set
|
||||||
query = 'UPDATE "%s" SET "%s"=%s' % (self._table, k, ss[0])
|
query = 'UPDATE "%s" SET "%s"=%s' % (self._table, k, ss[0])
|
||||||
cr.execute(query, (default is not None and ss[1](default) or None,))
|
cr.execute(query, (ss[1](default),))
|
||||||
|
cr.commit()
|
||||||
|
logger.notifyChannel('init', netsvc.LOG_DEBUG, 'setting default value of new column %s of table %s'% (k, self._table))
|
||||||
|
elif not create:
|
||||||
|
logger.notifyChannel('init', netsvc.LOG_DEBUG, 'creating new column %s of table %s'% (k, self._table))
|
||||||
|
|
||||||
if isinstance(f, fields.function):
|
if isinstance(f, fields.function):
|
||||||
todo_update_store.append((f,k))
|
order = 10
|
||||||
|
if f.store is not True:
|
||||||
|
order = f.store[f.store.keys()[0]][2]
|
||||||
|
todo_update_store.append((order, f,k))
|
||||||
|
|
||||||
# and add constraints if needed
|
# and add constraints if needed
|
||||||
if isinstance(f, fields.many2one):
|
if isinstance(f, fields.many2one):
|
||||||
|
@ -1497,10 +1525,10 @@ class orm(orm_template):
|
||||||
if f.select:
|
if f.select:
|
||||||
cr.execute('CREATE INDEX "%s_%s_index" ON "%s" ("%s")' % (self._table, k, self._table, k))
|
cr.execute('CREATE INDEX "%s_%s_index" ON "%s" ("%s")' % (self._table, k, self._table, k))
|
||||||
if f.required:
|
if f.required:
|
||||||
cr.commit()
|
|
||||||
try:
|
try:
|
||||||
|
cr.commit()
|
||||||
cr.execute('ALTER TABLE "%s" ALTER COLUMN "%s" SET NOT NULL' % (self._table, k))
|
cr.execute('ALTER TABLE "%s" ALTER COLUMN "%s" SET NOT NULL' % (self._table, k))
|
||||||
except:
|
except Exception, e:
|
||||||
logger.notifyChannel('init', netsvc.LOG_WARNING, 'WARNING: unable to set column %s of table %s not null !\nTry to re-run: openerp-server.py --update=module\nIf it doesn\'t work, update records and execute manually:\nALTER TABLE %s ALTER COLUMN %s SET NOT NULL' % (k, self._table, self._table, k))
|
logger.notifyChannel('init', netsvc.LOG_WARNING, 'WARNING: unable to set column %s of table %s not null !\nTry to re-run: openerp-server.py --update=module\nIf it doesn\'t work, update records and execute manually:\nALTER TABLE %s ALTER COLUMN %s SET NOT NULL' % (k, self._table, self._table, k))
|
||||||
cr.commit()
|
cr.commit()
|
||||||
elif len(res)==1:
|
elif len(res)==1:
|
||||||
|
@ -1509,40 +1537,40 @@ class orm(orm_template):
|
||||||
f_pg_size = f_pg_def['size']
|
f_pg_size = f_pg_def['size']
|
||||||
f_pg_notnull = f_pg_def['attnotnull']
|
f_pg_notnull = f_pg_def['attnotnull']
|
||||||
if isinstance(f, fields.function) and not f.store:
|
if isinstance(f, fields.function) and not f.store:
|
||||||
logger.notifyChannel('init', netsvc.LOG_WARNING, 'column %s (%s) in table %s was converted to a function !\nYou should remove this column from your database.' % (k, f.string, self._table))
|
logger.notifyChannel('init', netsvc.LOG_INFO, 'column %s (%s) in table %s was converted to a function !\nYou should remove this column from your database.' % (k, f.string, self._table))
|
||||||
f_obj_type = None
|
f_obj_type = None
|
||||||
else:
|
else:
|
||||||
f_obj_type = get_pg_type(f) and get_pg_type(f)[0]
|
f_obj_type = get_pg_type(f) and get_pg_type(f)[0]
|
||||||
|
|
||||||
if f_obj_type:
|
if f_obj_type:
|
||||||
if f_pg_type != f_obj_type:
|
ok = False
|
||||||
logger.notifyChannel('init', netsvc.LOG_WARNING, "column '%s' in table '%s' has changed type (DB = %s, def = %s) !" % (k, self._table, f_pg_type, f._type))
|
casts = [
|
||||||
|
('text', 'char', 'VARCHAR(%d)' % (f.size or 0,), '::VARCHAR(%d)'%(f.size or 0,)),
|
||||||
|
('varchar', 'text', 'TEXT', ''),
|
||||||
|
('int4', 'float', get_pg_type(f)[1], '::'+get_pg_type(f)[1]),
|
||||||
|
('date', 'datetime', 'TIMESTAMP', '::TIMESTAMP'),
|
||||||
|
]
|
||||||
if f_pg_type == 'varchar' and f._type == 'char' and f_pg_size != f.size:
|
if f_pg_type == 'varchar' and f._type == 'char' and f_pg_size != f.size:
|
||||||
# columns with the name 'type' cannot be changed for an unknown reason?!
|
logger.notifyChannel('init', netsvc.LOG_INFO, "column '%s' in table '%s' changed size" % (k, self._table))
|
||||||
if k != 'type':
|
cr.execute('ALTER TABLE "%s" RENAME COLUMN "%s" TO temp_change_size' % (self._table, k))
|
||||||
if f_pg_size > f.size:
|
cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" VARCHAR(%d)' % (self._table, k, f.size))
|
||||||
logger.notifyChannel('init', netsvc.LOG_WARNING, "column '%s' in table '%s' has changed size (DB = %d, def = %d), DB size will be kept !" % (k, self._table, f_pg_size, f.size))
|
cr.execute('UPDATE "%s" SET "%s"=temp_change_size::VARCHAR(%d)' % (self._table, k, f.size))
|
||||||
# If actual DB size is < than new
|
cr.execute('ALTER TABLE "%s" DROP COLUMN temp_change_size' % (self._table,))
|
||||||
# We update varchar size, otherwise, we keep DB size
|
cr.commit()
|
||||||
# to avoid truncated string...
|
for c in casts:
|
||||||
if f_pg_size < f.size:
|
if (f_pg_type==c[0]) and (f._type==c[1]):
|
||||||
cr.execute('ALTER TABLE "%s" RENAME COLUMN "%s" TO temp_change_size' % (self._table, k))
|
logger.notifyChannel('init', netsvc.LOG_INFO, "column '%s' in table '%s' changed type to %s." % (k, self._table, c[1]))
|
||||||
cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" VARCHAR(%d)' % (self._table, k, f.size))
|
ok = True
|
||||||
cr.execute('UPDATE "%s" SET "%s"=temp_change_size::VARCHAR(%d)' % (self._table, k, f.size))
|
cr.execute('ALTER TABLE "%s" RENAME COLUMN "%s" TO temp_change_size' % (self._table, k))
|
||||||
cr.execute('ALTER TABLE "%s" DROP COLUMN temp_change_size' % (self._table,))
|
cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" %s' % (self._table, k, c[2]))
|
||||||
cr.commit()
|
cr.execute(('UPDATE "%s" SET "%s"=temp_change_size'+c[3]) % (self._table, k))
|
||||||
if f_pg_type == 'varchar' and f._type == 'text':
|
cr.execute('ALTER TABLE "%s" DROP COLUMN temp_change_size CASCADE' % (self._table,))
|
||||||
cr.execute("ALTER TABLE \"%s\" RENAME COLUMN \"%s\" TO temp_change_type" % (self._table, k))
|
cr.commit()
|
||||||
cr.execute("ALTER TABLE \"%s\" ADD COLUMN \"%s\" text " % (self._table, k))
|
|
||||||
cr.execute("UPDATE \"%s\" SET \"%s\"=temp_change_type" % (self._table, k))
|
if f_pg_type != f_obj_type:
|
||||||
cr.execute("ALTER TABLE \"%s\" DROP COLUMN temp_change_type" % (self._table,))
|
if not ok:
|
||||||
cr.commit()
|
logger.notifyChannel('init', netsvc.LOG_WARNING, "column '%s' in table '%s' has changed type (DB = %s, def = %s) but unable to migrate this change !" % (k, self._table, f_pg_type, f._type))
|
||||||
if f_pg_type == 'date' and f._type == 'datetime':
|
|
||||||
cr.execute('ALTER TABLE "%s" RENAME COLUMN "%s" TO temp_change_type' % (self._table, k))
|
|
||||||
cr.execute('ALTER TABLE "%s" ADD COLUMN "%s" TIMESTAMP' % (self._table, k))
|
|
||||||
cr.execute('UPDATE "%s" SET "%s"=temp_change_type::TIMESTAMP' % (self._table, k))
|
|
||||||
cr.execute('ALTER TABLE "%s" DROP COLUMN temp_change_type' % (self._table,))
|
|
||||||
cr.commit()
|
|
||||||
# if the field is required and hasn't got a NOT NULL constraint
|
# if the field is required and hasn't got a NOT NULL constraint
|
||||||
if f.required and f_pg_notnull == 0:
|
if f.required and f_pg_notnull == 0:
|
||||||
# set the field to the default value if any
|
# set the field to the default value if any
|
||||||
|
@ -1552,12 +1580,12 @@ class orm(orm_template):
|
||||||
ss = self._columns[k]._symbol_set
|
ss = self._columns[k]._symbol_set
|
||||||
query = 'UPDATE "%s" SET "%s"=%s WHERE %s is NULL' % (self._table, k, ss[0], k)
|
query = 'UPDATE "%s" SET "%s"=%s WHERE %s is NULL' % (self._table, k, ss[0], k)
|
||||||
cr.execute(query, (ss[1](default),))
|
cr.execute(query, (ss[1](default),))
|
||||||
cr.commit()
|
|
||||||
# add the NOT NULL constraint
|
# add the NOT NULL constraint
|
||||||
|
cr.commit()
|
||||||
try:
|
try:
|
||||||
cr.execute('ALTER TABLE "%s" ALTER COLUMN "%s" SET NOT NULL' % (self._table, k))
|
cr.execute('ALTER TABLE "%s" ALTER COLUMN "%s" SET NOT NULL' % (self._table, k))
|
||||||
cr.commit()
|
cr.commit()
|
||||||
except:
|
except Exception, e:
|
||||||
logger.notifyChannel('init', netsvc.LOG_WARNING, 'unable to set a NOT NULL constraint on column %s of the %s table !\nIf you want to have it, you should update the records and execute manually:\nALTER TABLE %s ALTER COLUMN %s SET NOT NULL' % (k, self._table, self._table, k))
|
logger.notifyChannel('init', netsvc.LOG_WARNING, 'unable to set a NOT NULL constraint on column %s of the %s table !\nIf you want to have it, you should update the records and execute manually:\nALTER TABLE %s ALTER COLUMN %s SET NOT NULL' % (k, self._table, self._table, k))
|
||||||
cr.commit()
|
cr.commit()
|
||||||
elif not f.required and f_pg_notnull == 1:
|
elif not f.required and f_pg_notnull == 1:
|
||||||
|
@ -1606,23 +1634,8 @@ class orm(orm_template):
|
||||||
else:
|
else:
|
||||||
logger = netsvc.Logger()
|
logger = netsvc.Logger()
|
||||||
logger.notifyChannel('orm', netsvc.LOG_ERROR, "Programming error !")
|
logger.notifyChannel('orm', netsvc.LOG_ERROR, "Programming error !")
|
||||||
for f,k in todo_update_store:
|
for order,f,k in todo_update_store:
|
||||||
ss = self._columns[k]._symbol_set
|
todo_end.append((order, self._update_store, (f, k)))
|
||||||
update_query = 'UPDATE "%s" SET "%s"=%s WHERE id=%%s' % (self._table, k, ss[0])
|
|
||||||
cr.execute('select id from '+self._table)
|
|
||||||
ids_lst = map(lambda x: x[0], cr.fetchall())
|
|
||||||
while ids_lst:
|
|
||||||
iids = ids_lst[:40]
|
|
||||||
ids_lst = ids_lst[40:]
|
|
||||||
res = f.get(cr, self, iids, k, 1, {})
|
|
||||||
for key,val in res.items():
|
|
||||||
if f._multi:
|
|
||||||
val = val[k]
|
|
||||||
if (val<>False) or (type(val)<>bool):
|
|
||||||
#cr.execute("UPDATE \"%s\" SET \"%s\"='%s' where id=%d"% (self._table, k, val, key))
|
|
||||||
cr.execute(update_query, (ss[1](val), key))
|
|
||||||
#else:
|
|
||||||
# cr.execute("UPDATE \"%s\" SET \"%s\"=NULL where id=%d"% (self._table, k, key))
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
cr.execute("SELECT relname FROM pg_class WHERE relkind in ('r','v') AND relname=%s", (self._table,))
|
cr.execute("SELECT relname FROM pg_class WHERE relkind in ('r','v') AND relname=%s", (self._table,))
|
||||||
|
@ -1647,6 +1660,7 @@ class orm(orm_template):
|
||||||
cr.commit()
|
cr.commit()
|
||||||
if store_compute:
|
if store_compute:
|
||||||
self._parent_store_compute(cr)
|
self._parent_store_compute(cr)
|
||||||
|
return todo_end
|
||||||
|
|
||||||
def __init__(self, cr):
|
def __init__(self, cr):
|
||||||
super(orm, self).__init__(cr)
|
super(orm, self).__init__(cr)
|
||||||
|
@ -1658,18 +1672,15 @@ class orm(orm_template):
|
||||||
if not f.store:
|
if not f.store:
|
||||||
continue
|
continue
|
||||||
if self._columns[store_field].store is True:
|
if self._columns[store_field].store is True:
|
||||||
sm = {self._name:(lambda self,cr, uid, ids, c={}: ids, None)}
|
sm = {self._name:(lambda self,cr, uid, ids, c={}: ids, None, 10)}
|
||||||
else:
|
else:
|
||||||
sm = self._columns[store_field].store
|
sm = self._columns[store_field].store
|
||||||
for object, aa in sm.items():
|
for object, aa in sm.items():
|
||||||
if len(aa)==2:
|
if len(aa)==3:
|
||||||
(fnct,fields2)=aa
|
|
||||||
order = 1
|
|
||||||
elif len(aa)==3:
|
|
||||||
(fnct,fields2,order)=aa
|
(fnct,fields2,order)=aa
|
||||||
else:
|
else:
|
||||||
raise except_orm(_('Error'),
|
raise except_orm('Error',
|
||||||
_('Invalid function definition %s in object %s !' % (store_field, self._name)))
|
('Invalid function definition %s in object %s !\nYou must use the definition: store={object:(fnct, fields, priority)}.' % (store_field, self._name)))
|
||||||
self.pool._store_function.setdefault(object, [])
|
self.pool._store_function.setdefault(object, [])
|
||||||
ok = True
|
ok = True
|
||||||
for x,y,z,e,f in self.pool._store_function[object]:
|
for x,y,z,e,f in self.pool._store_function[object]:
|
||||||
|
@ -1790,7 +1801,6 @@ class orm(orm_template):
|
||||||
value[key[8:]] = context[key]
|
value[key[8:]] = context[key]
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Update objects that uses this one to update their _inherits fields
|
# Update objects that uses this one to update their _inherits fields
|
||||||
#
|
#
|
||||||
|
@ -2402,16 +2412,22 @@ class orm(orm_template):
|
||||||
|
|
||||||
def _store_set_values(self, cr, uid, ids, fields, context):
|
def _store_set_values(self, cr, uid, ids, fields, context):
|
||||||
todo = {}
|
todo = {}
|
||||||
|
keys = []
|
||||||
for f in fields:
|
for f in fields:
|
||||||
|
if self._columns[f]._multi not in keys:
|
||||||
|
keys.append(self._columns[f]._multi)
|
||||||
todo.setdefault(self._columns[f]._multi, [])
|
todo.setdefault(self._columns[f]._multi, [])
|
||||||
todo[self._columns[f]._multi].append(f)
|
todo[self._columns[f]._multi].append(f)
|
||||||
for key,val in todo.items():
|
for key in keys:
|
||||||
|
val = todo[key]
|
||||||
if key:
|
if key:
|
||||||
result = self._columns[val[0]].get(cr, self, ids, val, uid, context=context)
|
result = self._columns[val[0]].get(cr, self, ids, val, uid, context=context)
|
||||||
for id,value in result.items():
|
for id,value in result.items():
|
||||||
upd0 = []
|
upd0 = []
|
||||||
upd1 = []
|
upd1 = []
|
||||||
for v in value:
|
for v in value:
|
||||||
|
if v not in val:
|
||||||
|
continue
|
||||||
if self._columns[v]._type in ('many2one', 'one2one'):
|
if self._columns[v]._type in ('many2one', 'one2one'):
|
||||||
try:
|
try:
|
||||||
value[v] = value[v][0]
|
value[v] = value[v][0]
|
||||||
|
@ -2433,7 +2449,7 @@ class orm(orm_template):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
cr.execute('update "' + self._table + '" set ' + \
|
cr.execute('update "' + self._table + '" set ' + \
|
||||||
'"'+f+'"='+self._columns[f]._symbol_set[0] + ' where id = %s', (value,id))
|
'"'+f+'"='+self._columns[f]._symbol_set[0] + ' where id = %s', (self._columns[f]._symbol_set[1](value),id))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -184,7 +184,7 @@ class osv_memory(orm.orm_memory):
|
||||||
name = hasattr(cls, '_name') and cls._name or cls._inherit
|
name = hasattr(cls, '_name') and cls._name or cls._inherit
|
||||||
parent_name = hasattr(cls, '_inherit') and cls._inherit
|
parent_name = hasattr(cls, '_inherit') and cls._inherit
|
||||||
if parent_name:
|
if parent_name:
|
||||||
print 'Inherit not supported in osv_memory object !'
|
raise 'Inherit not supported in osv_memory object !'
|
||||||
obj = object.__new__(cls)
|
obj = object.__new__(cls)
|
||||||
obj.__init__(pool, cr)
|
obj.__init__(pool, cr)
|
||||||
return obj
|
return obj
|
||||||
|
|
|
@ -610,7 +610,6 @@ class report_sxw(report_rml):
|
||||||
attach = report_xml.attachment
|
attach = report_xml.attachment
|
||||||
rml = report_xml.report_rml_content
|
rml = report_xml.report_rml_content
|
||||||
report_type = report_xml.report_type
|
report_type = report_xml.report_type
|
||||||
context['actual_model']=report_xml.actual_model
|
|
||||||
else:
|
else:
|
||||||
ir_menu_report_obj = pool.get('ir.ui.menu')
|
ir_menu_report_obj = pool.get('ir.ui.menu')
|
||||||
report_menu_ids = ir_menu_report_obj.search(cr, uid,
|
report_menu_ids = ir_menu_report_obj.search(cr, uid,
|
||||||
|
|
|
@ -29,7 +29,6 @@ import logging
|
||||||
import threading, thread
|
import threading, thread
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import base64
|
|
||||||
import addons
|
import addons
|
||||||
|
|
||||||
import sql_db
|
import sql_db
|
||||||
|
|
|
@ -26,6 +26,7 @@ from psycopg2.pool import ThreadedConnectionPool
|
||||||
from psycopg2.psycopg1 import cursor as psycopg1cursor
|
from psycopg2.psycopg1 import cursor as psycopg1cursor
|
||||||
|
|
||||||
import psycopg2.extensions
|
import psycopg2.extensions
|
||||||
|
|
||||||
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
|
psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
|
||||||
|
|
||||||
types_mapping = {
|
types_mapping = {
|
||||||
|
@ -34,6 +35,10 @@ types_mapping = {
|
||||||
'datetime': (1114,),
|
'datetime': (1114,),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def unbuffer(symb, cr):
|
||||||
|
if symb is None: return None
|
||||||
|
return str(symb)
|
||||||
|
|
||||||
def undecimalize(symb, cr):
|
def undecimalize(symb, cr):
|
||||||
if symb is None: return None
|
if symb is None: return None
|
||||||
return float(symb)
|
return float(symb)
|
||||||
|
|
|
@ -35,7 +35,7 @@ class configmanager(object):
|
||||||
'netport': '8070',
|
'netport': '8070',
|
||||||
'db_host': False,
|
'db_host': False,
|
||||||
'db_port': False,
|
'db_port': False,
|
||||||
'db_name': 'terp',
|
'db_name': False,
|
||||||
'db_user': False,
|
'db_user': False,
|
||||||
'db_password': False,
|
'db_password': False,
|
||||||
'db_maxconn': 64,
|
'db_maxconn': 64,
|
||||||
|
|
|
@ -663,7 +663,7 @@ form: module.record_id""" % (xml_id,)
|
||||||
# if not rec_id and not self.isnoupdate(data_node):
|
# if not rec_id and not self.isnoupdate(data_node):
|
||||||
# print "Warning", rec_model
|
# print "Warning", rec_model
|
||||||
|
|
||||||
if self.isnoupdate(data_node) and not self.mode == 'init':
|
if self.isnoupdate(data_node) and not self.mode in ('init','update'):
|
||||||
# check if the xml record has an id string
|
# check if the xml record has an id string
|
||||||
if rec_id:
|
if rec_id:
|
||||||
id = self.pool.get('ir.model.data')._update_dummy(cr, self.uid, rec_model, self.module, rec_id)
|
id = self.pool.get('ir.model.data')._update_dummy(cr, self.uid, rec_model, self.module, rec_id)
|
||||||
|
@ -724,10 +724,11 @@ form: module.record_id""" % (xml_id,)
|
||||||
if isinstance(model._columns[f_name], osv.fields.integer):
|
if isinstance(model._columns[f_name], osv.fields.integer):
|
||||||
f_val = int(f_val)
|
f_val = int(f_val)
|
||||||
res[f_name] = f_val
|
res[f_name] = f_val
|
||||||
|
|
||||||
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 )
|
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 )
|
||||||
if rec_id:
|
if rec_id:
|
||||||
self.idref[rec_id] = int(id)
|
self.idref[rec_id] = int(id)
|
||||||
if config.get('import_partial', False):
|
if config.get('i mport_partial', False):
|
||||||
cr.commit()
|
cr.commit()
|
||||||
return rec_model, id
|
return rec_model, id
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ class workflow_service(netsvc.Service):
|
||||||
|
|
||||||
def trg_write(self, uid, res_type, res_id, cr):
|
def trg_write(self, uid, res_type, res_id, cr):
|
||||||
ident = (uid,res_type,res_id)
|
ident = (uid,res_type,res_id)
|
||||||
cr.execute('select id from wkf_instance where res_id=%s and res_type=%s and state=%s', (res_id,res_type, 'active'))
|
cr.execute('select id from wkf_instance where res_id=%s and res_type=%s and state=%s', (res_id or None,res_type or None, 'active'))
|
||||||
for (id,) in cr.fetchall():
|
for (id,) in cr.fetchall():
|
||||||
instance.update(cr, id, ident)
|
instance.update(cr, id, ident)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue