Rename *_xml into xml and add attribute demo to xml file
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
'name': 'IR',
|
||||
'active': True,
|
||||
'update_xml': [
|
||||
'xml': [
|
||||
'sequence.xml',
|
||||
'ui/menu.xml',
|
||||
'ui/view.xml',
|
||||
|
||||
+24
-36
@@ -76,7 +76,7 @@ class Node(Singleton):
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
super(Node, self).__setattr__(name, value)
|
||||
if name in ('init', 'update', 'demo'):
|
||||
if name in ('init', 'update'):
|
||||
CONFIG[name][self.name] = 1
|
||||
for child in self.childs:
|
||||
setattr(child, name, value)
|
||||
@@ -137,7 +137,7 @@ def create_graph(module_list, force=None):
|
||||
graph.add_node(package, deps)
|
||||
node = Node(package, graph)
|
||||
node.datas = datas
|
||||
for kind in ('init', 'demo', 'update'):
|
||||
for kind in ('init', 'update'):
|
||||
if (package in CONFIG[kind]) \
|
||||
or ('all' in CONFIG[kind]) \
|
||||
or (kind in force):
|
||||
@@ -177,45 +177,33 @@ def load_module_graph(cursor, graph, **kwargs):
|
||||
or hasattr(package, 'update') \
|
||||
or (package_state in ('to install', 'to upgrade')):
|
||||
init_module_objects(cursor, module, modules)
|
||||
for kind in ('init', 'update'):
|
||||
for filename in package.datas.get('%s_xml' % kind, []):
|
||||
mode = 'update'
|
||||
if hasattr(package, 'init') or package_state=='to install':
|
||||
mode = 'init'
|
||||
Logger().notify_channel('init', LOG_INFO,
|
||||
'addon:%s:loading %s' % (module, filename))
|
||||
ext = os.path.splitext(filename)[1]
|
||||
if ext == '.csv':
|
||||
tools.convert_csv_import(cursor, module,
|
||||
os.path.basename(filename),
|
||||
tools.file_open(OPJ(module, filename)).read(),
|
||||
idref, mode=mode)
|
||||
elif ext == '.sql':
|
||||
demo = hasattr(package, 'demo') \
|
||||
or (package_demo and package_state != 'installed')
|
||||
for filename in package.datas.get('xml', []):
|
||||
mode = 'update'
|
||||
if hasattr(package, 'init') or package_state=='to install':
|
||||
mode = 'init'
|
||||
Logger().notify_channel('init', LOG_INFO,
|
||||
'addon:%s:loading %s' % (module, filename))
|
||||
ext = os.path.splitext(filename)[1]
|
||||
if ext == '.csv':
|
||||
tools.convert_csv_import(cursor, module,
|
||||
os.path.basename(filename),
|
||||
tools.file_open(OPJ(module, filename)).read(),
|
||||
idref, mode=mode)
|
||||
elif ext == '.sql':
|
||||
if mode == 'init':
|
||||
queries = tools.file_open(OPJ(module,
|
||||
filename)).read().split(';')
|
||||
for query in queries:
|
||||
new_query = ' '.join(query.split())
|
||||
if new_query:
|
||||
cursor.execute(new_query)
|
||||
else:
|
||||
tools.convert_xml_import(cursor, module,
|
||||
tools.file_open(OPJ(module, filename)).read(),
|
||||
idref, mode=mode, **kwargs)
|
||||
if hasattr(package, 'demo') \
|
||||
or (package_demo and package_state != 'installed'):
|
||||
for xml in package.datas.get('demo_xml', []):
|
||||
ext = os.path.splitext(xml)[1]
|
||||
Logger().notify_channel('init', LOG_INFO,
|
||||
'addon:%s:loading %s' % (module, xml))
|
||||
if ext == '.csv':
|
||||
tools.convert_csv_import(cursor, module,
|
||||
os.path.basename(xml),
|
||||
tools.file_open(OPJ(module, xml)).read(), idref,
|
||||
noupdate=True)
|
||||
else:
|
||||
tools.convert_xml_import(cursor, module,
|
||||
tools.file_open(OPJ(module, xml)).read(), idref,
|
||||
noupdate=True, **kwargs)
|
||||
else:
|
||||
tools.convert_xml_import(cursor, module,
|
||||
tools.file_open(OPJ(module, filename)).read(),
|
||||
idref, mode=mode, demo=demo, **kwargs)
|
||||
if demo:
|
||||
cursor.execute('UPDATE ir_module_module SET demo = %s ' \
|
||||
'WHERE name = %s', (True, package.name))
|
||||
package_todo.append(package.name)
|
||||
@@ -278,7 +266,7 @@ def load_modules(database, force_demo=False, update_module=False):
|
||||
if report.get_report():
|
||||
Logger().notify_channel('init', LOG_INFO, 'assert:%s' % report)
|
||||
|
||||
for kind in ('init', 'demo', 'update'):
|
||||
for kind in ('init', 'update'):
|
||||
CONFIG[kind] = {}
|
||||
|
||||
if update_module:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
'name': 'Res',
|
||||
'active': True,
|
||||
'depends': ['ir'],
|
||||
'update_xml': [
|
||||
'xml': [
|
||||
'user.xml',
|
||||
'lang.xml',
|
||||
'request.xml',
|
||||
|
||||
@@ -180,6 +180,9 @@ class AssertionReport(object):
|
||||
class XMLImport(object):
|
||||
|
||||
def isnoupdate(self, data_node = None):
|
||||
if (data_node \
|
||||
and data_node.getAttribute('demo')):
|
||||
return not self.demo
|
||||
return self.noupdate or (data_node \
|
||||
and data_node.getAttribute('noupdate'))
|
||||
|
||||
@@ -696,7 +699,7 @@ class XMLImport(object):
|
||||
return True
|
||||
|
||||
def __init__(self, cursor, module, idref, mode, report=AssertionReport(),
|
||||
noupdate = False):
|
||||
noupdate=False, demo=False):
|
||||
self.mode = mode
|
||||
self.module = module
|
||||
self.cursor = cursor
|
||||
@@ -705,6 +708,7 @@ class XMLImport(object):
|
||||
self.user = 1
|
||||
self.assert_report = report
|
||||
self.noupdate = noupdate
|
||||
self.demo = demo
|
||||
self._tags = {
|
||||
'menuitem': self._tag_menuitem,
|
||||
'record': self._tag_record,
|
||||
@@ -751,13 +755,13 @@ def convert_csv_import(cursor, module, fname, csvcontent, idref=None,
|
||||
module, noupdate)
|
||||
|
||||
def convert_xml_import(cursor, module, xmlstr, idref=None, mode='init',
|
||||
noupdate=False, report=None):
|
||||
noupdate=False, report=None, demo=False):
|
||||
if idref is None:
|
||||
idref = {}
|
||||
if report is None:
|
||||
report = AssertionReport()
|
||||
obj = XMLImport(cursor, module, idref, mode, report=report,
|
||||
noupdate=noupdate)
|
||||
noupdate=noupdate, demo=demo)
|
||||
obj.parse(xmlstr)
|
||||
del obj
|
||||
return True
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
'name': 'Workflow',
|
||||
'active': True,
|
||||
'update_xml': [
|
||||
'xml': [
|
||||
'workflow.xml',
|
||||
],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user