merting from the trunk
also fix the problem for the server action list view now it works with the xml-rpc too lp bug: https://launchpad.net/bugs/308092 fixed bzr revid: mga@tinyerp.com-20081215134912-i8w7dm8r8dma8ucq
This commit is contained in:
commit
940972f174
|
@ -140,8 +140,6 @@ def get_module_path(module):
|
||||||
|
|
||||||
logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: module not found' % (module,))
|
logger.notifyChannel('init', netsvc.LOG_WARNING, 'module %s: module not found' % (module,))
|
||||||
return False
|
return False
|
||||||
raise IOError, 'Module not found : %s' % module
|
|
||||||
|
|
||||||
|
|
||||||
def get_module_filetree(module, dir='.'):
|
def get_module_filetree(module, dir='.'):
|
||||||
path = get_module_path(module)
|
path = get_module_path(module)
|
||||||
|
@ -193,7 +191,11 @@ def get_modules():
|
||||||
if name[-4:] == '.zip':
|
if name[-4:] == '.zip':
|
||||||
name = name[:-4]
|
name = name[:-4]
|
||||||
return name
|
return name
|
||||||
return map(clean, os.listdir(dir))
|
|
||||||
|
def is_really_module(name):
|
||||||
|
name = opj(dir, name)
|
||||||
|
return os.path.isdir(name) or zipfile.is_zipfile(name)
|
||||||
|
return map(clean, filter(is_really_module, os.listdir(dir)))
|
||||||
|
|
||||||
return list(set(listdir(ad) + listdir(_ad)))
|
return list(set(listdir(ad) + listdir(_ad)))
|
||||||
|
|
||||||
|
|
|
@ -1142,13 +1142,7 @@
|
||||||
<field name="model_id" select="1"/>
|
<field name="model_id" select="1"/>
|
||||||
<field name="sequence" select="2"/>
|
<field name="sequence" select="2"/>
|
||||||
<notebook colspan="4">
|
<notebook colspan="4">
|
||||||
<!--<page string="Python Code" attrs="{'invisible':[('state','!=','python')]}">
|
<page string="Trigger" attrs="{'invisible':[('state','!=','trigger')]}">
|
||||||
<separator colspan="4" string="Python code"/>
|
|
||||||
<field name="code" colspan="4" nolabel="1" />
|
|
||||||
<button string="Create Action" name="%(wizard_server_action_create)d" type="action"/>
|
|
||||||
</page>
|
|
||||||
|
|
||||||
--><page string="Trigger" attrs="{'invisible':[('state','!=','trigger')]}">
|
|
||||||
<separator colspan="4" string="Trigger Configuration"/>
|
<separator colspan="4" string="Trigger Configuration"/>
|
||||||
<field name="wkf_model_id"/>
|
<field name="wkf_model_id"/>
|
||||||
<field name="trigger_obj_id" select="2" domain="[('model_id','=',model_id)]" on_change="on_trigger_obj_id(trigger_obj_id)"/>
|
<field name="trigger_obj_id" select="2" domain="[('model_id','=',model_id)]" on_change="on_trigger_obj_id(trigger_obj_id)"/>
|
||||||
|
@ -1197,7 +1191,8 @@
|
||||||
<page string="Multi Actions" attrs="{'invisible':[('state','!=','other')]}">
|
<page string="Multi Actions" attrs="{'invisible':[('state','!=','other')]}">
|
||||||
<separator colspan="4" string="Other Actions Configuration"/>
|
<separator colspan="4" string="Other Actions Configuration"/>
|
||||||
<field name="child_ids" nolabel="1" colspan="4"/>
|
<field name="child_ids" nolabel="1" colspan="4"/>
|
||||||
<label colspan="4" string="Only one client action will be execute, last clinent action will be consider in case of multipls clinets actions" align="0.0"/>
|
<label colspan="4" string="Only one client action will be execute, last
|
||||||
|
clinent action will be consider in case of multiples clients actions" align="0.0"/>
|
||||||
</page>
|
</page>
|
||||||
|
|
||||||
</notebook>
|
</notebook>
|
||||||
|
@ -1223,6 +1218,7 @@
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
<field name="res_model">ir.actions.server</field>
|
<field name="res_model">ir.actions.server</field>
|
||||||
<field name="view_type">form</field>
|
<field name="view_type">form</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
<field name="view_id" ref="view_server_action_tree"/>
|
<field name="view_id" ref="view_server_action_tree"/>
|
||||||
<field name="context">{'key':'server_action'}</field>
|
<field name="context">{'key':'server_action'}</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
|
@ -374,8 +374,13 @@ class actions_server(osv.osv):
|
||||||
cr.execute("select distinct t.signal as key, t.signal || ' - [ ' || w.osv || ' ] ' as val from wkf w, wkf_activity a, wkf_transition t "\
|
cr.execute("select distinct t.signal as key, t.signal || ' - [ ' || w.osv || ' ] ' as val from wkf w, wkf_activity a, wkf_transition t "\
|
||||||
" where w.id = a.wkf_id " \
|
" where w.id = a.wkf_id " \
|
||||||
" and t.act_from = a.wkf_id " \
|
" and t.act_from = a.wkf_id " \
|
||||||
" or t.act_to = a.wkf_id ")
|
" or t.act_to = a.wkf_id and t.signal not in (null, NULL)")
|
||||||
return cr.fetchall()
|
result = cr.fetchall() or []
|
||||||
|
res = []
|
||||||
|
for rs in result:
|
||||||
|
if not rs[0] == None and not rs[1] == None:
|
||||||
|
res.append(rs)
|
||||||
|
return res
|
||||||
|
|
||||||
_name = 'ir.actions.server'
|
_name = 'ir.actions.server'
|
||||||
_table = 'ir_act_server'
|
_table = 'ir_act_server'
|
||||||
|
@ -392,7 +397,6 @@ class actions_server(osv.osv):
|
||||||
('object_write','Write Object'),
|
('object_write','Write Object'),
|
||||||
('other','Multi Actions'),
|
('other','Multi Actions'),
|
||||||
], 'Action State', required=True, size=32),
|
], 'Action State', required=True, size=32),
|
||||||
'code': fields.text('Python Code'),
|
|
||||||
'sequence': fields.integer('Sequence'),
|
'sequence': fields.integer('Sequence'),
|
||||||
'model_id': fields.many2one('ir.model', 'Object', required=True),
|
'model_id': fields.many2one('ir.model', 'Object', required=True),
|
||||||
'action_id': fields.many2one('ir.actions.actions', 'Client Action'),
|
'action_id': fields.many2one('ir.actions.actions', 'Client Action'),
|
||||||
|
@ -413,16 +417,7 @@ class actions_server(osv.osv):
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'state': lambda *a: 'dummy',
|
'state': lambda *a: 'dummy',
|
||||||
'type': lambda *a: 'ir.actions.server',
|
'type': lambda *a: 'ir.actions.server',
|
||||||
'sequence': lambda *a: 0,
|
'sequence': lambda *a: 5,
|
||||||
'code': lambda *a: """# You can use the following variables
|
|
||||||
# - object
|
|
||||||
# - object2
|
|
||||||
# - time
|
|
||||||
# - cr
|
|
||||||
# - uid
|
|
||||||
# - ids
|
|
||||||
# If you plan to return an action, assign: action = {...}
|
|
||||||
""",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -292,10 +292,7 @@ class module(osv.osv):
|
||||||
res = [0, 0] # [update, add]
|
res = [0, 0] # [update, add]
|
||||||
|
|
||||||
# iterate through installed modules and mark them as being so
|
# iterate through installed modules and mark them as being so
|
||||||
for name in addons.get_modules():
|
for mod_name in addons.get_modules():
|
||||||
mod_name = name
|
|
||||||
if name[-4:]=='.zip':
|
|
||||||
mod_name=name[:-4]
|
|
||||||
ids = self.search(cr, uid, [('name','=',mod_name)])
|
ids = self.search(cr, uid, [('name','=',mod_name)])
|
||||||
if ids:
|
if ids:
|
||||||
id = ids[0]
|
id = ids[0]
|
||||||
|
@ -304,8 +301,7 @@ class module(osv.osv):
|
||||||
if terp.get('installable', True) and mod.state == 'uninstallable':
|
if terp.get('installable', True) and mod.state == 'uninstallable':
|
||||||
self.write(cr, uid, id, {'state': 'uninstalled'})
|
self.write(cr, uid, id, {'state': 'uninstalled'})
|
||||||
if parse_version(terp.get('version', '')) > parse_version(mod.latest_version or ''):
|
if parse_version(terp.get('version', '')) > parse_version(mod.latest_version or ''):
|
||||||
self.write(cr, uid, id, {
|
self.write(cr, uid, id, { 'url': ''})
|
||||||
'url': ''})
|
|
||||||
res[0] += 1
|
res[0] += 1
|
||||||
self.write(cr, uid, id, {
|
self.write(cr, uid, id, {
|
||||||
'description': terp.get('description', ''),
|
'description': terp.get('description', ''),
|
||||||
|
@ -314,28 +310,16 @@ class module(osv.osv):
|
||||||
'website': terp.get('website', ''),
|
'website': terp.get('website', ''),
|
||||||
'license': terp.get('license', 'GPL-2'),
|
'license': terp.get('license', 'GPL-2'),
|
||||||
})
|
})
|
||||||
cr.execute('DELETE FROM ir_module_module_dependency\
|
cr.execute('DELETE FROM ir_module_module_dependency WHERE module_id = %s', (id,))
|
||||||
WHERE module_id = %s', (id,))
|
self._update_dependencies(cr, uid, ids[0], terp.get('depends', []))
|
||||||
self._update_dependencies(cr, uid, ids[0], terp.get('depends',
|
self._update_category(cr, uid, ids[0], terp.get('category', 'Uncategorized'))
|
||||||
[]))
|
|
||||||
self._update_category(cr, uid, ids[0], terp.get('category',
|
|
||||||
'Uncategorized'))
|
|
||||||
continue
|
continue
|
||||||
terp_file = addons.get_module_resource(name, '__terp__.py')
|
mod_path = addons.get_module_path(mod_name)
|
||||||
mod_path = addons.get_module_path(name)
|
if mod_path:
|
||||||
if mod_path and (os.path.isdir(mod_path) or os.path.islink(mod_path) or zipfile.is_zipfile(mod_path)):
|
|
||||||
terp = self.get_module_info(mod_name)
|
terp = self.get_module_info(mod_name)
|
||||||
if not terp or not terp.get('installable', True):
|
if not terp or not terp.get('installable', True):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
#if not os.path.isfile( mod_path ):
|
|
||||||
# import imp
|
|
||||||
# path = imp.find_module(mod_name, [addons.ad, addons._ad])
|
|
||||||
# imp.load_module(name, *path)
|
|
||||||
#else:
|
|
||||||
# import zipimport
|
|
||||||
# zimp = zipimport.zipimporter(mod_path)
|
|
||||||
# zimp.load_module(mod_name)
|
|
||||||
id = self.create(cr, uid, {
|
id = self.create(cr, uid, {
|
||||||
'name': mod_name,
|
'name': mod_name,
|
||||||
'state': 'uninstalled',
|
'state': 'uninstalled',
|
||||||
|
@ -349,8 +333,6 @@ class module(osv.osv):
|
||||||
self._update_dependencies(cr, uid, id, terp.get('depends', []))
|
self._update_dependencies(cr, uid, id, terp.get('depends', []))
|
||||||
self._update_category(cr, uid, id, terp.get('category', 'Uncategorized'))
|
self._update_category(cr, uid, id, terp.get('category', 'Uncategorized'))
|
||||||
|
|
||||||
#import socket
|
|
||||||
#socket.setdefaulttimeout(10)
|
|
||||||
for repository in robj.browse(cr, uid, robj.search(cr, uid, [])):
|
for repository in robj.browse(cr, uid, robj.search(cr, uid, [])):
|
||||||
try:
|
try:
|
||||||
index_page = urllib.urlopen(repository.url).read()
|
index_page = urllib.urlopen(repository.url).read()
|
||||||
|
@ -363,9 +345,7 @@ class module(osv.osv):
|
||||||
modules = re.findall(repository.filter, index_page, re.I+re.M)
|
modules = re.findall(repository.filter, index_page, re.I+re.M)
|
||||||
mod_sort = {}
|
mod_sort = {}
|
||||||
for m in modules:
|
for m in modules:
|
||||||
name = m[0]
|
name, version, extension = m[0], m[1], m[-1]
|
||||||
version = m[1]
|
|
||||||
extension = m[-1]
|
|
||||||
if version == 'x': # 'x' version was a mistake
|
if version == 'x': # 'x' version was a mistake
|
||||||
version = '0'
|
version = '0'
|
||||||
if name in mod_sort:
|
if name in mod_sort:
|
||||||
|
@ -390,16 +370,13 @@ class module(osv.osv):
|
||||||
if installed_version == 'x': # 'x' version was a mistake
|
if installed_version == 'x': # 'x' version was a mistake
|
||||||
installed_version = '0'
|
installed_version = '0'
|
||||||
if parse_version(version) > parse_version(installed_version):
|
if parse_version(version) > parse_version(installed_version):
|
||||||
self.write(cr, uid, id, {
|
self.write(cr, uid, id, { 'url': url })
|
||||||
'url': url
|
|
||||||
})
|
|
||||||
res[0] += 1
|
res[0] += 1
|
||||||
published_version = self.read(cr, uid, id, ['published_version'])['published_version']
|
published_version = self.read(cr, uid, id, ['published_version'])['published_version']
|
||||||
if published_version == 'x' or not published_version:
|
if published_version == 'x' or not published_version:
|
||||||
published_version = '0'
|
published_version = '0'
|
||||||
if parse_version(version) > parse_version(published_version):
|
if parse_version(version) > parse_version(published_version):
|
||||||
self.write(cr, uid, id,
|
self.write(cr, uid, id, {'published_version': version})
|
||||||
{'published_version': version})
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def download(self, cr, uid, ids, download=True, context=None):
|
def download(self, cr, uid, ids, download=True, context=None):
|
||||||
|
|
|
@ -658,7 +658,6 @@ class related(function):
|
||||||
return [(self._arg[0], 'in', sarg)]
|
return [(self._arg[0], 'in', sarg)]
|
||||||
|
|
||||||
def _fnct_write(self,obj,cr, uid, ids, field_name, values, args, context=None):
|
def _fnct_write(self,obj,cr, uid, ids, field_name, values, args, context=None):
|
||||||
print 'Related Write', obj._name
|
|
||||||
if values and field_name:
|
if values and field_name:
|
||||||
self._field_get2(cr, uid, obj, context)
|
self._field_get2(cr, uid, obj, context)
|
||||||
relation = obj._name
|
relation = obj._name
|
||||||
|
|
|
@ -709,8 +709,7 @@ class orm_template(object):
|
||||||
translation_obj = self.pool.get('ir.translation')
|
translation_obj = self.pool.get('ir.translation')
|
||||||
model_access_obj = self.pool.get('ir.model.access')
|
model_access_obj = self.pool.get('ir.model.access')
|
||||||
for parent in self._inherits:
|
for parent in self._inherits:
|
||||||
res.update(self.pool.get(parent).fields_get(cr, user, fields,
|
res.update(self.pool.get(parent).fields_get(cr, user, fields, context))
|
||||||
context))
|
|
||||||
for f in self._columns.keys():
|
for f in self._columns.keys():
|
||||||
if fields and f not in fields:
|
if fields and f not in fields:
|
||||||
continue
|
continue
|
||||||
|
@ -727,12 +726,10 @@ class orm_template(object):
|
||||||
and getattr(self._columns[f], arg):
|
and getattr(self._columns[f], arg):
|
||||||
res[f][arg] = getattr(self._columns[f], arg)
|
res[f][arg] = getattr(self._columns[f], arg)
|
||||||
|
|
||||||
res_trans = translation_obj._get_source(cr, user,
|
res_trans = translation_obj._get_source(cr, user, self._name + ',' + f, 'field', context.get('lang', False) or 'en_US')
|
||||||
self._name + ',' + f, 'field', context.get('lang', False) or 'en_US')
|
|
||||||
if res_trans:
|
if res_trans:
|
||||||
res[f]['string'] = res_trans
|
res[f]['string'] = res_trans
|
||||||
help_trans = translation_obj._get_source(cr, user,
|
help_trans = translation_obj._get_source(cr, user, self._name + ',' + f, 'help', context.get('lang', False) or 'en_US')
|
||||||
self._name + ',' + f, 'help', context.get('lang', False) or 'en_US')
|
|
||||||
if help_trans:
|
if help_trans:
|
||||||
res[f]['help'] = help_trans
|
res[f]['help'] = help_trans
|
||||||
|
|
||||||
|
@ -744,9 +741,7 @@ class orm_template(object):
|
||||||
for (key, val) in sel:
|
for (key, val) in sel:
|
||||||
val2 = None
|
val2 = None
|
||||||
if val:
|
if val:
|
||||||
val2 = translation_obj._get_source(cr, user,
|
val2 = translation_obj._get_source(cr, user, self._name + ',' + f, 'selection', context.get('lang', False) or 'en_US', val)
|
||||||
self._name + ',' + f, 'selection',
|
|
||||||
context.get('lang', False) or 'en_US', val)
|
|
||||||
sel2.append((key, val2 or val))
|
sel2.append((key, val2 or val))
|
||||||
sel = sel2
|
sel = sel2
|
||||||
res[f]['selection'] = sel
|
res[f]['selection'] = sel
|
||||||
|
|
|
@ -531,12 +531,14 @@ def is_hashable(h):
|
||||||
except TypeError:
|
except TypeError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
#
|
|
||||||
# Use it as a decorator of the function you plan to cache
|
|
||||||
# Timeout: 0 = no timeout, otherwise in seconds
|
|
||||||
#
|
|
||||||
class cache(object):
|
class cache(object):
|
||||||
|
"""
|
||||||
|
Use it as a decorator of the function you plan to cache
|
||||||
|
Timeout: 0 = no timeout, otherwise in seconds
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, timeout=10000, skiparg=2, multi=None):
|
def __init__(self, timeout=10000, skiparg=2, multi=None):
|
||||||
|
assert skiparg >= 2 # at least self and cr
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
self.skiparg = skiparg
|
self.skiparg = skiparg
|
||||||
self.multi = multi
|
self.multi = multi
|
||||||
|
@ -553,9 +555,9 @@ class cache(object):
|
||||||
del self.cache[kwargs['clear_keys']]
|
del self.cache[kwargs['clear_keys']]
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# Update named arguments with positional argument values
|
# Update named arguments with positional argument values (without self and cr)
|
||||||
kwargs2 = kwargs.copy()
|
kwargs2 = kwargs.copy()
|
||||||
kwargs2.update(dict(zip(arg_names, args)))
|
kwargs2.update(dict(zip(arg_names, args[self.skiparg-2:])))
|
||||||
for k in kwargs2:
|
for k in kwargs2:
|
||||||
if isinstance(kwargs2[k], (list, dict, set)):
|
if isinstance(kwargs2[k], (list, dict, set)):
|
||||||
kwargs2[k] = tuple(kwargs2[k])
|
kwargs2[k] = tuple(kwargs2[k])
|
||||||
|
@ -577,7 +579,7 @@ class cache(object):
|
||||||
# Work out new value, cache it and return it
|
# Work out new value, cache it and return it
|
||||||
# FIXME Should copy() this value to avoid futur modifications of the cache ?
|
# FIXME Should copy() this value to avoid futur modifications of the cache ?
|
||||||
# FIXME What about exceptions ?
|
# FIXME What about exceptions ?
|
||||||
result = fn(self2,cr,*args, **kwargs)
|
result = fn(self2, cr, *args, **kwargs)
|
||||||
|
|
||||||
self.cache[key] = (result, time.time())
|
self.cache[key] = (result, time.time())
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Reference in New Issue