Fix menuitem tag
This commit is contained in:
commit
6082567348
26 files changed
+382
-1094
No files matched your search
+13
-13
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<menuitem name="Administration/IR/Actions" id="menu_actions"/>
|
||||
<menuitem name="Actions" id="menu_actions" parent_id="ir.menu_ir"/>
|
||||
<record model="ir.ui.view" id="actions_actions_view_form">
|
||||
<field name="model">ir.actions.actions</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Action">
|
||||
<field name="name" select="1"/>
|
||||
<field name="type" select="1"/>
|
||||
@@ -28,7 +28,7 @@
|
||||
<field name="model">ir.actions.actions</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Action">
|
||||
<field name="name"/>
|
||||
<field name="type"/>
|
||||
@@ -56,13 +56,13 @@
|
||||
<field name="view_id" ref="actions_actions_view_form"/>
|
||||
<field name="act_window_id" ref="act_actions_actions_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/Actions/"
|
||||
<menuitem parent_id="menu_actions"
|
||||
action="act_actions_actions_form" id="menu_actions_actions"/>
|
||||
<record model="ir.ui.view" id="actions_report_view_form">
|
||||
<field name="model">ir.actions.report</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Report">
|
||||
<field name="name" select="1"/>
|
||||
<field name="type" select="1"/>
|
||||
@@ -78,7 +78,7 @@
|
||||
<field name="model">ir.actions.report</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Report xml">
|
||||
<field name="name"/>
|
||||
<field name="type"/>
|
||||
@@ -108,13 +108,13 @@
|
||||
<field name="view_id" ref="actions_report_view_form"/>
|
||||
<field name="act_window_id" ref="act_actions_report_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/Actions/"
|
||||
<menuitem parent_id="menu_actions"
|
||||
action="act_actions_report_form" id="menu_actions_report_form"/>
|
||||
<record model="ir.ui.view" id="actions_act_window_view_form">
|
||||
<field name="model">ir.actions.act_window</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Open a Window">
|
||||
<field name="name" select="1"/>
|
||||
<field name="type" readonly="1"/>
|
||||
@@ -149,7 +149,7 @@
|
||||
<field name="model">ir.actions.act_window</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Open Window">
|
||||
<field name="name"/>
|
||||
<field name="res_model"/>
|
||||
@@ -178,13 +178,13 @@
|
||||
<field name="view_id" ref="actions_act_window_view_form"/>
|
||||
<field name="act_window_id" ref="act_actions_act_window_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/Actions/"
|
||||
<menuitem parent_id="menu_actions"
|
||||
action="act_actions_act_window_form" id="menu_actions_act_window"/>
|
||||
<record model="ir.ui.view" id="actions_wizard_view_form">
|
||||
<field name="model">ir.actions.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Wizard">
|
||||
<field name="name" select="1"/>
|
||||
<field name="type" select="1"/>
|
||||
@@ -198,7 +198,7 @@
|
||||
<field name="model">ir.actions.wizard</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Wizard">
|
||||
<field name="name"/>
|
||||
<field name="type"/>
|
||||
@@ -228,7 +228,7 @@
|
||||
<field name="view_id" ref="actions_wizard_view_form"/>
|
||||
<field name="act_window_id" ref="act_actions_wizard_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/Actions/"
|
||||
<menuitem parent_id="menu_actions"
|
||||
action="act_actions_wizard_form" id="menu_actions_wizard"/>
|
||||
</data>
|
||||
</terp>
|
||||
@@ -5,7 +5,7 @@
|
||||
<field name="model">ir.attachment</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Attachments">
|
||||
<field name="name" colspan="4" select="1"/>
|
||||
<field name="datas" colspan="4"/>
|
||||
@@ -23,7 +23,7 @@
|
||||
<field name="model">ir.attachment</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Attachments">
|
||||
<field name="name"/>
|
||||
<field name="res_model"/>
|
||||
@@ -52,7 +52,7 @@
|
||||
<field name="view_id" ref="attachment_view_form"/>
|
||||
<field name="act_window_id" ref="act_attachment_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/Attachments"
|
||||
<menuitem name="Attachments" parent_id="ir.menu_ir"
|
||||
action="act_attachment_form" id="menu_attachment_form"/>
|
||||
</data>
|
||||
</terp>
|
||||
+3
-3
@@ -5,7 +5,7 @@
|
||||
<field name="model">ir.cron</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Scheduled Actions">
|
||||
<field name="nextcall"/>
|
||||
<field name="name"/>
|
||||
@@ -20,7 +20,7 @@
|
||||
<field name="model">ir.cron</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Scheduled Action">
|
||||
<field name="name" select="1"/>
|
||||
<field name="active" select="1"/>
|
||||
@@ -62,7 +62,7 @@
|
||||
<field name="view_id" ref="cron_view_form"/>
|
||||
<field name="act_window_id" ref="act_cron_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/"
|
||||
<menuitem parent_id="ir.menu_ir"
|
||||
action="act_cron_form" id="menu_cron_form"/>
|
||||
</data>
|
||||
</terp>
|
||||
@@ -5,7 +5,7 @@
|
||||
<field name="model">ir.exports</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Exports">
|
||||
<field name="name" select="1"/>
|
||||
<field name="resource" select="1"/>
|
||||
@@ -18,7 +18,7 @@
|
||||
<field name="model">ir.exports</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Exports">
|
||||
<field name="name"/>
|
||||
<field name="resource"/>
|
||||
@@ -46,7 +46,7 @@
|
||||
<field name="view_id" ref="exports_view_form"/>
|
||||
<field name="act_window_id" ref="act_exports_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/"
|
||||
<menuitem parent_id="ir.menu_ir"
|
||||
action="act_exports_form" id="menu_exports_form"/>
|
||||
</data>
|
||||
</terp>
|
||||
+1
-1
@@ -2,6 +2,6 @@
|
||||
<terp>
|
||||
<data>
|
||||
<menuitem name="Administration" id="menu_administration"/>
|
||||
<menuitem name="Administration/IR" id="menu_ir"/>
|
||||
<menuitem name="IR" id="menu_ir" parent_id="menu_administration"/>
|
||||
</data>
|
||||
</terp>
|
||||
+157
-168
@@ -1,6 +1,6 @@
|
||||
"model"
|
||||
from trytond.osv import fields, OSV
|
||||
from trytond.netsvc import Logger, LocalService, LOG_ERROR, LOG_INFO
|
||||
from trytond.netsvc import Logger, LocalService, LOG_ERROR, LOG_INFO, LOG_WARNING
|
||||
from trytond.osv.orm import except_orm
|
||||
from trytond.tools import Cache
|
||||
import time
|
||||
@@ -141,211 +141,189 @@ class ModelData(OSV):
|
||||
_name = 'ir.model.data'
|
||||
_description = __doc__
|
||||
_columns = {
|
||||
'name': fields.char('XML Identifier', required=True, size=64),
|
||||
'fs_id': fields.char('Identifier on File System', required=True,
|
||||
size=64, help="The id of the record as known on the file system."),
|
||||
'model': fields.char('Model', required=True, size=64),
|
||||
'module': fields.char('Module', required=True, size=64),
|
||||
'res_id': fields.integer('Resource ID'),
|
||||
'noupdate': fields.boolean('Non Updatable'),
|
||||
'db_id': fields.integer('Resource ID',
|
||||
help="The id of the record in the database."),
|
||||
'date_update': fields.datetime('Update Date'),
|
||||
'date_init': fields.datetime('Init Date')
|
||||
'date_init': fields.datetime('Init Date'),
|
||||
'values': fields.text('Values'),
|
||||
}
|
||||
_defaults = {
|
||||
'date_init': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'date_update': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
'noupdate': lambda *a: False
|
||||
}
|
||||
|
||||
def __init__(self, pool):
|
||||
OSV.__init__(self, pool)
|
||||
self.loads = {}
|
||||
self.doinit = True
|
||||
self.unlink_mark = {}
|
||||
|
||||
def _get_id(self, cursor, user, module, xml_id):
|
||||
ids = self.search(cursor, user, [
|
||||
('module', '=', module),
|
||||
('name', '=', xml_id),
|
||||
])
|
||||
assert len(ids)==1, '%d reference(s) to %s. ' \
|
||||
'You should have only one !' % (len(ids),xml_id)
|
||||
return ids[0]
|
||||
self.fs2db = None
|
||||
self.fs2values = None
|
||||
|
||||
_get_id = Cache()(_get_id)
|
||||
|
||||
def _update_dummy(self, cursor, user, model, module, xml_id=False):
|
||||
if not xml_id:
|
||||
return False
|
||||
try:
|
||||
obj_id = self.read(cursor, user, self._get_id(cursor, user, module,
|
||||
xml_id), ['res_id'])['res_id']
|
||||
self.loads[(module, xml_id)] = (model, obj_id)
|
||||
except:
|
||||
obj_id = False
|
||||
return obj_id
|
||||
def populate_fs2db(self, cursor, user):
|
||||
"""Fetch all the db_id, model tuple in the table in one shot
|
||||
(if necessary). This table is kept as a cache for the future
|
||||
conversions between fs_id abd db_id"""
|
||||
|
||||
def _update(self, cursor, user, model, module, values, xml_id='',
|
||||
noupdate=False, mode='init', res_id=False):
|
||||
model_obj = self.pool.get(model)
|
||||
if xml_id and ('.' in xml_id):
|
||||
assert len(xml_id.split('.')) == 2, '"%s" contains too many dots. '\
|
||||
'XML ids should not contain dots ! ' \
|
||||
if not self.fs2db: self.fs2db = {}
|
||||
if cursor.dbname not in self.fs2db:
|
||||
module_data_ids = self.search(cursor, user,[])
|
||||
self.fs2db[cursor.dbname] = dict([
|
||||
((x.fs_id, x.module),
|
||||
(x.db_id, x.model)) for x in \
|
||||
self.browse(cursor, user, module_data_ids)])
|
||||
|
||||
def populate_fs2values(self, cursor, user):
|
||||
"""Fetch all the table in one shot (if necessary). When a
|
||||
record is imported ny import_record, the corresponding item in
|
||||
fs2values is removed. When post_import is called, the items
|
||||
remaining in fs2values are the one that were in the model_data
|
||||
table but not in the fs, so they are removed."""
|
||||
# Improvement: store the fiedls names and a hash of the values
|
||||
# instead of all the values.
|
||||
if not self.fs2values: self.fs2values = {}
|
||||
if cursor.dbname not in self.fs2values:
|
||||
module_data_ids = self.search(cursor, user,[])
|
||||
self.fs2values[cursor.dbname] = dict([
|
||||
((x.fs_id, x.module),
|
||||
x.values) for x in \
|
||||
self.browse(cursor, user, module_data_ids)])
|
||||
|
||||
def get_id(self, cursor, user, module, fs_id):
|
||||
|
||||
# Pre-Fetch all the data at once
|
||||
self.populate_fs2db(cursor, user)
|
||||
|
||||
# return only the db_id
|
||||
if (fs_id, module) in self.fs2db[cursor.dbname]:
|
||||
return self.fs2db[cursor.dbname][(fs_id, module)][0]
|
||||
else:
|
||||
raise Exception("Reference to %s not found"% ".".join([module,fs_id]))
|
||||
|
||||
def import_record(self, cursor, user, model, module, values, fs_id):
|
||||
|
||||
if not fs_id:
|
||||
raise Exception('import_record : Argument fs_id is mandatory')
|
||||
|
||||
if '.' in fs_id:
|
||||
assert len(fs_id.split('.')) == 2, '"%s" contains too many dots. '\
|
||||
'file system ids should contain ot most one dot ! ' \
|
||||
'These are used to refer to other modules data, ' \
|
||||
'as in module.reference_id' % (xml_id)
|
||||
module, xml_id = xml_id.split('.')
|
||||
if (not xml_id) and (not self.doinit):
|
||||
return False
|
||||
action_id = False
|
||||
if xml_id:
|
||||
cursor.execute('SELECT id, res_id FROM ir_model_data ' \
|
||||
'WHERE module = %s AND name = %s', (module,xml_id))
|
||||
results = cursor.fetchall()
|
||||
for action_id2, res_id2 in results:
|
||||
cursor.execute('SELECT id ' \
|
||||
'FROM ' + self.pool.get(model)._table + ' ' \
|
||||
'WHERE id = %d', (res_id2,))
|
||||
result3 = cursor.fetchone()
|
||||
if not result3:
|
||||
cursor.execute('DELETE FROM ir_model_data ' \
|
||||
'WHERE id = %d', (action_id2,))
|
||||
'as in module.reference_id' % (fs_id)
|
||||
|
||||
module, fs_id = fs_id.split('.')
|
||||
|
||||
self.populate_fs2db(cursor, user)
|
||||
self.populate_fs2values(cursor, user)
|
||||
|
||||
|
||||
if (fs_id, module) in self.fs2db[cursor.dbname]:
|
||||
# this record is already in the db:
|
||||
db_id, db_model = \
|
||||
self.fs2db[cursor.dbname][(fs_id, module)]
|
||||
old_values = self.fs2values[cursor.dbname][(fs_id, module)]
|
||||
old_values = eval(old_values)
|
||||
|
||||
# Check if this record has been modified in the db:
|
||||
if model != db_model:
|
||||
raise Exception("This record try to overwrite"
|
||||
"data with the wrong model.")
|
||||
object_ref = self.pool.get(model)
|
||||
db_values = object_ref.read(cursor, user, db_id, old_values.keys())
|
||||
|
||||
modified = False
|
||||
for key in old_values:
|
||||
|
||||
if object_ref._columns[key]._type == 'many2one':
|
||||
db_field = db_values[key][0]
|
||||
elif object_ref._columns[key]._type in ['one2one', 'one2many', "many2many"]:
|
||||
logger = Logger()
|
||||
logger.notify_channel('init', LOG_WARNING,
|
||||
'Field %s on %s : integrity not tested.'%(key, model))
|
||||
continue
|
||||
else:
|
||||
res_id, action_id = res_id2, action_id2
|
||||
db_field = db_values[key]
|
||||
|
||||
if action_id and res_id:
|
||||
model_obj.write(cursor, user, [res_id], values)
|
||||
self.write(cursor, user, [action_id], {
|
||||
'date_update': time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
})
|
||||
elif res_id:
|
||||
model_obj.write(cursor, user, [res_id], values)
|
||||
if xml_id:
|
||||
if old_values[key] != db_field:
|
||||
modified = True
|
||||
break
|
||||
|
||||
if not modified:
|
||||
# Update the model_data with the modified values
|
||||
|
||||
self.pool.get(model).write(cursor, user, db_id, values)
|
||||
self.create(cursor, user, {
|
||||
'name': xml_id,
|
||||
'fs_id': fs_id,
|
||||
'model': model,
|
||||
'module':module,
|
||||
'res_id':res_id,
|
||||
'noupdate': noupdate,
|
||||
'module': module,
|
||||
'db_id': db_id,
|
||||
'values': str(values),
|
||||
'date_update': time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||
})
|
||||
if model_obj._inherits:
|
||||
for table in model_obj._inherits:
|
||||
inherit_id = model_obj.browse(cursor, user,
|
||||
res_id)[model_obj._inherits[table]]
|
||||
self.create(cursor, user, {
|
||||
'name': xml_id + '_' + table.replace('.', '_'),
|
||||
'model': table,
|
||||
'module': module,
|
||||
'res_id': inherit_id,
|
||||
'noupdate': noupdate,
|
||||
})
|
||||
|
||||
else:
|
||||
# We may not overwrite modified data:
|
||||
logger = Logger()
|
||||
logger.notify_channel('init', LOG_INFO,
|
||||
'Record %s ignored, the corresponding data (%s@%s) '
|
||||
'in the db has been modified' % (fs_id,db_id, model))
|
||||
# Remove this record from the value list. This means that
|
||||
# the corresponding record have been found.
|
||||
del self.fs2values[cursor.dbname][(fs_id, module)]
|
||||
else:
|
||||
if mode == 'init' or (mode == 'update' and xml_id):
|
||||
res_id = model_obj.create(cursor, user, values)
|
||||
if xml_id:
|
||||
self.create(cursor, user, {
|
||||
'name': xml_id,
|
||||
'model': model,
|
||||
'module': module,
|
||||
'res_id': res_id,
|
||||
'noupdate': noupdate
|
||||
})
|
||||
if model_obj._inherits:
|
||||
for table in model_obj._inherits:
|
||||
inherit_id = model_obj.browse(cursor, user,
|
||||
res_id)[model_obj._inherits[table]]
|
||||
self.create(cursor, user, {
|
||||
'name': xml_id + '_' + table.replace('.', '_'),
|
||||
'model': table,
|
||||
'module': module,
|
||||
'res_id': inherit_id,
|
||||
'noupdate': noupdate,
|
||||
})
|
||||
if xml_id:
|
||||
if res_id:
|
||||
self.loads[(module, xml_id)] = (model, res_id)
|
||||
return res_id
|
||||
# this record is new
|
||||
db_id = self.pool.get(model).create(cursor, user, values)
|
||||
self.create(cursor, user, {
|
||||
'fs_id': fs_id,
|
||||
'model': model,
|
||||
'module': module,
|
||||
'db_id': db_id,
|
||||
'values': str(values),
|
||||
})
|
||||
# update fs2db:
|
||||
self.fs2db[cursor.dbname][(fs_id, module)]= (db_id, model, str(values))
|
||||
|
||||
def _unlink(self, cursor, user, model, ids, direct=False):
|
||||
#self.pool.get(model).unlink(cursor, user, ids)
|
||||
for obj_id in ids:
|
||||
self.unlink_mark[(model, obj_id)]=False
|
||||
cursor.execute('DELETE FROM ir_model_data ' \
|
||||
'WHERE res_id = %d AND model = %s', (obj_id, model))
|
||||
return True
|
||||
def post_import(self, cursor, user, modules):
|
||||
|
||||
def ir_set(self, cursor, user, key, key2, name, models, value,
|
||||
replace=True, isobject=False, meta=None, xml_id=False):
|
||||
obj = self.pool.get('ir.values')
|
||||
if type(models[0])==type([]) or type(models[0])==type(()):
|
||||
model, res_id = models[0]
|
||||
else:
|
||||
res_id = None
|
||||
model = models[0]
|
||||
|
||||
if res_id:
|
||||
where = ' AND res_id = %d' % (res_id,)
|
||||
else:
|
||||
where = ' AND (res_id IS NULL)'
|
||||
|
||||
if key2:
|
||||
where += ' AND key2 = \'%s\'' % (key2,)
|
||||
else:
|
||||
where += ' AND (key2 IS NULL)'
|
||||
|
||||
cursor.execute('SELECT * FROM ir_values ' \
|
||||
'WHERE model = %s AND key = %s AND name = %s' + where,
|
||||
(model, key, name))
|
||||
res = cursor.fetchone()
|
||||
if not res:
|
||||
res = obj.set(cursor, user, key, key2, name, models, value,
|
||||
replace, isobject, meta)
|
||||
elif xml_id:
|
||||
cursor.execute('UPDATE ir_values SET value = %s ' \
|
||||
'WHERE model = %s AND key = %s AND name = %s' + where,
|
||||
(value, model, key, name))
|
||||
return True
|
||||
|
||||
def _process_end(self, cursor, user, modules):
|
||||
if not modules:
|
||||
# Test because of a wrong extra call see todo at the end of
|
||||
# load_module_graph in module.py
|
||||
# Globaly this function is a bit dirty.
|
||||
if not (self.fs2values and self.fs2values.get(cursor.dbname)):
|
||||
return True
|
||||
module_str = ["'%s'" % m for m in modules]
|
||||
cursor.execute('SELECT id, name, model, res_id, module ' \
|
||||
'FROM ir_model_data ' \
|
||||
'WHERE module IN (' + ','.join(module_str) + ') ' \
|
||||
'AND NOT noupdate')
|
||||
wkf_todo = []
|
||||
for (obj_id, name, model, res_id, module) in cursor.fetchall():
|
||||
if (module, name) not in self.loads:
|
||||
self.unlink_mark[(model, res_id)] = obj_id
|
||||
|
||||
wf_service = LocalService("workflow")
|
||||
|
||||
data_unlink = []
|
||||
|
||||
for (fs_id, module) in self.fs2values[cursor.dbname]:
|
||||
if module in modules:
|
||||
(db_id, model, values) = self.fs2db[cursor.dbname][(fs_id, module)]
|
||||
|
||||
if model == 'workflow.activity':
|
||||
cursor.execute('SELECT res_type, res_id ' \
|
||||
cursor.execute('SELECT res_type, db_id ' \
|
||||
'FROM wkf_instance ' \
|
||||
'WHERE id IN (' \
|
||||
'SELECT inst_id FROM wkf_workitem ' \
|
||||
'WHERE act_id = %d)', (res_id,))
|
||||
'WHERE act_id = %d)', (db_id,))
|
||||
wkf_todo.extend(cursor.fetchall())
|
||||
cursor.execute("UPDATE wkf_transition " \
|
||||
"SET condition = 'True', role_id = NULL, " \
|
||||
"signal = NULL, act_to = act_from, " \
|
||||
"act_from = %d " \
|
||||
"WHERE act_to = %d", (res_id, res_id))
|
||||
"WHERE act_to = %d", (db_id, db_id))
|
||||
cursor.execute("DELETE FROM wkf_transition " \
|
||||
"WHERE act_to = %d", (res_id,))
|
||||
"WHERE act_to = %d", (db_id,))
|
||||
|
||||
for model, obj_id in wkf_todo:
|
||||
wf_service = LocalService("workflow")
|
||||
wf_service.trg_write(user, model, obj_id, cursor)
|
||||
wf_service.trg_write(user, model, db_id, cursor)
|
||||
|
||||
for (model, obj_id) in self.unlink_mark.keys():
|
||||
if self.pool.get(model):
|
||||
logger = Logger()
|
||||
logger.notify_channel('init', LOG_INFO,
|
||||
'Deleting %s@%s' % (obj_id, model))
|
||||
'Deleting %s@%s' % (db_id, model))
|
||||
try:
|
||||
self.pool.get(model).unlink(cursor, user, [obj_id])
|
||||
if self.unlink_mark[(model, obj_id)]:
|
||||
self.unlink(cursor, user,
|
||||
[self.unlink_mark[(model, obj_id)]])
|
||||
cursor.execute('DELETE FROM ir_values WHERE value=%s',
|
||||
(model + ',' + str(obj_id),))
|
||||
self.pool.get(model).unlink(cursor, user, db_id)
|
||||
data_unlink.append((fs_id, module))
|
||||
except:
|
||||
logger.notify_channel('init', LOG_ERROR,
|
||||
'Could not delete id: %d of model %s\t' \
|
||||
@@ -353,7 +331,18 @@ class ModelData(OSV):
|
||||
'that points to this resource\t' \
|
||||
'You should manually fix this ' \
|
||||
'and restart --update=module' % \
|
||||
(obj_id, model))
|
||||
(db_id, model))
|
||||
|
||||
if data_unlink:
|
||||
cursor.execute("""
|
||||
DELETE FROM ir_model_data
|
||||
WHERE (fs_id, module) in (%s)
|
||||
"""% ','.join(["('%s','%s')"%x for x in data_unlink]))
|
||||
|
||||
del self.fs2values[cursor.dbname]
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
ModelData()
|
||||
+10
-9
@@ -5,7 +5,7 @@
|
||||
<field name="model">ir.model</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Model Description">
|
||||
<field name="name" select="1"/>
|
||||
<field name="model" select="1"/>
|
||||
@@ -28,7 +28,7 @@
|
||||
<field name="model">ir.model</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Model Description">
|
||||
<field name="name"/>
|
||||
<field name="model"/>
|
||||
@@ -55,13 +55,13 @@
|
||||
<field name="view_id" ref="model_view_form"/>
|
||||
<field name="act_window_id" ref="act_model_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/"
|
||||
<menuitem parent_id="ir.menu_ir"
|
||||
action="act_model_form" id="menu_model_form"/>
|
||||
<record model="ir.ui.view" id="model_fields_view_form">
|
||||
<field name="model">ir.model.fields</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Fields">
|
||||
<field name="name" select="1"/>
|
||||
<field name="model_id" readonly="1"/>
|
||||
@@ -76,7 +76,7 @@
|
||||
<field name="model">ir.model.fields</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Fields">
|
||||
<field name="name"/>
|
||||
<field name="field_description"/>
|
||||
@@ -103,13 +103,13 @@
|
||||
<field name="view_id" ref="model_fields_view_form"/>
|
||||
<field name="act_window_id" ref="act_model_fields_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/"
|
||||
<menuitem parent_id="ir.menu_ir"
|
||||
action="act_model_fields_form" id="model_model_fields_form"/>
|
||||
<record model="ir.ui.view" id="model_access_view_tree">
|
||||
<field name="model">ir.model.access</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Access controls">
|
||||
<field name="name"/>
|
||||
<field name="model_id"/>
|
||||
@@ -122,7 +122,7 @@
|
||||
<field name="model">ir.model.access</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Access controls">
|
||||
<field name="name" select="1" colspan="4"/>
|
||||
<field name="model_id" select="1"/>
|
||||
@@ -155,7 +155,8 @@
|
||||
<field name="view_id" ref="model_access_view_form"/>
|
||||
<field name="act_window_id" ref="act_model_access_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/"
|
||||
<menuitem parent_id="ir.menu_ir"
|
||||
action="act_model_access_form" id="menu_model_access_form"/>
|
||||
|
||||
</data>
|
||||
</terp>
|
||||
@@ -5,7 +5,7 @@
|
||||
<field name="model">ir.module.category</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Module Category">
|
||||
<field name="name" colspan="4"/>
|
||||
<field name="parent_id" colspan="4"/>
|
||||
@@ -18,7 +18,7 @@
|
||||
<field name="type">tree</field>
|
||||
<field name="field_parent">child_ids</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Module Categories">
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
@@ -39,7 +39,7 @@
|
||||
<field name="view_id" ref="category_view_tree"/>
|
||||
<field name="act_window_id" ref="act_category_tree"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/Modules/"
|
||||
<menuitem parent_id="menu_modules"
|
||||
action="act_category_tree" id="menu_category_tree"/>
|
||||
</data>
|
||||
</terp>
|
||||
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<menuitem name="Administration/IR/Modules" id="menu_modules"/>
|
||||
<menuitem name="Modules" parent_id="menu_ir" id="menu_modules"/>
|
||||
<record model="ir.ui.view" id="module_view_form">
|
||||
<field name="model">ir.module.module</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Module">
|
||||
<notebook>
|
||||
<page string="Module">
|
||||
@@ -57,7 +57,7 @@
|
||||
<field name="model">ir.module.module</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Modules"
|
||||
colors="blue:state=='to upgrade' or state=='to install';grey:state=='uninstalled' or state=='uninstallable'">
|
||||
<field name="name"/>
|
||||
@@ -67,7 +67,7 @@
|
||||
<field name="latest_version"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
]]>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="act_module_form">
|
||||
@@ -95,7 +95,7 @@
|
||||
<field name="keyword">tree_open</field>
|
||||
<field name="model">ir.module.category,0</field>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/Modules/"
|
||||
<menuitem parent_id="menu_modules"
|
||||
action="act_module_form" id="menu_module_form"/>
|
||||
<record model="ir.actions.wizard" id="act_module_update_list">
|
||||
<field name="name">Update Module List</field>
|
||||
@@ -126,7 +126,8 @@
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/Modules/Update Module List"
|
||||
|
||||
<menuitem name="Update Module List" parent_id="menu_modules"
|
||||
action="act_module_update_list"
|
||||
type="wizard"
|
||||
id="menu_module_update_list"/>
|
||||
@@ -182,7 +183,8 @@
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/Modules/Install \ Upgrade Modules"
|
||||
<menuitem name="Install \ Upgrade Modules"
|
||||
parent_id="menu_modules"
|
||||
action="act_module_install_upgrade"
|
||||
type="wizard"
|
||||
id="menu_module_install_upgrade"/>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<field name="model">ir.module.repository</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Repository">
|
||||
<field name="name" select="1"/>
|
||||
<field name="sequence"/>
|
||||
@@ -20,7 +20,7 @@
|
||||
<field name="model">ir.module.repository</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Repositories">
|
||||
<field name="sequence"/>
|
||||
<field name="active"/>
|
||||
@@ -50,7 +50,7 @@
|
||||
<field name="view_id" ref="repository_view_form"/>
|
||||
<field name="act_window_id" ref="act_repository_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/Modules/"
|
||||
<menuitem parent_id="menu_modules"
|
||||
action="act_repository_form" id="menu_repository_form"/>
|
||||
</data>
|
||||
</terp>
|
||||
@@ -51,8 +51,8 @@
|
||||
<field name="view_id" ref="property_view_form"/>
|
||||
<field name="act_window_id" ref="act_property_form_default"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/"
|
||||
action="act_property_form_default" id="menu_property_form"/>
|
||||
<menuitem parent_id="ir.menu_ir"
|
||||
action="act_property_form_default" id="menu_property_form_default"/>
|
||||
<record model="ir.actions.act_window" id="act_property_form">
|
||||
<field name="name">Properties</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
@@ -73,7 +73,7 @@
|
||||
<field name="view_id" ref="property_view_form"/>
|
||||
<field name="act_window_id" ref="act_property_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/"
|
||||
<menuitem parent_id="ir.menu_ir"
|
||||
action="act_property_form" id="menu_property_form"/>
|
||||
</data>
|
||||
</terp>
|
||||
+6
-6
@@ -5,7 +5,7 @@
|
||||
<field name="model">ir.rule.group</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Record rules">
|
||||
<field name="model_id"/>
|
||||
<field name="global"/>
|
||||
@@ -25,13 +25,13 @@
|
||||
<field name="model">ir.rule.group</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Record rules">
|
||||
<field name="model_id"/>
|
||||
<field name="name"/>
|
||||
<field name="global"/>
|
||||
</tree>
|
||||
]]>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="act_rule_group_form">
|
||||
@@ -53,13 +53,13 @@
|
||||
<field name="view_id" ref="rule_group_view_form"/>
|
||||
<field name="act_window_id" ref="act_rule_group_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/"
|
||||
<menuitem parent_id="ir.menu_ir"
|
||||
action="act_rule_group_form" id="menu_rule_group_form"/>
|
||||
<record model="ir.ui.view" id="rule_view_form">
|
||||
<field name="model">ir.rule</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Test">
|
||||
<group colspan="4" col="6">
|
||||
<field name="field_id"/>
|
||||
@@ -74,7 +74,7 @@
|
||||
<field name="model">ir.rule</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Test">
|
||||
<field name="field_id"/>
|
||||
<field name="operator"/>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<menuitem name="Administration/IR/Sequences" id="menu_sequence"/>
|
||||
<menuitem name="Sequences" parent_id="ir.menu_ir" id="menu_sequence"/>
|
||||
<record model="ir.ui.view" id="sequence_view_form">
|
||||
<field name="model">ir.sequence</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Sequences">
|
||||
<separator string="Configuration" colspan="4"/>
|
||||
<field name="name" colspan="4" select="1"/>
|
||||
@@ -23,14 +23,14 @@
|
||||
<label string="Day: %%(day)s" colspan="4"/>
|
||||
</form>
|
||||
]]>
|
||||
</field>
|
||||
</field>
|
||||
|
||||
</record>
|
||||
<record model="ir.ui.view" id="sequence_view_tree">
|
||||
<field name="model">ir.sequence</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Sequences">
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
@@ -60,13 +60,13 @@
|
||||
<field name="view_id" ref="sequence_view_form"/>
|
||||
<field name="act_window_id" ref="act_sequence_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/Sequences/"
|
||||
<menuitem parent_id="menu_sequence"
|
||||
action="act_sequence_form" id="menu_sequence_form"/>
|
||||
<record model="ir.ui.view" id="sequence_type_view_form">
|
||||
<field name="model">ir.sequence.type</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Sequence Type">
|
||||
<field name="name" select="1"/>
|
||||
<field name="code" readonly="1"/>
|
||||
@@ -78,7 +78,7 @@
|
||||
<field name="model">ir.sequence.type</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Sequence Type">
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
@@ -107,7 +107,7 @@
|
||||
<field name="view_id" ref="sequence_type_view_form"/>
|
||||
<field name="act_window_id" ref="act_sequence_type_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/Sequences/"
|
||||
<menuitem parent_id="menu_sequence"
|
||||
action="act_sequence_type_form" id="menu_ir_sequence_type"/>
|
||||
</data>
|
||||
</terp>
|
||||
@@ -5,7 +5,7 @@
|
||||
<field name="model">ir.translation</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Translations">
|
||||
<field name="name" select="2"/>
|
||||
<field name="res_id" select="2"/>
|
||||
@@ -21,7 +21,7 @@
|
||||
<field name="model">ir.translation</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Translations" editable="bottom">
|
||||
<field name="src"/>
|
||||
<field name="value"/>
|
||||
@@ -29,7 +29,7 @@
|
||||
<field name="lang"/>
|
||||
<field name="type"/>
|
||||
</tree>
|
||||
]]>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="act_translation_form">
|
||||
@@ -51,7 +51,7 @@
|
||||
<field name="view_id" ref="translation_view_form"/>
|
||||
<field name="act_window_id" ref="act_translation_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/Translations"
|
||||
<menuitem name="Translations" parent_id="ir.menu_ir"
|
||||
action="act_translation_form" id="menu_translation_form"/>
|
||||
</data>
|
||||
</terp>
|
||||
@@ -75,7 +75,7 @@
|
||||
<field name="view_id" ref="menu_view_form"/>
|
||||
<field name="act_window_id" ref="act_menu_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/UI/"
|
||||
<menuitem parent_id="menu_ui"
|
||||
action="act_menu_form" id="menu_menu_form"/>
|
||||
</data>
|
||||
</terp>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<menuitem name="Administration/IR/UI" id="menu_ui"/>
|
||||
<menuitem name="UI" parent_id="menu_ir" id="menu_ui"/>
|
||||
</data>
|
||||
</terp>
|
||||
@@ -65,6 +65,9 @@ class View(OSV):
|
||||
return res
|
||||
|
||||
def write(self, cursor, user, ids, vals, context=None):
|
||||
|
||||
if isinstance(ids, (int, long)):
|
||||
ids = [ids]
|
||||
views = self.browse(cursor, user, ids)
|
||||
for view in views:
|
||||
# Restart the cache
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<field name="view_id" ref="view_view_form"/>
|
||||
<field name="act_window_id" ref="act_view_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/UI/"
|
||||
<menuitem parent_id="menu_ui"
|
||||
action="act_view_form" id="menu_view"/>
|
||||
<record model="ir.ui.view" id="view_sc_view_form">
|
||||
<field name="model">ir.ui.view_sc</field>
|
||||
@@ -96,7 +96,7 @@
|
||||
<field name="view_id" ref="view_sc_view_form"/>
|
||||
<field name="act_window_id" ref="act_view_sc_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/UI/"
|
||||
<menuitem parent_id="menu_ui"
|
||||
action="act_view_sc_form" id="menu_view_sc"/>
|
||||
</data>
|
||||
</terp>
|
||||
@@ -5,7 +5,7 @@
|
||||
<field name="model">ir.values</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Values">
|
||||
<field name="name" select="1"/>
|
||||
<field name="model" select="1"/>
|
||||
@@ -24,7 +24,7 @@
|
||||
<field name="model">ir.values</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Values">
|
||||
<field name="name"/>
|
||||
<field name="model"/>
|
||||
@@ -55,7 +55,7 @@
|
||||
<field name="view_id" ref="values_view_form"/>
|
||||
<field name="act_window_id" ref="act_values_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/IR/"
|
||||
<menuitem parent_id="ir.menu_ir"
|
||||
action="act_values_form" id="menu_values_form"/>
|
||||
</data>
|
||||
</terp>
|
||||
+8
-9
@@ -158,8 +158,8 @@ def init_module_objects(cursor, module_name, obj_list):
|
||||
for obj in obj_list:
|
||||
obj.auto_init(cursor)
|
||||
|
||||
def load_module_graph(cursor, graph, **kwargs):
|
||||
# **kwargs is passed directly to convert_xml_import
|
||||
def load_module_graph(cursor, graph):
|
||||
|
||||
package_todo = []
|
||||
statusi = 0
|
||||
for package in graph:
|
||||
@@ -205,8 +205,7 @@ def load_module_graph(cursor, graph, **kwargs):
|
||||
cursor.execute(new_query)
|
||||
else:
|
||||
tools.convert_xml_import(cursor, module,
|
||||
tools.file_open(OPJ(module, filename)),
|
||||
idref, mode=mode, demo=demo, **kwargs)
|
||||
tools.file_open(OPJ(module, filename)))
|
||||
if demo:
|
||||
cursor.execute('UPDATE ir_module_module SET demo = %s ' \
|
||||
'WHERE name = %s', (True, package.name))
|
||||
@@ -218,7 +217,8 @@ def load_module_graph(cursor, graph, **kwargs):
|
||||
statusi += 1
|
||||
|
||||
pool = pooler.get_pool(cursor.dbname)
|
||||
pool.get('ir.model.data')._process_end(cursor, 1, package_todo)
|
||||
# TODO : post_import is called even if there not init nor update
|
||||
pool.get('ir.model.data').post_import(cursor, 1, package_todo)
|
||||
cursor.commit()
|
||||
|
||||
def register_classes():
|
||||
@@ -265,10 +265,9 @@ def load_modules(database, force_demo=False, update_module=False):
|
||||
"WHERE state IN ('installed', 'to upgrade', 'to remove')")
|
||||
module_list = [name for (name,) in cursor.fetchall()]
|
||||
graph = create_graph(module_list, force)
|
||||
report = tools.AssertionReport()
|
||||
load_module_graph(cursor, graph, report=report)
|
||||
if report.get_report():
|
||||
Logger().notify_channel('init', LOG_INFO, 'assert:%s' % report)
|
||||
|
||||
load_module_graph(cursor, graph)
|
||||
|
||||
|
||||
for kind in ('init', 'update'):
|
||||
CONFIG[kind] = {}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<field name="model">res.lang</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Languages" editable="bottom">
|
||||
<field name="name"/>
|
||||
<field name="code"/>
|
||||
@@ -33,7 +33,7 @@
|
||||
<field name="view_id" ref="lang_view_tree"/>
|
||||
<field name="act_window_id" ref="act_lang_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/Res/"
|
||||
<menuitem parent_id="res.menu_res"
|
||||
action="act_lang_form" id="menu_lang_form"/>
|
||||
</data>
|
||||
</terp>
|
||||
@@ -5,7 +5,7 @@
|
||||
<field name="model">res.request</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Requests">
|
||||
<field name="create_date"/>
|
||||
<field name="act_from"/>
|
||||
@@ -22,7 +22,7 @@
|
||||
<field name="model">res.request</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Requests">
|
||||
<notebook>
|
||||
<page string="Request">
|
||||
@@ -81,13 +81,13 @@
|
||||
<field name="view_id" ref="request_view_form"/>
|
||||
<field name="act_window_id" ref="act_request_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/Res/"
|
||||
<menuitem parent_id="res.menu_res"
|
||||
action="act_request_form" id="menu_request_form"/>
|
||||
<record model="ir.ui.view" id="request_link_view_form">
|
||||
<field name="model">res.request.link</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Request Link">
|
||||
<field name="name" select="1"/>
|
||||
<field name="object" select="1"/>
|
||||
@@ -100,7 +100,7 @@
|
||||
<field name="model">res.request.link</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Request Link">
|
||||
<field name="name"/>
|
||||
<field name="object"/>
|
||||
@@ -112,7 +112,7 @@
|
||||
<field name="model">res.request.history</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Request History">
|
||||
<field name="act_from"/>
|
||||
<field name="act_to"/>
|
||||
@@ -126,7 +126,7 @@
|
||||
<field name="model">res.request.history</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Request History">
|
||||
<field name="act_from"/>
|
||||
<field name="act_to"/>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<menuitem name="Administration/Res" id="menu_res"/>
|
||||
<menuitem name="Res" id="menu_res" parent_id="ir.menu_administration"/>
|
||||
</data>
|
||||
</terp>
|
||||
+13
-13
@@ -11,13 +11,13 @@
|
||||
<field name="signature">Administrator</field>
|
||||
<field name="action_id" ref="ir.act_menu_tree"/>
|
||||
<field name="menu_id" ref="ir.act_menu_tree"/>
|
||||
<field name="groups_id" eval="[(6, 0, [group_admin])]"/>
|
||||
<field name="groups_id" eval="[(6, 0, [ref('group_admin')])]"/>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="user_view_form">
|
||||
<field name="model">res.user</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="User">
|
||||
<notebook>
|
||||
<page string="User">
|
||||
@@ -40,19 +40,19 @@
|
||||
</page>
|
||||
</notebook>
|
||||
</form>
|
||||
]]>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="user_view_tree">
|
||||
<field name="model">res.user</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Users">
|
||||
<field name="name"/>
|
||||
<field name="login"/>
|
||||
</tree>
|
||||
]]>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="act_user_form">
|
||||
@@ -75,13 +75,13 @@
|
||||
<field name="view_id" ref="user_view_form"/>
|
||||
<field name="act_window_id" ref="act_user_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/Res/"
|
||||
<menuitem parent_id="res.menu_res"
|
||||
action="act_user_form" id="menu_user_form"/>
|
||||
<record model="ir.ui.view" id="group_view_form">
|
||||
<field name="model">res.group</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Group">
|
||||
<notebook>
|
||||
<page string="Group">
|
||||
@@ -102,7 +102,7 @@
|
||||
<field name="model">res.group</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Groups">
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
@@ -129,13 +129,13 @@
|
||||
<field name="view_id" ref="group_view_form"/>
|
||||
<field name="act_window_id" ref="act_group_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/Res/"
|
||||
<menuitem parent_id="res.menu_res"
|
||||
action="act_group_form" id="menu_group_form"/>
|
||||
<record model="ir.ui.view" id="role_view_form">
|
||||
<field name="model">res.role</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Role">
|
||||
<field name="name" select="1"/>
|
||||
<field name="parent_id"/>
|
||||
@@ -148,7 +148,7 @@
|
||||
<field name="type">tree</field>
|
||||
<field name="field_parent">parent_id</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Roles">
|
||||
<field name="name"/>
|
||||
</tree>
|
||||
@@ -188,9 +188,9 @@
|
||||
<field name="view_id" ref="role_view_tree"/>
|
||||
<field name="act_window_id" ref="act_role_tree"/>
|
||||
</record>
|
||||
<menuitem name="Administration/Res/"
|
||||
<menuitem parent_id="res.menu_res"
|
||||
action="act_role_form" id="menu_role_form"/>
|
||||
<menuitem name="Administration/Res/"
|
||||
<menuitem parent_id="res.menu_res"
|
||||
action="act_role_tree" id="menu_role_tree"/>
|
||||
</data>
|
||||
</terp>
|
||||
+98
-804
@@ -10,775 +10,12 @@ from trytond.config import CONFIG
|
||||
from trytond.version import VERSION
|
||||
import logging
|
||||
|
||||
|
||||
|
||||
CDATA_START = re.compile('^\s*\<\!\[cdata\[', re.IGNORECASE)
|
||||
CDATA_END = re.compile('\]\]\>\s*$', re.IGNORECASE)
|
||||
|
||||
def _ref(self, cursor):
|
||||
return lambda x: self.id_get(cursor, x)
|
||||
# TODO :
|
||||
# Add some exception helper, and give a good diagnostic for the errors
|
||||
|
||||
def _obj(pool, cursor, user, model_str, context=None):
|
||||
model = pool.get(model_str)
|
||||
return lambda x: model.browse(cursor, user, x, context=context)
|
||||
|
||||
def _eval_xml(self, node, pool, cursor, user, idref, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
if node.nodeType == node.TEXT_NODE:
|
||||
return node.data.encode("utf8")
|
||||
elif node.nodeType == node.ELEMENT_NODE:
|
||||
if node.nodeName in ('field','value'):
|
||||
f_type = node.getAttribute('type') or 'char'
|
||||
f_model = node.getAttribute("model").encode('ascii')
|
||||
if len(node.getAttribute('search')):
|
||||
f_search = node.getAttribute("search").encode('utf-8')
|
||||
f_use = node.getAttribute("use").encode('ascii')
|
||||
f_name = node.getAttribute("name").encode('utf-8')
|
||||
if len(f_use)==0:
|
||||
f_use = "id"
|
||||
args = eval(f_search, idref)
|
||||
ids = pool.get(f_model).search(cursor, user, args)
|
||||
if f_use != 'id':
|
||||
ids = [x[f_use] for x in pool.get(f_model).read(
|
||||
cursor, user, ids, [f_use])]
|
||||
_cols = pool.get(f_model)._columns
|
||||
if (f_name in _cols) and _cols[f_name]._type=='many2many':
|
||||
return ids
|
||||
f_val = False
|
||||
if len(ids):
|
||||
f_val = ids[0]
|
||||
if isinstance(f_val, tuple):
|
||||
f_val = f_val[0]
|
||||
return f_val
|
||||
a_eval = node.getAttribute('eval')
|
||||
if len(a_eval):
|
||||
import time
|
||||
idref['time'] = time
|
||||
idref['version'] = VERSION.rsplit('.', 1)[0]
|
||||
idref['ref'] = lambda x: self.id_get(cursor, x)
|
||||
if len(f_model):
|
||||
idref['obj'] = _obj(self.pool, cursor, user, f_model,
|
||||
context=context)
|
||||
try:
|
||||
import pytz
|
||||
except:
|
||||
Logger().notify_channel("init", LOG_INFO,
|
||||
'could not find pytz library')
|
||||
|
||||
|
||||
class Pytz(object):
|
||||
all_timezones = []
|
||||
|
||||
pytz = Pytz()
|
||||
idref['pytz'] = pytz
|
||||
return eval(a_eval, idref)
|
||||
if f_type == 'xml':
|
||||
|
||||
def _process(string, idref):
|
||||
matches = re.findall('[^%]%\((.*?)\)[ds]', string)
|
||||
for i in matches:
|
||||
if not i in idref:
|
||||
idref[i] = self.id_get(cursor, i)
|
||||
return string % idref
|
||||
|
||||
txt = _process("".join([x.toxml().encode("utf8") \
|
||||
for x in node.childNodes]), idref)
|
||||
|
||||
txt = CDATA_START.sub('', txt)
|
||||
txt = CDATA_END.sub('', txt)
|
||||
|
||||
return '<?xml version="1.0"?>\n' + txt
|
||||
if f_type in ('char', 'int', 'float'):
|
||||
value = ""
|
||||
for child_node in node.childNodes:
|
||||
value += str(_eval_xml(self, child_node, pool, cursor,
|
||||
user, idref))
|
||||
if f_type == 'int':
|
||||
value = value.strip()
|
||||
if value == 'None':
|
||||
return None
|
||||
else:
|
||||
value = int(value.strip())
|
||||
elif f_type == 'float':
|
||||
value = float(value.strip())
|
||||
return value
|
||||
elif f_type in ('list', 'tuple'):
|
||||
res = []
|
||||
for child_node in node.childNodes:
|
||||
if child_node.nodeType != child_node.ELEMENT_NODE \
|
||||
or child_node.nodeName != 'value':
|
||||
continue
|
||||
res.append(_eval_xml(self, child_node, pool, cursor,
|
||||
user, idref))
|
||||
if f_type == 'tuple':
|
||||
return tuple(res)
|
||||
return res
|
||||
elif node.nodeName=="getitem":
|
||||
for child_node in node.childNodes:
|
||||
if child_node.nodeType != child_node.ELEMENT_NODE:
|
||||
continue
|
||||
res = _eval_xml(self, child_node, pool, cursor, user, idref)
|
||||
if not res:
|
||||
raise LookupError
|
||||
elif node.getAttribute('type') in ("int", "list"):
|
||||
return res[int(node.getAttribute('index'))]
|
||||
else:
|
||||
return res[node.getAttribute('index').encode("utf8")]
|
||||
elif node.nodeName=="function":
|
||||
args = []
|
||||
a_eval = node.getAttribute('eval')
|
||||
if len(a_eval):
|
||||
idref['ref'] = lambda x: self.id_get(cursor, x)
|
||||
args = eval(a_eval, idref)
|
||||
for child_node in node.childNodes:
|
||||
if child_node.nodeType != child_node.ELEMENT_NODE:
|
||||
continue
|
||||
args.append(_eval_xml(self, child_node, pool, cursor, user,
|
||||
idref, context))
|
||||
model = pool.get(node.getAttribute('model'))
|
||||
method = node.getAttribute('name')
|
||||
res = getattr(model, method)(cursor, user, *args)
|
||||
return res
|
||||
elif node.nodeName=="test":
|
||||
value = ""
|
||||
for child_node in node.childNodes:
|
||||
value += str(_eval_xml(self, child_node, pool, cursor, user,
|
||||
idref, context=context))
|
||||
return value
|
||||
|
||||
ESCAPE_RE = re.compile(r'(?<!\\)/')
|
||||
def escape(i):
|
||||
return i.replace('\\/', '/')
|
||||
|
||||
|
||||
class AssertionReport(object):
|
||||
|
||||
def __init__(self):
|
||||
self._report = {}
|
||||
|
||||
def record_assertion(self, success, severity):
|
||||
"""
|
||||
Records the result of an assertion for the failed/success count
|
||||
retrurns success
|
||||
"""
|
||||
if severity in self._report:
|
||||
self._report[severity][success] += 1
|
||||
else:
|
||||
self._report[severity] = {success:1, not success: 0}
|
||||
return success
|
||||
|
||||
def get_report(self):
|
||||
return self._report
|
||||
|
||||
def __str__(self):
|
||||
res = '\nAssertions report:\nLevel\tsuccess\tfailed\n'
|
||||
success = failed = 0
|
||||
for sev in self._report:
|
||||
res += sev + '\t' + str(self._report[sev][True]) + '\t' + \
|
||||
str(self._report[sev][False]) + '\n'
|
||||
success += self._report[sev][True]
|
||||
failed += self._report[sev][False]
|
||||
res += 'total\t' + str(success) + '\t' + str(failed) + '\n'
|
||||
res += 'end of report (' + str(success + failed) + \
|
||||
' assertion(s) checked)'
|
||||
return res
|
||||
|
||||
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'))
|
||||
|
||||
def get_context(self, data_node, node, eval_dict):
|
||||
data_node_context = (data_node \
|
||||
and data_node.getAttribute('context').encode('utf8'))
|
||||
if data_node_context:
|
||||
context = eval(data_node_context, eval_dict)
|
||||
else:
|
||||
context = {}
|
||||
|
||||
node_context = node.getAttribute("context").encode('utf8')
|
||||
if len(node_context):
|
||||
context.update(eval(node_context, eval_dict))
|
||||
|
||||
return context
|
||||
|
||||
def get_uid(self, cursor, user, data_node, node):
|
||||
node_uid = node.getAttribute('user') or (data_node \
|
||||
and data_node.getAttribute('user'))
|
||||
if len(node_uid):
|
||||
return self.id_get(cursor, node_uid)
|
||||
return user
|
||||
|
||||
def _test_xml_id(self, xml_id):
|
||||
obj_id = xml_id
|
||||
if '.' in xml_id:
|
||||
obj_id = xml_id.split('.')[1]
|
||||
if len(obj_id) > 64:
|
||||
Logger().notify_channel('init', LOG_ERROR,
|
||||
'id: %s is to long (max: 64)' % xml_id)
|
||||
def _tag_delete(self, cursor, rec, data_node=None):
|
||||
d_model = rec.getAttribute("model")
|
||||
d_search = rec.getAttribute("search")
|
||||
d_id = rec.getAttribute("id")
|
||||
ids = []
|
||||
if len(d_search):
|
||||
ids = self.pool.get(d_model).search(cursor, self.user,
|
||||
eval(d_search))
|
||||
if len(d_id):
|
||||
ids.append(self.id_get(cursor, d_id))
|
||||
if len(ids):
|
||||
self.pool.get(d_model).unlink(cursor, self.user, ids)
|
||||
#self.pool.get('ir.model.data')._unlink(cursor, self.user, d_model,
|
||||
# ids, direct=True)
|
||||
return False
|
||||
|
||||
def _tag_report(self, cursor, rec, data_node=None):
|
||||
res = {}
|
||||
for dest, attr in (
|
||||
('name', 'string'),
|
||||
('model', 'model'),
|
||||
('report_name', 'name'),
|
||||
):
|
||||
res[dest] = rec.getAttribute(attr).encode('utf8')
|
||||
assert res[dest], "Attribute %s of report is empty !" % (attr,)
|
||||
for field, dest in (
|
||||
('rml', 'report_rml'),
|
||||
('xml', 'report_xml'),
|
||||
('xsl', 'report_xsl'),
|
||||
):
|
||||
if rec.hasAttribute(field):
|
||||
res[dest] = rec.getAttribute(field).encode('utf8')
|
||||
if rec.hasAttribute('auto'):
|
||||
res['auto'] = eval(rec.getAttribute('auto'))
|
||||
if rec.hasAttribute('header'):
|
||||
res['header'] = eval(rec.getAttribute('header'))
|
||||
res['multi'] = rec.hasAttribute('multi') \
|
||||
and eval(rec.getAttribute('multi'))
|
||||
xml_id = rec.getAttribute('id').encode('utf8')
|
||||
self._test_xml_id(xml_id)
|
||||
obj_id = self.pool.get('ir.model.data')._update(cursor, self.user,
|
||||
"ir.actions.report.xml", self.module, res, xml_id,
|
||||
mode=self.mode)
|
||||
self.idref[xml_id] = int(obj_id)
|
||||
if not rec.hasAttribute('menu') or eval(rec.getAttribute('menu')):
|
||||
keyword = str(rec.getAttribute('keyword') or 'client_print_multi')
|
||||
value = 'ir.actions.report.xml,' + str(obj_id)
|
||||
replace = rec.hasAttribute('replace') \
|
||||
and rec.getAttribute("replace")
|
||||
self.pool.get('ir.model.data').ir_set(cursor, self.user, 'action',
|
||||
keyword, res['name'], [res['model']], value,
|
||||
replace=replace, isobject=True, xml_id=xml_id)
|
||||
return False
|
||||
|
||||
def _tag_function(self, cursor, rec, data_node=None):
|
||||
if self.isnoupdate(data_node) and self.mode != 'init':
|
||||
return
|
||||
context = self.get_context(data_node, rec, {'ref': _ref(self, cursor)})
|
||||
user = self.get_uid(cursor, self.user, data_node, rec)
|
||||
_eval_xml(self, rec, self.pool, cursor, user, self.idref,
|
||||
context=context)
|
||||
return False
|
||||
|
||||
def _tag_wizard(self, cursor, rec, data_node=None):
|
||||
string = rec.getAttribute("string").encode('utf8')
|
||||
model = rec.getAttribute("model").encode('utf8')
|
||||
name = rec.getAttribute("name").encode('utf8')
|
||||
xml_id = rec.getAttribute('id').encode('utf8')
|
||||
self._test_xml_id(xml_id)
|
||||
multi = rec.hasAttribute('multi') and eval(rec.getAttribute('multi'))
|
||||
res = {'name': string, 'wiz_name': name, 'multi':multi}
|
||||
|
||||
obj_id = self.pool.get('ir.model.data')._update(cursor, self.user,
|
||||
"ir.actions.wizard", self.module, res, xml_id, mode=self.mode)
|
||||
self.idref[xml_id] = int(obj_id)
|
||||
# ir_set
|
||||
if (not rec.hasAttribute('menu') or eval(rec.getAttribute('menu'))) \
|
||||
and obj_id:
|
||||
keyword = str(rec.getAttribute('keyword') or 'client_action_multi')
|
||||
value = 'ir.actions.wizard,' + str(obj_id)
|
||||
replace = rec.hasAttribute('replace') and \
|
||||
rec.getAttribute("replace") or True
|
||||
self.pool.get('ir.model.data').ir_set(cursor, self.user, 'action',
|
||||
keyword, string, [model], value, replace=replace,
|
||||
isobject=True, xml_id=xml_id)
|
||||
return False
|
||||
|
||||
def _tag_act_window(self, cursor, rec, data_node=None):
|
||||
name = rec.hasAttribute('name') \
|
||||
and rec.getAttribute('name').encode('utf-8')
|
||||
xml_id = rec.getAttribute('id').encode('utf8')
|
||||
self._test_xml_id(xml_id)
|
||||
ftype = rec.hasAttribute('type') \
|
||||
and rec.getAttribute('type').encode('utf-8') \
|
||||
or 'ir.actions.act_window'
|
||||
view_id = False
|
||||
if rec.hasAttribute('view'):
|
||||
view_id = self.id_get(cursor,
|
||||
rec.getAttribute('view').encode('utf-8'))
|
||||
domain = rec.hasAttribute('domain') \
|
||||
and rec.getAttribute('domain').encode('utf-8')
|
||||
context = rec.hasAttribute('context') \
|
||||
and rec.getAttribute('context').encode('utf-8') \
|
||||
or '{}'
|
||||
res_model = rec.getAttribute('res_model').encode('utf-8')
|
||||
src_model = rec.hasAttribute('src_model') \
|
||||
and rec.getAttribute('src_model').encode('utf-8')
|
||||
view_type = rec.hasAttribute('view_type') \
|
||||
and rec.getAttribute('view_type').encode('utf-8') \
|
||||
or 'form'
|
||||
view_mode = rec.hasAttribute('view_mode') \
|
||||
and rec.getAttribute('view_mode').encode('utf-8') \
|
||||
or 'tree,form'
|
||||
usage = rec.hasAttribute('usage') \
|
||||
and rec.getAttribute('usage').encode('utf-8')
|
||||
limit = rec.hasAttribute('limit') \
|
||||
and rec.getAttribute('limit').encode('utf-8')
|
||||
auto_refresh = rec.hasAttribute('auto_refresh') \
|
||||
and rec.getAttribute('auto_refresh').encode('utf-8')
|
||||
|
||||
res = {
|
||||
'name': name,
|
||||
'type': ftype,
|
||||
'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,
|
||||
'limit': limit,
|
||||
'auto_refresh': auto_refresh,
|
||||
}
|
||||
|
||||
obj_id = self.pool.get('ir.model.data')._update(cursor, self.user,
|
||||
'ir.actions.act_window', self.module, res, xml_id,
|
||||
mode=self.mode)
|
||||
self.idref[xml_id] = int(obj_id)
|
||||
|
||||
if src_model:
|
||||
keyword = 'client_action_relate'
|
||||
value = 'ir.actions.act_window,' + str(obj_id)
|
||||
replace = rec.hasAttribute('replace') \
|
||||
and rec.getAttribute('replace')
|
||||
self.pool.get('ir.model.data').ir_set(cursor, self.user, 'action',
|
||||
keyword, xml_id, [src_model], value, replace=replace,
|
||||
isobject=True, xml_id=xml_id)
|
||||
# TODO add remove ir.model.data
|
||||
return False
|
||||
|
||||
def _tag_ir_set(self, cursor, rec, data_node=None):
|
||||
if not self.mode == 'init':
|
||||
return False
|
||||
res = {}
|
||||
for field in [i for i in rec.childNodes \
|
||||
if (i.nodeType == i.ELEMENT_NODE and i.nodeName=="field")]:
|
||||
f_name = field.getAttribute("name").encode('utf-8')
|
||||
f_val = _eval_xml(self, field, self.pool, cursor, self.user,
|
||||
self.idref)
|
||||
res[f_name] = f_val
|
||||
self.pool.get('ir.model.data').ir_set(cursor, self.user, 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))
|
||||
return False
|
||||
|
||||
def _tag_workflow(self, cursor, rec, data_node=None):
|
||||
if self.isnoupdate(data_node) and self.mode != 'init':
|
||||
return
|
||||
model = str(rec.getAttribute('model'))
|
||||
w_ref = rec.getAttribute('ref')
|
||||
if len(w_ref):
|
||||
obj_id = self.id_get(cursor, w_ref)
|
||||
else:
|
||||
assert rec.childNodes, 'You must define a child node ' \
|
||||
'if you dont give a ref'
|
||||
element_childs = [i for i in rec.childNodes \
|
||||
if i.nodeType == i.ELEMENT_NODE]
|
||||
assert len(element_childs) == 1, 'Only one child node ' \
|
||||
'is accepted (%d given)' % len(rec.childNodes)
|
||||
obj_id = _eval_xml(self, element_childs[0], self.pool, cursor,
|
||||
self.user, self.idref)
|
||||
|
||||
user = self.get_uid(cursor, self.user, data_node, rec)
|
||||
wf_service = LocalService("workflow")
|
||||
wf_service.trg_validate(user, model,
|
||||
obj_id,
|
||||
str(rec.getAttribute('action')), cursor)
|
||||
return False
|
||||
|
||||
def _tag_menuitem(self, cursor, rec, data_node=None):
|
||||
rec_id = rec.getAttribute("id").encode('ascii')
|
||||
assert rec_id, "No id on menutiem %s" % \
|
||||
rec.getAttribute("name").encode('utf8')
|
||||
self._test_xml_id(rec_id)
|
||||
m_l = [escape(x) for x in ESCAPE_RE.split(
|
||||
rec.getAttribute("name").encode('utf8'))]
|
||||
pid = False
|
||||
for idx, menu_elem in enumerate(m_l):
|
||||
if pid:
|
||||
cursor.execute('SELECT id FROM ir_ui_menu ' \
|
||||
'WHERE parent_id = %d AND name = %s',
|
||||
(pid, menu_elem))
|
||||
else:
|
||||
cursor.execute('SELECT id FROM ir_ui_menu ' \
|
||||
'WHERE parent_id IS NULL AND name = %s',
|
||||
(menu_elem,))
|
||||
res = cursor.fetchone()
|
||||
if idx == (len(m_l) - 1):
|
||||
# we are at the last menu element/level (it's a leaf)
|
||||
values = {'parent_id': pid, 'name': menu_elem}
|
||||
|
||||
if rec.hasAttribute('action'):
|
||||
a_action = rec.getAttribute('action').encode('utf8')
|
||||
a_type = rec.getAttribute('type').encode('utf8') \
|
||||
or 'act_window'
|
||||
icons = {
|
||||
"act_window": 'STOCK_NEW',
|
||||
"report.xml": 'STOCK_PASTE',
|
||||
"wizard": 'STOCK_EXECUTE',
|
||||
"url": 'STOCK_JUMP_TO'
|
||||
}
|
||||
values['icon'] = icons.get(a_type,'STOCK_NEW')
|
||||
if a_type == 'act_window':
|
||||
a_id = self.id_get(cursor, a_action)
|
||||
cursor.execute('SELECT view_type, ' \
|
||||
'name, view_id ' \
|
||||
'FROM ir_act_window ' \
|
||||
'WHERE id = %d', (int(a_id),))
|
||||
action_type, action_name, view_id = \
|
||||
cursor.fetchone()
|
||||
if view_id:
|
||||
cursor.execute('SELECT type FROM ir_ui_view ' \
|
||||
'WHERE id = %d', (int(view_id),))
|
||||
action_mode, = cursor.fetchone()
|
||||
cursor.execute('SELECT view_mode ' \
|
||||
'FROM ir_act_window_view ' \
|
||||
'WHERE act_window_id = %d ' \
|
||||
'ORDER BY sequence LIMIT 1', (int(a_id),))
|
||||
if cursor.rowcount:
|
||||
action_mode, = cursor.fetchone()
|
||||
if action_type == 'tree':
|
||||
values['icon'] = 'STOCK_INDENT'
|
||||
elif action_mode and action_mode.startswith('tree'):
|
||||
values['icon'] = 'STOCK_JUSTIFY_FILL'
|
||||
elif action_mode and action_mode.startswith('graph'):
|
||||
values['icon'] = 'terp-graph'
|
||||
elif action_mode and action_mode.startswith('calendar'):
|
||||
values['icon'] = 'terp-calendar'
|
||||
if not values['name']:
|
||||
values['name'] = action_name
|
||||
if rec.hasAttribute('sequence'):
|
||||
values['sequence'] = int(rec.getAttribute('sequence'))
|
||||
if rec.hasAttribute('icon'):
|
||||
values['icon'] = str(rec.getAttribute('icon'))
|
||||
if rec.hasAttribute('groups'):
|
||||
g_names = rec.getAttribute('groups').split(',')
|
||||
groups_value = []
|
||||
groups_obj = self.pool.get('res.group')
|
||||
for group in g_names:
|
||||
if group.startswith('-'):
|
||||
group_id = self.id_get(cursor, group[1:])
|
||||
groups_value.append((3, group_id))
|
||||
else:
|
||||
group_id = self.id_get(cursor, group)
|
||||
groups_value.append((4, group_id))
|
||||
values['groups_id'] = groups_value
|
||||
if rec.hasAttribute('action'):
|
||||
a_action = rec.getAttribute('action').encode('utf8')
|
||||
a_type = rec.getAttribute('type').encode('utf8') \
|
||||
or 'act_window'
|
||||
a_id = self.id_get(cursor, a_action)
|
||||
values['action'] = "ir.actions.%s,%d" % (a_type, a_id)
|
||||
xml_id = rec.getAttribute('id').encode('utf8')
|
||||
self._test_xml_id(xml_id)
|
||||
pid = self.pool.get('ir.model.data')._update(cursor, self.user,
|
||||
'ir.ui.menu', self.module, values, xml_id,
|
||||
mode=self.mode, res_id=(res and res[0] or False))
|
||||
else:
|
||||
assert res, "The parent menuitem %s does not exist!" % \
|
||||
(menu_elem,)
|
||||
pid = res[0]
|
||||
self.idref[rec_id] = int(pid)
|
||||
return ('ir.ui.menu', pid)
|
||||
|
||||
def _assert_equals(self, i, j, prec=4):
|
||||
return not round(i - j, prec)
|
||||
|
||||
def _tag_assert(self, cursor, rec, data_node=None):
|
||||
if self.isnoupdate(data_node) and self.mode != 'init':
|
||||
return
|
||||
|
||||
rec_model = rec.getAttribute("model").encode('ascii')
|
||||
model = self.pool.get(rec_model)
|
||||
assert model, "The model %s does not exist !" % (rec_model,)
|
||||
rec_id = rec.getAttribute("id").encode('ascii')
|
||||
self._test_xml_id(rec_id)
|
||||
rec_src = rec.getAttribute("search").encode('utf8')
|
||||
rec_src_count = rec.getAttribute("count")
|
||||
|
||||
severity = rec.getAttribute("severity").encode('ascii') or 'info'
|
||||
|
||||
rec_string = rec.getAttribute("string").encode('utf8') or 'unknown'
|
||||
|
||||
ids = None
|
||||
eval_dict = {'ref': _ref(self, cursor)}
|
||||
context = self.get_context(data_node, rec, eval_dict)
|
||||
user = self.get_uid(cursor, self.user, data_node, rec)
|
||||
if len(rec_id):
|
||||
ids = [self.id_get(cursor, rec_id)]
|
||||
elif len(rec_src):
|
||||
args = eval(rec_src, eval_dict)
|
||||
ids = self.pool.get(rec_model).search(cursor, user, args,
|
||||
context=context)
|
||||
if len(rec_src_count):
|
||||
count = int(rec_src_count)
|
||||
if len(ids) != count:
|
||||
self.assert_report.record_assertion(False, severity)
|
||||
Logger().notify_channel('init', severity,
|
||||
'assertion "' + rec_string + \
|
||||
'" failed ! (search count is incorrect: ' \
|
||||
+ str(len(ids)) + ')' )
|
||||
sevval = getattr(logging, severity.upper())
|
||||
if sevval > CONFIG['assert_exit_level']:
|
||||
# TODO: define a dedicated exception
|
||||
raise Exception('Severe assertion failure')
|
||||
return
|
||||
|
||||
assert ids != None, 'You must give either an id or a search criteria'
|
||||
|
||||
ref = _ref(self, cursor)
|
||||
for brrec in model.browse(cursor, user, ids, context):
|
||||
|
||||
|
||||
class Dict(dict):
|
||||
|
||||
def __getitem__(self, key):
|
||||
if key in brrec:
|
||||
return brrec[key]
|
||||
return dict.__getitem__(self, key)
|
||||
|
||||
eval_globals = Dict()
|
||||
eval_globals['floatEqual'] = self._assert_equals
|
||||
eval_globals['ref'] = ref
|
||||
eval_globals['_ref'] = ref
|
||||
for test in [i for i in rec.childNodes \
|
||||
if (i.nodeType == i.ELEMENT_NODE and i.nodeName=="test")]:
|
||||
f_expr = test.getAttribute("expr").encode('utf-8')
|
||||
f_val = _eval_xml(self, test, self.pool, cursor, user,
|
||||
self.idref, context=context) or True
|
||||
if eval(f_expr, eval_globals) != f_val: # assertion failed
|
||||
self.assert_report.record_assertion(False, severity)
|
||||
Logger().notify_channel('init', severity,
|
||||
'assertion "' + rec_string + \
|
||||
'" failed ! (tag ' + test.toxml() + ')' )
|
||||
sevval = getattr(logging, severity.upper())
|
||||
if sevval > CONFIG['assert_exit_level']:
|
||||
# TODO: define a dedicated exception
|
||||
raise Exception('Severe assertion failure')
|
||||
return
|
||||
else: # all tests were successful for this assertion tag (no break)
|
||||
self.assert_report.record_assertion(True, severity)
|
||||
|
||||
def _tag_record(self, cursor, rec, data_node=None):
|
||||
rec_model = rec.getAttribute("model").encode('ascii')
|
||||
model = self.pool.get(rec_model)
|
||||
assert model, "The model %s does not exist !" % (rec_model,)
|
||||
rec_id = rec.getAttribute("id").encode('ascii')
|
||||
self._test_xml_id(rec_id)
|
||||
|
||||
# if not rec_id and not self.isnoupdate(data_node):
|
||||
# print "Warning", rec_model
|
||||
|
||||
if self.isnoupdate(data_node) and not self.mode == 'init':
|
||||
# check if the xml record has an id string
|
||||
if rec_id:
|
||||
obj_id = self.pool.get('ir.model.data')._update_dummy(cursor,
|
||||
self.user, rec_model, self.module, rec_id)
|
||||
# check if the resource already existed at the last update
|
||||
if obj_id:
|
||||
# if it existed, we don't update the data, but we need to
|
||||
# know the id of the existing record anyway
|
||||
self.idref[rec_id] = int(obj_id)
|
||||
return None
|
||||
else:
|
||||
# if the resource didn't exist
|
||||
if rec.getAttribute("forcecreate"):
|
||||
# we want to create it, so we let the normal
|
||||
# "update" behavior happen
|
||||
pass
|
||||
else:
|
||||
# otherwise do nothing
|
||||
return None
|
||||
else:
|
||||
# otherwise it is skipped
|
||||
return None
|
||||
|
||||
res = {}
|
||||
for field in [i for i in rec.childNodes \
|
||||
if (i.nodeType == i.ELEMENT_NODE and i.nodeName=="field")]:
|
||||
#TODO: most of this code is duplicated above (in _eval_xml)
|
||||
f_name = field.getAttribute("name").encode('utf-8')
|
||||
f_ref = field.getAttribute("ref").encode('ascii')
|
||||
f_search = field.getAttribute("search").encode('utf-8')
|
||||
f_model = field.getAttribute("model").encode('ascii')
|
||||
if not f_model and model._columns.get(f_name, False):
|
||||
f_model = model._columns[f_name]._obj
|
||||
f_use = field.getAttribute("use").encode('ascii') or 'id'
|
||||
f_val = False
|
||||
|
||||
if len(f_search):
|
||||
args = eval(f_search, self.idref)
|
||||
field = []
|
||||
assert f_model, 'Define an attribute ' \
|
||||
'model="..." in your .XML file !'
|
||||
f_obj = self.pool.get(f_model)
|
||||
# browse the objects searched
|
||||
objs = f_obj.browse(cursor, self.user, f_obj.search(cursor,
|
||||
self.user, args))
|
||||
# column definitions of the "local" object
|
||||
_cols = self.pool.get(rec_model)._columns
|
||||
# if the current field is many2many
|
||||
if (f_name in _cols) and _cols[f_name]._type=='many2many':
|
||||
f_val = [(6, 0, [x[f_use] for x in objs])]
|
||||
elif len(objs):
|
||||
# otherwise (we are probably in a many2one field),
|
||||
# take the first element of the search
|
||||
f_val = objs[0][f_use]
|
||||
elif len(f_ref):
|
||||
if f_ref == "null":
|
||||
f_val = False
|
||||
else:
|
||||
f_val = self.id_get(cursor, f_ref)
|
||||
else:
|
||||
f_val = _eval_xml(self, field, self.pool, cursor, self.user,
|
||||
self.idref)
|
||||
|
||||
if model._columns.has_key(f_name):
|
||||
if isinstance(model._columns[f_name], Integer):
|
||||
f_val = int(f_val)
|
||||
res[f_name] = f_val
|
||||
obj_id = self.pool.get('ir.model.data')._update(cursor, self.user,
|
||||
rec_model, self.module, res, rec_id or False,
|
||||
noupdate=self.isnoupdate(data_node), mode=self.mode)
|
||||
if rec_id:
|
||||
self.idref[rec_id] = int(obj_id)
|
||||
return rec_model, obj_id
|
||||
|
||||
def id_get(self, cursor, id_str):
|
||||
if id_str in self.idref:
|
||||
return self.idref[id_str]
|
||||
mod = self.module
|
||||
if '.' in id_str:
|
||||
mod, id_str = id_str.split('.')
|
||||
result = self.pool.get('ir.model.data')._get_id(cursor, self.user,
|
||||
mod, id_str)
|
||||
return int(self.pool.get('ir.model.data').read(cursor, self.user,
|
||||
[result], ['res_id'])[0]['res_id'])
|
||||
|
||||
def parse(self, xmlstr):
|
||||
doc = xml.dom.minidom.parseString(xmlstr)
|
||||
elem = doc.documentElement
|
||||
for node in [i for i in elem.childNodes \
|
||||
if (i.nodeType == i.ELEMENT_NODE and i.nodeName=="data")]:
|
||||
for rec in node.childNodes:
|
||||
if rec.nodeType == rec.ELEMENT_NODE:
|
||||
if rec.nodeName in self._tags:
|
||||
try:
|
||||
self._tags[rec.nodeName](self.cursor, rec, node)
|
||||
except:
|
||||
Logger().notify_channel("init", LOG_INFO,
|
||||
'\n'+rec.toxml())
|
||||
self.cursor.rollback()
|
||||
raise
|
||||
return True
|
||||
|
||||
def __init__(self, cursor, module, idref, mode, report=AssertionReport(),
|
||||
noupdate=False, demo=False):
|
||||
self.mode = mode
|
||||
self.module = module
|
||||
self.cursor = cursor
|
||||
self.idref = idref
|
||||
self.pool = pooler.get_pool(cursor.dbname)
|
||||
self.user = 1
|
||||
self.assert_report = report
|
||||
self.noupdate = noupdate
|
||||
self.demo = demo
|
||||
self._tags = {
|
||||
'menuitem': self._tag_menuitem,
|
||||
'record': self._tag_record,
|
||||
'assert': self._tag_assert,
|
||||
'report': self._tag_report,
|
||||
'wizard': self._tag_wizard,
|
||||
'delete': self._tag_delete,
|
||||
'ir_set': self._tag_ir_set,
|
||||
'function': self._tag_function,
|
||||
'workflow': self._tag_workflow,
|
||||
'act_window': self._tag_act_window,
|
||||
}
|
||||
|
||||
def convert_csv_import(cursor, module, fname, csvcontent, idref=None,
|
||||
mode='init', noupdate=False):
|
||||
'''
|
||||
Import csv file :
|
||||
quote: "
|
||||
delimiter: ,
|
||||
encoding: utf-8
|
||||
'''
|
||||
if idref is None:
|
||||
idref = {}
|
||||
model = ('.'.join(fname.split('.')[:-1]).split('-'))[0]
|
||||
#remove folder path from model
|
||||
model = os.path.split(model)[1]
|
||||
|
||||
pool = pooler.get_pool(cursor.dbname)
|
||||
|
||||
input_file = StringIO.StringIO(csvcontent)
|
||||
reader = csv.reader(input_file, quotechar='"', delimiter=',')
|
||||
fields = reader.next()
|
||||
|
||||
if not (mode == 'init' or 'id' in fields):
|
||||
return
|
||||
|
||||
user = 1
|
||||
datas = []
|
||||
for line in reader:
|
||||
if (not line) or not reduce(lambda x, y: x or y, line) :
|
||||
continue
|
||||
datas.append([x.decode('utf8').encode('utf8') for x in line])
|
||||
pool.get(model).import_data(cursor, user, fields, datas, mode,
|
||||
module, noupdate)
|
||||
|
||||
def convert_xml_import_dom(cursor, module, xmlstream, idref=None, mode='init',
|
||||
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, demo=demo)
|
||||
obj.parse(xmlstream.read())
|
||||
del obj
|
||||
return True
|
||||
|
||||
|
||||
|
||||
|
||||
#$$
|
||||
# Notes:
|
||||
# - classe monolythique vs instancier des sous-classe par type de record
|
||||
# (que l'on re-reference a la volee des qu'on lit le debut du record).
|
||||
# - utilser des pointeur de fct plutot que que inTitle=1
|
||||
# - analyser le code _update, source d'amelioration
|
||||
# - ajouter un handler d'exception
|
||||
# - faire un cache en debut de traitement : {xml_id: (db_id, model)}
|
||||
|
||||
# tuto : http://pyxml.sourceforge.net/topics/howto/node14.html
|
||||
|
||||
from xml import sax
|
||||
|
||||
@@ -803,10 +40,69 @@ class DummyTagHandler:
|
||||
class MenuitemTagHandler:
|
||||
"""Taghandler for the tag <record> """
|
||||
def __init__(self, master_handler):
|
||||
pass
|
||||
self.mh = master_handler
|
||||
|
||||
def startElement(self, name, attributes):
|
||||
return
|
||||
|
||||
values = {}
|
||||
|
||||
self.xml_id = attributes['id']
|
||||
|
||||
for attr in ('name', 'icon', 'sequence', 'parent_id', 'action',):
|
||||
if attributes.get(attr):
|
||||
values[attr] = attributes.get(attr).encode('utf8')
|
||||
|
||||
|
||||
if values.get('parent_id'):
|
||||
values['parent_id'] = self.mh.get_id(values['parent_id'])
|
||||
|
||||
action_name = False
|
||||
if values.get('action'):
|
||||
action_id = self.mh.get_id(values['action'])
|
||||
|
||||
# TODO maybe use a prefetch for this:
|
||||
self.mh.cursor.execute(
|
||||
"SELECT a.name, a.type, v.type, wv.view_mode " \
|
||||
"FROM ir_actions a " \
|
||||
"LEFT JOIN ir_act_window act on (a.id = act.id) " \
|
||||
"LEFT JOIN ir_ui_view v on (v.id = act.view_id) " \
|
||||
"LEFT JOIN ir_act_window_view wv on (a.id = wv.act_window_id) " \
|
||||
"WHERE a.id = %d " \
|
||||
"ORDER by wv.sequence " \
|
||||
"LIMIT 1", (action_id,))
|
||||
action_name, action_type, view_type, view_mode = \
|
||||
self.mh.cursor.fetchone()
|
||||
|
||||
values['action'] = '%s,%d' % (action_type, action_id)
|
||||
|
||||
icon = attributes.get('icon', '').encode('utf8')
|
||||
if icon:
|
||||
values['icon'] = icon
|
||||
elif action_type == 'ir.actions.wizard':
|
||||
values['icon'] = 'STOCK_EXECUTE'
|
||||
elif action_type == 'ir.actions.report':
|
||||
values['icon'] = 'STOCK_PRINT'
|
||||
elif action_type == 'ir.actions.act_window':
|
||||
if view_type == 'tree':
|
||||
values['icon'] = 'STOCK_INDENT'
|
||||
elif view_mode and view_mode.startswith('tree'):
|
||||
values['icon'] = 'STOCK_JUSTIFY_FILL'
|
||||
elif view_mode and view_mode.startswith('graph'):
|
||||
values['icon'] = 'terp-graph'
|
||||
elif view_mode and view_mode.startswith('calendar'):
|
||||
values['icon'] = 'terp-calendar'
|
||||
else:
|
||||
values['icon'] = 'STOCK_NEW'
|
||||
|
||||
if not values.get('name'):
|
||||
if not action_name:
|
||||
raise Exception("Please provide at least a 'name' attributes "
|
||||
"or a 'action' attributes on the menuitem tags.")
|
||||
else:
|
||||
values['name'] = action_name
|
||||
|
||||
self.values = values
|
||||
|
||||
|
||||
def characters(self, data):
|
||||
pass
|
||||
@@ -816,6 +112,10 @@ class MenuitemTagHandler:
|
||||
if name != "menuitem":
|
||||
return self
|
||||
else:
|
||||
|
||||
res = self.mh.pool.get('ir.model.data').import_record(
|
||||
self.mh.cursor, self.mh.user,
|
||||
'ir.ui.menu', self.mh.module, self.values, self.xml_id)
|
||||
return None
|
||||
|
||||
|
||||
@@ -827,6 +127,7 @@ class RecordTagHandler:
|
||||
# Remind reference of parent handler
|
||||
self.mh = master_handler
|
||||
|
||||
|
||||
def startElement(self, name, attributes):
|
||||
|
||||
# Manage the top level tag
|
||||
@@ -866,8 +167,7 @@ class RecordTagHandler:
|
||||
cursor, self.mh.user,
|
||||
model.search(self.mh.cursor,self.mh.user, search_attr))
|
||||
|
||||
if not answer:
|
||||
return
|
||||
if not answer: return
|
||||
|
||||
if field_name in model._columns:
|
||||
if model._columns[field_name]._type == 'many2many':
|
||||
@@ -877,14 +177,27 @@ class RecordTagHandler:
|
||||
self.values[field_name] = answer[0]['id']
|
||||
|
||||
elif ref_attr:
|
||||
# TODO avec cache sur les ids..:
|
||||
#self.id_get(cursor, f_ref)
|
||||
self.values[field_name] = self.mh.get_id(ref_attr)
|
||||
|
||||
elif eval_attr:
|
||||
print "NOT IMPLEMENTED : eval"
|
||||
pass
|
||||
|
||||
import time
|
||||
context = {}
|
||||
context['time'] = time
|
||||
context['version'] = VERSION.rsplit('.', 1)[0]
|
||||
context['ref'] = self.mh.get_id
|
||||
context['obj'] = lambda *a: 1
|
||||
try:
|
||||
import pytz
|
||||
except:
|
||||
Logger().notify_channel("init", LOG_INFO,
|
||||
'could not find pytz library')
|
||||
class Pytz(object):
|
||||
all_timezones = []
|
||||
|
||||
pytz = Pytz()
|
||||
context['pytz'] = pytz
|
||||
self.values[field_name] = eval(eval_attr, context)
|
||||
|
||||
else:
|
||||
raise Exception("Tags '%s' not supported inside tag record."% (name,))
|
||||
@@ -924,15 +237,9 @@ class RecordTagHandler:
|
||||
return self
|
||||
|
||||
elif name == "record":
|
||||
# db access: TODO : use the object reference instead of
|
||||
# the name of the model because _update do a new get to
|
||||
# obtain the reference
|
||||
|
||||
|
||||
res = self.mh.pool.get('ir.model.data')._update(
|
||||
res = self.mh.pool.get('ir.model.data').import_record(
|
||||
self.mh.cursor, self.mh.user,
|
||||
self.model._name, self.mh.module, self.values, self.xml_id,
|
||||
noupdate=self.mh.noupdate, mode=self.mh.mode)
|
||||
self.model._name, self.mh.module, self.values, self.xml_id)
|
||||
|
||||
return None
|
||||
else:
|
||||
@@ -941,16 +248,15 @@ class RecordTagHandler:
|
||||
|
||||
class TrytondXmlHandler(sax.handler.ContentHandler):
|
||||
|
||||
def __init__(self, cursor, pool, mode, module, noupdate):
|
||||
def __init__(self, cursor, pool, module,):
|
||||
"Register known taghandlers, and manged tags."
|
||||
|
||||
self.pool = pool
|
||||
self.mode = mode
|
||||
self.noupdate = noupdate
|
||||
self.cursor = cursor
|
||||
self.user = 1
|
||||
self.module = module
|
||||
|
||||
|
||||
# Tag handlders are used to delegate the processing
|
||||
self.taghandlerlist = {
|
||||
'record': RecordTagHandler(self),
|
||||
@@ -969,13 +275,9 @@ class TrytondXmlHandler(sax.handler.ContentHandler):
|
||||
if '.' in xml_id:
|
||||
module, xml_id = xml_id.split('.')
|
||||
|
||||
model_data_id = self.pool.get('ir.model.data')._get_id(
|
||||
return self.pool.get('ir.model.data').get_id(
|
||||
self.cursor, self.user, module, xml_id)
|
||||
|
||||
return int(self.pool.get('ir.model.data').read(self.cursor, self.user,
|
||||
[model_data_id], ['res_id'])[0]['res_id'])
|
||||
|
||||
|
||||
def startElement(self, name, attributes):
|
||||
"""Rebind the current handler if necessary and call
|
||||
startElement on it"""
|
||||
@@ -994,9 +296,8 @@ class TrytondXmlHandler(sax.handler.ContentHandler):
|
||||
pass
|
||||
|
||||
else:
|
||||
# TODO logger, logger, logger, ...
|
||||
print "Tag", name , "not supported"
|
||||
raise
|
||||
Logger().notify_channel("init", LOG_INFO,
|
||||
"Tag", name , "not supported")
|
||||
return
|
||||
else:
|
||||
self.taghandler.startElement(name, attributes)
|
||||
@@ -1013,24 +314,17 @@ class TrytondXmlHandler(sax.handler.ContentHandler):
|
||||
self.taghandler = self.taghandler.endElement(name)
|
||||
|
||||
|
||||
def convert_xml_import_sax(cursor, module, xmlstream, idref=None, mode='init',
|
||||
noupdate=False, report=None, demo=False):
|
||||
if idref is None:
|
||||
idref = {}
|
||||
if report is None:
|
||||
report = AssertionReport()
|
||||
|
||||
def convert_xml_import_sax(cursor, module, xmlstream):
|
||||
|
||||
parser = sax.make_parser()
|
||||
# Tell the parser we are not interested in XML namespaces
|
||||
# Tell the parser we are not interested in XML namespaces
|
||||
parser.setFeature(sax.handler.feature_namespaces, 0)
|
||||
|
||||
handler = TrytondXmlHandler(
|
||||
cursor=cursor,
|
||||
pool=pooler.get_pool(cursor.dbname),
|
||||
mode=mode,
|
||||
module=module,
|
||||
noupdate=noupdate,)
|
||||
)
|
||||
|
||||
parser.setContentHandler(handler)
|
||||
source = sax.InputSource()
|
||||
@@ -1041,5 +335,5 @@ def convert_xml_import_sax(cursor, module, xmlstream, idref=None, mode='init',
|
||||
return True
|
||||
|
||||
|
||||
# use convert_xml_import_sax or convert_xml_import_dom
|
||||
convert_xml_import = convert_xml_import_dom
|
||||
# use convert_xml_import_sax or convert_xml_import_dom
|
||||
convert_xml_import = convert_xml_import_sax
|
||||
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<menuitem name="Administration/Workflow" id="menu_workflow"/>
|
||||
<menuitem name="Workflow" id="menu_workflow" parent_id="ir.menu_administration"/>
|
||||
<record model="ir.ui.view" id="workflow_view_form">
|
||||
<field name="model">workflow</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Workflow">
|
||||
<field name="name" select="1"/>
|
||||
<field name="osv" select="1"/>
|
||||
@@ -21,7 +21,7 @@
|
||||
<field name="model">workflow</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Workflow">
|
||||
<field name="name"/>
|
||||
<field name="osv"/>
|
||||
@@ -49,13 +49,13 @@
|
||||
<field name="view_id" ref="workflow_view_form"/>
|
||||
<field name="act_window_id" ref="act_workflow_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/Workflow/"
|
||||
<menuitem parent_id="menu_workflow"
|
||||
action="act_workflow_form" id="menu_workflow_form"/>
|
||||
<record model="ir.ui.view" id="activity_view_form">
|
||||
<field name="model">workflow.activity</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Activity">
|
||||
<field name="name" colspan="4" select="1"/>
|
||||
<field name="wkf_id" select="1"/>
|
||||
@@ -98,7 +98,7 @@
|
||||
<field name="model">workflow.activity</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Activity">
|
||||
<field name="name"/>
|
||||
<field name="wkf_id"/>
|
||||
@@ -129,13 +129,13 @@
|
||||
<field name="view_id" ref="activity_view_form"/>
|
||||
<field name="act_window_id" ref="act_activity_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/Workflow/"
|
||||
<menuitem parent_id="menu_workflow"
|
||||
action="act_activity_form" id="menu_activity_form"/>
|
||||
<record model="ir.ui.view" id="transition_view_form">
|
||||
<field name="model">workflow.transition</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Transition">
|
||||
<field name="act_from" select="1"/>
|
||||
<field name="act_to" select="1"/>
|
||||
@@ -152,7 +152,7 @@
|
||||
<field name="model">workflow.transition</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Transitions">
|
||||
<field name="act_from"/>
|
||||
<field name="act_to"/>
|
||||
@@ -184,13 +184,13 @@
|
||||
<field name="view_id" ref="transition_view_form"/>
|
||||
<field name="act_window_id" ref="act_transition_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/Workflow/"
|
||||
<menuitem parent_id="menu_workflow"
|
||||
action="act_transition_form" id="menu_transition_form"/>
|
||||
<record model="ir.ui.view" id="instance_view_form">
|
||||
<field name="model">workflow.instance</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Instance">
|
||||
<field name="wkf_id" select="1"/>
|
||||
<field name="uid" select="2"/>
|
||||
@@ -205,7 +205,7 @@
|
||||
<field name="model">workflow.instance</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Instances">
|
||||
<field name="wkf_id"/>
|
||||
<field name="uid"/>
|
||||
@@ -228,13 +228,13 @@
|
||||
<field name="view_id" ref="instance_view_tree"/>
|
||||
<field name="act_window_id" ref="act_instance_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/Workflow/"
|
||||
<menuitem parent_id="menu_workflow"
|
||||
action="act_instance_form" id="menu_instance_form"/>
|
||||
<record model="ir.ui.view" id="workitem_view_form">
|
||||
<field name="model">workflow.workitem</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<form string="Workitem">
|
||||
<field name="act_id" select="1"/>
|
||||
<field name="subflow_id" select="1"/>
|
||||
@@ -248,14 +248,14 @@
|
||||
<field name="model">workflow.workitem</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="arch" type="xml">
|
||||
<![CDATA[
|
||||
<![CDATA[
|
||||
<tree string="Workitems">
|
||||
<field name="act_id"/>
|
||||
<field name="subflow_id"/>
|
||||
<field name="inst_id"/>
|
||||
<field name="state"/>
|
||||
</tree>
|
||||
]]>
|
||||
]]>
|
||||
</field>
|
||||
</record>
|
||||
<record model="ir.actions.act_window" id="act_workitem_form">
|
||||
@@ -277,7 +277,7 @@
|
||||
<field name="view_id" ref="workitem_view_form"/>
|
||||
<field name="act_window_id" ref="act_workitem_form"/>
|
||||
</record>
|
||||
<menuitem name="Administration/Workflow/"
|
||||
<menuitem parent_id="menu_workflow"
|
||||
action="act_workitem_form" id="menu_workitem_form"/>
|
||||
</data>
|
||||
</terp>
|
||||
Reference in new issue
Block a user