kernel: don't use mutable as default value in function defintion.
bzr revid: ced-824ee7e22dca5a4b4f2d8d5095aa20650f5a2469
This commit is contained in:
parent
4669379c8b
commit
d9d0678328
|
@ -126,7 +126,9 @@ class Node(Singleton):
|
||||||
s += '%s`-> %s' % (' ' * depth, c._pprint(depth+1))
|
s += '%s`-> %s' % (' ' * depth, c._pprint(depth+1))
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def create_graph(module_list, force=[]):
|
def create_graph(module_list, force=None):
|
||||||
|
if not force:
|
||||||
|
force=[]
|
||||||
graph = Graph()
|
graph = Graph()
|
||||||
packages = []
|
packages = []
|
||||||
|
|
||||||
|
@ -177,7 +179,10 @@ def init_module_objects(cr, module_name, obj_list):
|
||||||
obj._auto_init(cr)
|
obj._auto_init(cr)
|
||||||
cr.commit()
|
cr.commit()
|
||||||
|
|
||||||
def load_module_graph(cr, graph, status={}):
|
def load_module_graph(cr, graph, status=None):
|
||||||
|
if not status:
|
||||||
|
status={}
|
||||||
|
status = status.copy()
|
||||||
package_todo = []
|
package_todo = []
|
||||||
statusi = 0
|
statusi = 0
|
||||||
for package in graph:
|
for package in graph:
|
||||||
|
@ -248,7 +253,9 @@ def register_classes():
|
||||||
except zipimport.ZipImportError:
|
except zipimport.ZipImportError:
|
||||||
logger.notifyChannel('init', netsvc.LOG_ERROR, 'Couldn\'t find module %s' % m)
|
logger.notifyChannel('init', netsvc.LOG_ERROR, 'Couldn\'t find module %s' % m)
|
||||||
|
|
||||||
def load_modules(db, force_demo=False, status={}, update_module=False):
|
def load_modules(db, force_demo=False, status=None, update_module=False):
|
||||||
|
if not status:
|
||||||
|
status={}
|
||||||
cr = db.cursor()
|
cr = db.cursor()
|
||||||
force = []
|
force = []
|
||||||
if force_demo:
|
if force_demo:
|
||||||
|
|
|
@ -158,7 +158,11 @@ class Agent(object):
|
||||||
_timers = []
|
_timers = []
|
||||||
_logger = Logger()
|
_logger = Logger()
|
||||||
|
|
||||||
def setAlarm(self, fn, dt, args=[], kwargs={}):
|
def setAlarm(self, fn, dt, args=None, kwargs=None):
|
||||||
|
if not args:
|
||||||
|
args=[]
|
||||||
|
if not kwargs:
|
||||||
|
kwargs={}
|
||||||
wait = dt - time.time()
|
wait = dt - time.time()
|
||||||
if wait > 0:
|
if wait > 0:
|
||||||
self._logger.notifyChannel('timers', LOG_DEBUG, "Job scheduled in %s seconds for %s.%s" % (wait, fn.im_class.__name__, fn.func_name))
|
self._logger.notifyChannel('timers', LOG_DEBUG, "Job scheduled in %s seconds for %s.%s" % (wait, fn.im_class.__name__, fn.func_name))
|
||||||
|
|
|
@ -66,8 +66,8 @@ class _column(object):
|
||||||
_symbol_set = (_symbol_c, _symbol_f)
|
_symbol_set = (_symbol_c, _symbol_f)
|
||||||
_symbol_get = None
|
_symbol_get = None
|
||||||
|
|
||||||
def __init__(self, string='unknown', required=False, readonly=False, domain=[], context='', states={}, priority=0, change_default=False, size=None, ondelete="set null", translate=False, select=False, **args):
|
def __init__(self, string='unknown', required=False, readonly=False, domain=None, context='', states=None, priority=0, change_default=False, size=None, ondelete="set null", translate=False, select=False, **args):
|
||||||
self.states = states
|
self.states = states or {}
|
||||||
self.string = string
|
self.string = string
|
||||||
self.readonly = readonly
|
self.readonly = readonly
|
||||||
self.required = required
|
self.required = required
|
||||||
|
@ -77,7 +77,7 @@ class _column(object):
|
||||||
self.change_default = change_default
|
self.change_default = change_default
|
||||||
self.ondelete = ondelete
|
self.ondelete = ondelete
|
||||||
self.translate = translate
|
self.translate = translate
|
||||||
self._domain = domain
|
self._domain = domain or []
|
||||||
self.relate =False
|
self.relate =False
|
||||||
self._context = context
|
self._context = context
|
||||||
self.group_name = False
|
self.group_name = False
|
||||||
|
@ -90,10 +90,10 @@ class _column(object):
|
||||||
warnings.warn("The relate attribute doesn't work anymore, use act_window tag instead", DeprecationWarning)
|
warnings.warn("The relate attribute doesn't work anymore, use act_window tag instead", DeprecationWarning)
|
||||||
|
|
||||||
|
|
||||||
def set(self, cr, obj, id, name, value, user=None, context={}):
|
def set(self, cr, obj, id, name, value, user=None, context=None):
|
||||||
cr.execute('update '+obj._table+' set '+name+'='+self._symbol_set[0]+' where id=%d', (self._symbol_set[1](value),id) )
|
cr.execute('update '+obj._table+' set '+name+'='+self._symbol_set[0]+' where id=%d', (self._symbol_set[1](value),id) )
|
||||||
|
|
||||||
def get(self, cr, obj, ids, name, context={}, values={}):
|
def get(self, cr, obj, ids, name, context=None, values=None):
|
||||||
raise 'undefined get method !'
|
raise 'undefined get method !'
|
||||||
|
|
||||||
def search(self, cr, obj, args, name, value, offset=0, limit=None, uid=None):
|
def search(self, cr, obj, args, name, value, offset=0, limit=None, uid=None):
|
||||||
|
@ -212,7 +212,9 @@ class selection(_column):
|
||||||
_column.__init__(self, string=string, **args)
|
_column.__init__(self, string=string, **args)
|
||||||
self.selection = selection
|
self.selection = selection
|
||||||
|
|
||||||
def set(self, cr, obj, id, name, value, user=None, context={}):
|
def set(self, cr, obj, id, name, value, user=None, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
#CHECKME: a priori, ceci n'est jamais appelé puisque le test ci-dessous est mauvais
|
#CHECKME: a priori, ceci n'est jamais appelé puisque le test ci-dessous est mauvais
|
||||||
# la raison est que selection n'est pas en classic_write = false
|
# la raison est que selection n'est pas en classic_write = false
|
||||||
# a noter qu'on pourrait fournir un _symbol_set specifique, et ca suffirait
|
# a noter qu'on pourrait fournir un _symbol_set specifique, et ca suffirait
|
||||||
|
@ -244,7 +246,9 @@ class one2one(_column):
|
||||||
_column.__init__(self, string=string, **args)
|
_column.__init__(self, string=string, **args)
|
||||||
self._obj = obj
|
self._obj = obj
|
||||||
|
|
||||||
def set(self, cr, obj_src, id, field, act, user=None, context={}):
|
def set(self, cr, obj_src, id, field, act, user=None, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
obj = obj_src.pool.get(self._obj)
|
obj = obj_src.pool.get(self._obj)
|
||||||
self._table = obj_src.pool.get(self._obj)._table
|
self._table = obj_src.pool.get(self._obj)._table
|
||||||
if act[0]==0:
|
if act[0]==0:
|
||||||
|
@ -272,7 +276,11 @@ class many2one(_column):
|
||||||
# TODO: speed improvement
|
# TODO: speed improvement
|
||||||
#
|
#
|
||||||
# name is the name of the relation field
|
# name is the name of the relation field
|
||||||
def get(self, cr, obj, ids, name, user=None, context={}, values={}):
|
def get(self, cr, obj, ids, name, user=None, context=None, values=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
|
if not values:
|
||||||
|
values={}
|
||||||
res = {}
|
res = {}
|
||||||
for r in values:
|
for r in values:
|
||||||
res[r['id']] = r[name]
|
res[r['id']] = r[name]
|
||||||
|
@ -300,7 +308,9 @@ class many2one(_column):
|
||||||
res[r] = False
|
res[r] = False
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def set(self, cr, obj_src, id, field, values, user=None, context={}):
|
def set(self, cr, obj_src, id, field, values, user=None, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
obj = obj_src.pool.get(self._obj)
|
obj = obj_src.pool.get(self._obj)
|
||||||
self._table = obj_src.pool.get(self._obj)._table
|
self._table = obj_src.pool.get(self._obj)._table
|
||||||
if type(values)==type([]):
|
if type(values)==type([]):
|
||||||
|
@ -338,7 +348,11 @@ class one2many(_column):
|
||||||
#one2many can't be used as condition for defaults
|
#one2many can't be used as condition for defaults
|
||||||
assert(self.change_default != True)
|
assert(self.change_default != True)
|
||||||
|
|
||||||
def get(self, cr, obj, ids, name, user=None, offset=0, context={}, values={}):
|
def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None):
|
||||||
|
if not context:
|
||||||
|
context = {}
|
||||||
|
if not values:
|
||||||
|
values = {}
|
||||||
res = {}
|
res = {}
|
||||||
for id in ids:
|
for id in ids:
|
||||||
res[id] = []
|
res[id] = []
|
||||||
|
@ -347,7 +361,9 @@ class one2many(_column):
|
||||||
res[r[self._fields_id]].append( r['id'] )
|
res[r[self._fields_id]].append( r['id'] )
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def set(self, cr, obj, id, field, values, user=None, context={}):
|
def set(self, cr, obj, id, field, values, user=None, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
if not values:
|
if not values:
|
||||||
return
|
return
|
||||||
_table = obj.pool.get(self._obj)._table
|
_table = obj.pool.get(self._obj)._table
|
||||||
|
@ -397,7 +413,11 @@ class many2many(_column):
|
||||||
self._id2 = id2
|
self._id2 = id2
|
||||||
self._limit = limit
|
self._limit = limit
|
||||||
|
|
||||||
def get(self, cr, obj, ids, name, user=None, offset=0, context={}, values={}):
|
def get(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
|
if not values:
|
||||||
|
values={}
|
||||||
res = {}
|
res = {}
|
||||||
if not ids:
|
if not ids:
|
||||||
return res
|
return res
|
||||||
|
@ -416,7 +436,9 @@ class many2many(_column):
|
||||||
res[r[1]].append(r[0])
|
res[r[1]].append(r[0])
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def set(self, cr, obj, id, name, values, user=None, context={}):
|
def set(self, cr, obj, id, name, values, user=None, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
if not values:
|
if not values:
|
||||||
return
|
return
|
||||||
obj = obj.pool.get(self._obj)
|
obj = obj.pool.get(self._obj)
|
||||||
|
@ -486,7 +508,11 @@ class function(_column):
|
||||||
return []
|
return []
|
||||||
return self._fnct_search(obj, cr, uid, obj, name, args)
|
return self._fnct_search(obj, cr, uid, obj, name, args)
|
||||||
|
|
||||||
def get(self, cr, obj, ids, name, user=None, context={}, values={}):
|
def get(self, cr, obj, ids, name, user=None, context=None, values=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
|
if not values:
|
||||||
|
values={}
|
||||||
res = {}
|
res = {}
|
||||||
table = obj._table
|
table = obj._table
|
||||||
if self._method:
|
if self._method:
|
||||||
|
@ -495,7 +521,9 @@ class function(_column):
|
||||||
else:
|
else:
|
||||||
return self._fnct(cr, table, ids, name, self._arg, context)
|
return self._fnct(cr, table, ids, name, self._arg, context)
|
||||||
|
|
||||||
def set(self, cr, obj, id, name, value, user=None, context={}):
|
def set(self, cr, obj, id, name, value, user=None, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
if self._fnct_inv:
|
if self._fnct_inv:
|
||||||
self._fnct_inv(obj, cr, user, id, name, value, self._fnct_inv_arg, context)
|
self._fnct_inv(obj, cr, user, id, name, value, self._fnct_inv_arg, context)
|
||||||
|
|
||||||
|
@ -512,7 +540,9 @@ class serialized(_column):
|
||||||
super(serialized, self).__init__(string=string, **args)
|
super(serialized, self).__init__(string=string, **args)
|
||||||
|
|
||||||
class property(function):
|
class property(function):
|
||||||
def _fnct_write(self2, self, cr, uid, id, prop, id_val, val, context={}):
|
def _fnct_write(self2, self, cr, uid, id, prop, id_val, val, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
(obj_dest,) = val
|
(obj_dest,) = val
|
||||||
definition_id = self2._field_get(self, cr, uid, prop)
|
definition_id = self2._field_get(self, cr, uid, prop)
|
||||||
|
|
||||||
|
@ -540,7 +570,9 @@ class property(function):
|
||||||
}, context=context)
|
}, context=context)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def _fnct_read(self2, self, cr, uid, ids, prop, val, context={}):
|
def _fnct_read(self2, self, cr, uid, ids, prop, val, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
property = self.pool.get('ir.property')
|
property = self.pool.get('ir.property')
|
||||||
definition_id = self2._field_get(self, cr, uid, prop)
|
definition_id = self2._field_get(self, cr, uid, prop)
|
||||||
|
|
||||||
|
@ -577,7 +609,4 @@ class property(function):
|
||||||
|
|
||||||
def __init__(self, obj_prop, **args):
|
def __init__(self, obj_prop, **args):
|
||||||
self.field_id = {}
|
self.field_id = {}
|
||||||
function.__init__(self,
|
function.__init__(self, self._fnct_read, False, self._fnct_write, (obj_prop, ), **args)
|
||||||
self._fnct_read, False,
|
|
||||||
self._fnct_write, (obj_prop, ),
|
|
||||||
**args)
|
|
||||||
|
|
110
bin/osv/orm.py
110
bin/osv/orm.py
|
@ -516,7 +516,9 @@ class orm(object):
|
||||||
self._inherit_fields=res
|
self._inherit_fields=res
|
||||||
self._inherits_reload_src()
|
self._inherits_reload_src()
|
||||||
|
|
||||||
def browse(self, cr, uid, select, context={}, list_class=None):
|
def browse(self, cr, uid, select, context=None, list_class=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
self._list_class = list_class or browse_record_list
|
self._list_class = list_class or browse_record_list
|
||||||
cache = {}
|
cache = {}
|
||||||
# need to accepts ints and longs because ids coming from a method
|
# need to accepts ints and longs because ids coming from a method
|
||||||
|
@ -529,7 +531,9 @@ class orm(object):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
# TODO: implement this
|
# TODO: implement this
|
||||||
def __export_row(self, cr, uid, row, fields, prefix, context={}):
|
def __export_row(self, cr, uid, row, fields, prefix, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
lines = []
|
lines = []
|
||||||
data = map(lambda x: '', range(len(fields)))
|
data = map(lambda x: '', range(len(fields)))
|
||||||
done = []
|
done = []
|
||||||
|
@ -564,14 +568,18 @@ class orm(object):
|
||||||
data[fpos] = str(r or '')
|
data[fpos] = str(r or '')
|
||||||
return [data] + lines
|
return [data] + lines
|
||||||
|
|
||||||
def export_data(self, cr, uid, ids, fields, context={}):
|
def export_data(self, cr, uid, ids, fields, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
fields = map(lambda x: x.split('/'), fields)
|
fields = map(lambda x: x.split('/'), fields)
|
||||||
datas = []
|
datas = []
|
||||||
for row in self.browse(cr, uid, ids, context):
|
for row in self.browse(cr, uid, ids, context):
|
||||||
datas += self.__export_row(cr, uid, row, fields, [], context)
|
datas += self.__export_row(cr, uid, row, fields, [], context)
|
||||||
return datas
|
return datas
|
||||||
|
|
||||||
def import_data(self, cr, uid, fields, datas, mode='init', current_module=None, noupdate=False, context={}):
|
def import_data(self, cr, uid, fields, datas, mode='init', current_module=None, noupdate=False, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
fields = map(lambda x: x.split('/'), fields)
|
fields = map(lambda x: x.split('/'), fields)
|
||||||
logger = netsvc.Logger()
|
logger = netsvc.Logger()
|
||||||
def process_liness(self, datas, prefix, fields_def, position=0):
|
def process_liness(self, datas, prefix, fields_def, position=0):
|
||||||
|
@ -712,7 +720,9 @@ class orm(object):
|
||||||
#
|
#
|
||||||
return (done, 0, 0, 0)
|
return (done, 0, 0, 0)
|
||||||
|
|
||||||
def read(self, cr, user, ids, fields=None, context={}, load='_classic_read'):
|
def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
self.pool.get('ir.model.access').check(cr, user, self._name, 'read')
|
self.pool.get('ir.model.access').check(cr, user, self._name, 'read')
|
||||||
if not fields:
|
if not fields:
|
||||||
fields = self._columns.keys() + self._inherit_fields.keys()
|
fields = self._columns.keys() + self._inherit_fields.keys()
|
||||||
|
@ -728,7 +738,9 @@ class orm(object):
|
||||||
return result[0]
|
return result[0]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _read_flat(self, cr, user, ids, fields, context={}, load='_classic_read'):
|
def _read_flat(self, cr, user, ids, fields, context=None, load='_classic_read'):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
if not ids:
|
if not ids:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
@ -809,7 +821,9 @@ class orm(object):
|
||||||
cr.rollback()
|
cr.rollback()
|
||||||
raise except_orm('ValidateError', ('\n'.join(field_err_str), ','.join(field_error)))
|
raise except_orm('ValidateError', ('\n'.join(field_err_str), ','.join(field_error)))
|
||||||
|
|
||||||
def default_get(self, cr, uid, fields, context={}):
|
def default_get(self, cr, uid, fields, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
value = {}
|
value = {}
|
||||||
# get the default values for the inherited fields
|
# get the default values for the inherited fields
|
||||||
for t in self._inherits.keys():
|
for t in self._inherits.keys():
|
||||||
|
@ -828,7 +842,9 @@ class orm(object):
|
||||||
value[field] = field_value
|
value[field] = field_value
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def perm_read(self, cr, user, ids, context={}, details=True):
|
def perm_read(self, cr, user, ids, context=None, details=True):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
if not ids:
|
if not ids:
|
||||||
return []
|
return []
|
||||||
fields = ', p.level, p.uid, p.gid'
|
fields = ', p.level, p.uid, p.gid'
|
||||||
|
@ -854,7 +870,9 @@ class orm(object):
|
||||||
return res[ids]
|
return res[ids]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def unlink(self, cr, uid, ids, context={}):
|
def unlink(self, cr, uid, ids, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
if not ids:
|
if not ids:
|
||||||
return True
|
return True
|
||||||
if isinstance(ids, (int, long)):
|
if isinstance(ids, (int, long)):
|
||||||
|
@ -893,7 +911,9 @@ class orm(object):
|
||||||
#
|
#
|
||||||
# TODO: Validate
|
# TODO: Validate
|
||||||
#
|
#
|
||||||
def write(self, cr, user, ids, vals, context={}):
|
def write(self, cr, user, ids, vals, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
if not ids:
|
if not ids:
|
||||||
return True
|
return True
|
||||||
if isinstance(ids, (int, long)):
|
if isinstance(ids, (int, long)):
|
||||||
|
@ -984,12 +1004,14 @@ class orm(object):
|
||||||
#
|
#
|
||||||
# TODO: Should set perm to user.xxx
|
# TODO: Should set perm to user.xxx
|
||||||
#
|
#
|
||||||
def create(self, cr, user, vals, context={}):
|
def create(self, cr, user, vals, context=None):
|
||||||
""" create(cr, user, vals, context) -> int
|
""" create(cr, user, vals, context) -> int
|
||||||
cr = database cursor
|
cr = database cursor
|
||||||
user = user id
|
user = user id
|
||||||
vals = dictionary of the form {'field_name':field_value, ...}
|
vals = dictionary of the form {'field_name':field_value, ...}
|
||||||
"""
|
"""
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
self.pool.get('ir.model.access').check(cr, user, self._name, 'create')
|
self.pool.get('ir.model.access').check(cr, user, self._name, 'create')
|
||||||
|
|
||||||
default = []
|
default = []
|
||||||
|
@ -1056,7 +1078,9 @@ class orm(object):
|
||||||
self._update_function_stored(cr, user, [id_new], context=context)
|
self._update_function_stored(cr, user, [id_new], context=context)
|
||||||
return id_new
|
return id_new
|
||||||
|
|
||||||
def _update_function_stored(self, cr, user, ids, context={}):
|
def _update_function_stored(self, cr, user, ids, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
f=filter(lambda a: isinstance(self._columns[a], fields.function) and self._columns[a].store, self._columns)
|
f=filter(lambda a: isinstance(self._columns[a], fields.function) and self._columns[a].store, self._columns)
|
||||||
if f:
|
if f:
|
||||||
result=self.read(cr, user, ids, fields=f, context=context)
|
result=self.read(cr, user, ids, fields=f, context=context)
|
||||||
|
@ -1075,7 +1099,9 @@ class orm(object):
|
||||||
#
|
#
|
||||||
# TODO: Validate
|
# TODO: Validate
|
||||||
#
|
#
|
||||||
def perm_write(self, cr, user, ids, fields, context={}):
|
def perm_write(self, cr, user, ids, fields, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
if not ids:
|
if not ids:
|
||||||
return True
|
return True
|
||||||
if isinstance(ids, (int, long)):
|
if isinstance(ids, (int, long)):
|
||||||
|
@ -1100,7 +1126,9 @@ class orm(object):
|
||||||
|
|
||||||
# returns the definition of each field in the object
|
# returns the definition of each field in the object
|
||||||
# the optional fields parameter can limit the result to some fields
|
# the optional fields parameter can limit the result to some fields
|
||||||
def fields_get(self, cr, user, fields=None, context={}):
|
def fields_get(self, cr, user, fields=None, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
res = {}
|
res = {}
|
||||||
for parent in self._inherits:
|
for parent in self._inherits:
|
||||||
res.update(self.pool.get(parent).fields_get(cr, user, fields, context))
|
res.update(self.pool.get(parent).fields_get(cr, user, fields, context))
|
||||||
|
@ -1153,10 +1181,12 @@ class orm(object):
|
||||||
#
|
#
|
||||||
# Overload this method if you need a window title which depends on the context
|
# Overload this method if you need a window title which depends on the context
|
||||||
#
|
#
|
||||||
def view_header_get(self, cr, user, view_id=None, view_type='form', context={}):
|
def view_header_get(self, cr, user, view_id=None, view_type='form', context=None):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def __view_look_dom(self, cr, user, node, context={}):
|
def __view_look_dom(self, cr, user, node, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
result = False
|
result = False
|
||||||
fields = {}
|
fields = {}
|
||||||
childs = True
|
childs = True
|
||||||
|
@ -1230,7 +1260,9 @@ class orm(object):
|
||||||
fields.update(self.__view_look_dom(cr, user, f,context))
|
fields.update(self.__view_look_dom(cr, user, f,context))
|
||||||
return fields
|
return fields
|
||||||
|
|
||||||
def __view_look_dom_arch(self, cr, user, node, context={}):
|
def __view_look_dom_arch(self, cr, user, node, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
fields_def = self.__view_look_dom(cr, user, node, context=context)
|
fields_def = self.__view_look_dom(cr, user, node, context=context)
|
||||||
arch = node.toxml()
|
arch = node.toxml()
|
||||||
fields = self.fields_get(cr, user, fields_def.keys(), context)
|
fields = self.fields_get(cr, user, fields_def.keys(), context)
|
||||||
|
@ -1242,7 +1274,9 @@ class orm(object):
|
||||||
#
|
#
|
||||||
# if view_id, view_type is not required
|
# if view_id, view_type is not required
|
||||||
#
|
#
|
||||||
def fields_view_get(self, cr, user, view_id=None, view_type='form', context={}, toolbar=False):
|
def fields_view_get(self, cr, user, view_id=None, view_type='form', context=None, toolbar=False):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
def _inherit_apply(src, inherit):
|
def _inherit_apply(src, inherit):
|
||||||
def _find(node, node2):
|
def _find(node, node2):
|
||||||
if node.nodeType==node.ELEMENT_NODE and node.localName==node2.localName:
|
if node.nodeType==node.ELEMENT_NODE and node.localName==node2.localName:
|
||||||
|
@ -1387,8 +1421,10 @@ class orm(object):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# TODO: ameliorer avec NULL
|
# TODO: ameliorer avec NULL
|
||||||
def _where_calc(self, cr, user, args2, context={}):
|
def _where_calc(self, cr, user, args, context=None):
|
||||||
args = args2[:]
|
if not context:
|
||||||
|
context={}
|
||||||
|
args = args[:]
|
||||||
# if the object has a field named 'active', filter out all inactive
|
# if the object has a field named 'active', filter out all inactive
|
||||||
# records unless they were explicitely asked for
|
# records unless they were explicitely asked for
|
||||||
if 'active' in self._columns:
|
if 'active' in self._columns:
|
||||||
|
@ -1581,7 +1617,9 @@ class orm(object):
|
||||||
qu1.append(' (1=0)')
|
qu1.append(' (1=0)')
|
||||||
return (qu1,qu2,tables)
|
return (qu1,qu2,tables)
|
||||||
|
|
||||||
def search_count(self, cr, user, args, context={}):
|
def search_count(self, cr, user, args, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
# compute the count of records
|
# compute the count of records
|
||||||
(qu1,qu2,tables) = self._where_calc(cr, user, args, context)
|
(qu1,qu2,tables) = self._where_calc(cr, user, args, context)
|
||||||
|
|
||||||
|
@ -1601,7 +1639,9 @@ class orm(object):
|
||||||
res = cr.fetchall()
|
res = cr.fetchall()
|
||||||
return res[0][0]
|
return res[0][0]
|
||||||
|
|
||||||
def search(self, cr, user, args, offset=0, limit=None, order=None, context={}):
|
def search(self, cr, user, args, offset=0, limit=None, order=None, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
# compute the where, order by, limit and offset clauses
|
# compute the where, order by, limit and offset clauses
|
||||||
(qu1,qu2,tables) = self._where_calc(cr, user, args, context)
|
(qu1,qu2,tables) = self._where_calc(cr, user, args, context)
|
||||||
|
|
||||||
|
@ -1628,27 +1668,37 @@ class orm(object):
|
||||||
# returns the different values ever entered for one field
|
# returns the different values ever entered for one field
|
||||||
# this is used, for example, in the client when the user hits enter on
|
# this is used, for example, in the client when the user hits enter on
|
||||||
# a char field
|
# a char field
|
||||||
def distinct_field_get(self, cr, uid, field, value, args=[], offset=0, limit=None):
|
def distinct_field_get(self, cr, uid, field, value, args=None, offset=0, limit=None):
|
||||||
|
if not args:
|
||||||
|
args=[]
|
||||||
if field in self._inherit_fields:
|
if field in self._inherit_fields:
|
||||||
return self.pool.get(self._inherit_fields[field][0]).distinct_field_get(cr, uid,field,value,args,offset,limit)
|
return self.pool.get(self._inherit_fields[field][0]).distinct_field_get(cr, uid,field,value,args,offset,limit)
|
||||||
else:
|
else:
|
||||||
return self._columns[field].search(cr, self, args, field, value, offset, limit, uid)
|
return self._columns[field].search(cr, self, args, field, value, offset, limit, uid)
|
||||||
|
|
||||||
def name_get(self, cr, user, ids, context={}):
|
def name_get(self, cr, user, ids, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
if not ids:
|
if not ids:
|
||||||
return []
|
return []
|
||||||
if isinstance(ids, (int, long)):
|
if isinstance(ids, (int, long)):
|
||||||
ids = [ids]
|
ids = [ids]
|
||||||
return [(r['id'], r[self._rec_name]) for r in self.read(cr, user, ids, [self._rec_name], context, load='_classic_write')]
|
return [(r['id'], r[self._rec_name]) for r in self.read(cr, user, ids, [self._rec_name], context, load='_classic_write')]
|
||||||
|
|
||||||
def name_search(self, cr, user, name='', args=[], operator='ilike', context={}, limit=80):
|
def name_search(self, cr, user, name='', args=None, operator='ilike', context=None, limit=80):
|
||||||
|
if not args:
|
||||||
|
args=[]
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
if name:
|
if name:
|
||||||
args += [(self._rec_name,operator,name)]
|
args += [(self._rec_name,operator,name)]
|
||||||
ids = self.search(cr, user, args, limit=limit)
|
ids = self.search(cr, user, args, limit=limit)
|
||||||
res = self.name_get(cr, user, ids, context)
|
res = self.name_get(cr, user, ids, context)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def copy(self, cr, uid, id, default=None, context={}):
|
def copy(self, cr, uid, id, default=None, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
if not default:
|
if not default:
|
||||||
default = {}
|
default = {}
|
||||||
if 'state' not in default:
|
if 'state' not in default:
|
||||||
|
@ -1687,7 +1737,9 @@ class orm(object):
|
||||||
del data[self._inherits[v]]
|
del data[self._inherits[v]]
|
||||||
return self.create(cr, uid, data)
|
return self.create(cr, uid, data)
|
||||||
|
|
||||||
def read_string(self, cr, uid, id, langs, fields=None, context={}):
|
def read_string(self, cr, uid, id, langs, fields=None, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
res = {}
|
res = {}
|
||||||
res2 = {}
|
res2 = {}
|
||||||
self.pool.get('ir.model.access').check(cr, uid, 'ir.translation', 'read')
|
self.pool.get('ir.model.access').check(cr, uid, 'ir.translation', 'read')
|
||||||
|
@ -1712,7 +1764,9 @@ class orm(object):
|
||||||
res[lang][f]=res2[lang][f]
|
res[lang][f]=res2[lang][f]
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def write_string(self, cr, uid, id, langs, vals, context={}):
|
def write_string(self, cr, uid, id, langs, vals, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
self.pool.get('ir.model.access').check(cr, uid, 'ir.translation', 'write')
|
self.pool.get('ir.model.access').check(cr, uid, 'ir.translation', 'write')
|
||||||
for lang in langs:
|
for lang in langs:
|
||||||
for field in vals:
|
for field in vals:
|
||||||
|
|
|
@ -292,7 +292,11 @@ class cacheable_osv(osv, Cacheable):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(cacheable_osv, self).__init__()
|
super(cacheable_osv, self).__init__()
|
||||||
|
|
||||||
def read(self, cr, user, ids, fields=[], context={}, load='_classic_read'):
|
def read(self, cr, user, ids, fields=None, context=None, load='_classic_read'):
|
||||||
|
if not fields:
|
||||||
|
fields=[]
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
fields = fields or self._columns.keys()
|
fields = fields or self._columns.keys()
|
||||||
ctx = [context.get(x, False) for x in self._relevant]
|
ctx = [context.get(x, False) for x in self._relevant]
|
||||||
result, tofetch = [], []
|
result, tofetch = [], []
|
||||||
|
@ -332,7 +336,9 @@ class cacheable_osv(osv, Cacheable):
|
||||||
def invalidate(self, key):
|
def invalidate(self, key):
|
||||||
del self._cache[key[0]][key[1]]
|
del self._cache[key[0]][key[1]]
|
||||||
|
|
||||||
def write(self, cr, user, ids, values, context={}):
|
def write(self, cr, user, ids, values, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
for id in ids:
|
for id in ids:
|
||||||
self.invalidate((self._name, id))
|
self.invalidate((self._name, id))
|
||||||
return super(cacheable_osv, self).write(cr, user, ids, values, context)
|
return super(cacheable_osv, self).write(cr, user, ids, values, context)
|
||||||
|
|
|
@ -34,7 +34,9 @@ import netsvc
|
||||||
db_dic = {}
|
db_dic = {}
|
||||||
pool_dic = {}
|
pool_dic = {}
|
||||||
|
|
||||||
def get_db_and_pool(db_name, force_demo=False, status={}, update_module=False):
|
def get_db_and_pool(db_name, force_demo=False, status=None, update_module=False):
|
||||||
|
if not status:
|
||||||
|
status={}
|
||||||
if db_name in db_dic:
|
if db_name in db_dic:
|
||||||
db = db_dic[db_name]
|
db = db_dic[db_name]
|
||||||
else:
|
else:
|
||||||
|
@ -80,7 +82,7 @@ def get_db(db_name):
|
||||||
# print "get_db", db_name
|
# print "get_db", db_name
|
||||||
return get_db_and_pool(db_name)[0]
|
return get_db_and_pool(db_name)[0]
|
||||||
|
|
||||||
def get_pool(db_name, force_demo=False, status={}, update_module=False):
|
def get_pool(db_name, force_demo=False, status=None, update_module=False):
|
||||||
# print "get_pool", db_name
|
# print "get_pool", db_name
|
||||||
pool = get_db_and_pool(db_name, force_demo, status, update_module)[1]
|
pool = get_db_and_pool(db_name, force_demo, status, update_module)[1]
|
||||||
# addons.load_modules(db_name, False)
|
# addons.load_modules(db_name, False)
|
||||||
|
|
|
@ -132,7 +132,9 @@ class report_custom(report_int):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def create(self, cr, uid, ids, datas, context={}):
|
def create(self, cr, uid, ids, datas, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
self.pool = pooler.get_pool(cr.dbname)
|
self.pool = pooler.get_pool(cr.dbname)
|
||||||
report = self.pool.get('ir.report.custom').browse(cr, uid, [datas['report_id']])[0]
|
report = self.pool.get('ir.report.custom').browse(cr, uid, [datas['report_id']])[0]
|
||||||
datas['model'] = report.model_id.model
|
datas['model'] = report.model_id.model
|
||||||
|
|
|
@ -64,7 +64,7 @@ class report_int(netsvc.Service):
|
||||||
self.joinGroup('report')
|
self.joinGroup('report')
|
||||||
self.exportMethod(self.create)
|
self.exportMethod(self.create)
|
||||||
|
|
||||||
def create(self, cr, uid, ids, datas, context={}):
|
def create(self, cr, uid, ids, datas, context=None):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -94,7 +94,9 @@ class report_rml(report_int):
|
||||||
pdf = create_doc(rml)
|
pdf = create_doc(rml)
|
||||||
return (pdf, report_type)
|
return (pdf, report_type)
|
||||||
|
|
||||||
def create_xml(self, cr, uid, ids, datas, context={}):
|
def create_xml(self, cr, uid, ids, datas, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
doc = print_xml.document(cr, uid, datas, {})
|
doc = print_xml.document(cr, uid, datas, {})
|
||||||
self.bin_datas = doc.bin_datas
|
self.bin_datas = doc.bin_datas
|
||||||
doc.parse(self.tmpl, ids, self.table, context)
|
doc.parse(self.tmpl, ids, self.table, context)
|
||||||
|
@ -102,7 +104,9 @@ class report_rml(report_int):
|
||||||
doc.close()
|
doc.close()
|
||||||
return self.post_process_xml_data(cr, uid, xml, context)
|
return self.post_process_xml_data(cr, uid, xml, context)
|
||||||
|
|
||||||
def post_process_xml_data(self, cr, uid, xml, context={}):
|
def post_process_xml_data(self, cr, uid, xml, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
# find the position of the 3rd tag
|
# find the position of the 3rd tag
|
||||||
# (skip the <?xml ...?> and the "root" tag)
|
# (skip the <?xml ...?> and the "root" tag)
|
||||||
iter = re.finditer('<[^>]*>', xml)
|
iter = re.finditer('<[^>]*>', xml)
|
||||||
|
@ -126,7 +130,9 @@ class report_rml(report_int):
|
||||||
#
|
#
|
||||||
# TODO: The translation doesn't work for "<tag t="1">textext<tag> tex</tag>text</tag>"
|
# TODO: The translation doesn't work for "<tag t="1">textext<tag> tex</tag>text</tag>"
|
||||||
#
|
#
|
||||||
def create_rml(self, cr, xml, uid, context={}):
|
def create_rml(self, cr, xml, uid, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
service = netsvc.LocalService("object_proxy")
|
service = netsvc.LocalService("object_proxy")
|
||||||
|
|
||||||
# In some case we might not use xsl ...
|
# In some case we might not use xsl ...
|
||||||
|
|
|
@ -334,18 +334,24 @@ class document(object):
|
||||||
def xml_get(self):
|
def xml_get(self):
|
||||||
return self.doc.toxml('utf-8')
|
return self.doc.toxml('utf-8')
|
||||||
|
|
||||||
def parse_tree(self, ids, model, context={}):
|
def parse_tree(self, ids, model, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
browser = self.pool.get(model).browse(self.cr, self.uid, ids, context)
|
browser = self.pool.get(model).browse(self.cr, self.uid, ids, context)
|
||||||
self.parse_node(self.dom.documentElement, self.doc, browser)
|
self.parse_node(self.dom.documentElement, self.doc, browser)
|
||||||
|
|
||||||
def parse_string(self, xml, ids, model, context={}):
|
def parse_string(self, xml, ids, model, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
# parses the xml template to memory
|
# parses the xml template to memory
|
||||||
self.dom = minidom.parseString(xml)
|
self.dom = minidom.parseString(xml)
|
||||||
|
|
||||||
# create the xml data from the xml template
|
# create the xml data from the xml template
|
||||||
self.parse_tree(ids, model, context)
|
self.parse_tree(ids, model, context)
|
||||||
|
|
||||||
def parse(self, filename, ids, model, context={}):
|
def parse(self, filename, ids, model, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
# parses the xml template to memory
|
# parses the xml template to memory
|
||||||
self.dom = minidom.parse(os.path.join(tools.config['root_path'],filename))
|
self.dom = minidom.parse(os.path.join(tools.config['root_path'],filename))
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,9 @@ class report_printscreen_list(report_int):
|
||||||
dom = minidom.parseString(view)
|
dom = minidom.parseString(view)
|
||||||
return self._parse_node(dom)
|
return self._parse_node(dom)
|
||||||
|
|
||||||
def create(self, cr, uid, ids, datas, context={}):
|
def create(self, cr, uid, ids, datas, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
datas['ids'] = ids
|
datas['ids'] = ids
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
model_id = pool.get('ir.model').search(cr, uid, [('model','=',model._name)])
|
model_id = pool.get('ir.model').search(cr, uid, [('model','=',model._name)])
|
||||||
|
|
|
@ -60,7 +60,9 @@ class report_printscreen_list(report_int):
|
||||||
dom = minidom.parseString(view.encode('utf-8'))
|
dom = minidom.parseString(view.encode('utf-8'))
|
||||||
return self._parse_node(dom)
|
return self._parse_node(dom)
|
||||||
|
|
||||||
def create(self, cr, uid, ids, datas, context={}):
|
def create(self, cr, uid, ids, datas, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
pool = pooler.get_pool(cr.dbname)
|
pool = pooler.get_pool(cr.dbname)
|
||||||
model = pool.get(datas['model'])
|
model = pool.get(datas['model'])
|
||||||
model_id = pool.get('ir.model').search(cr, uid, [('model','=',model._name)])
|
model_id = pool.get('ir.model').search(cr, uid, [('model','=',model._name)])
|
||||||
|
|
|
@ -87,7 +87,9 @@ class browse_record_list(list):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
class rml_parse(object):
|
class rml_parse(object):
|
||||||
def __init__(self, cr, uid, name, context={}):
|
def __init__(self, cr, uid, name, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
self.cr = cr
|
self.cr = cr
|
||||||
self.uid = uid
|
self.uid = uid
|
||||||
self.pool = pooler.get_pool(cr.dbname)
|
self.pool = pooler.get_pool(cr.dbname)
|
||||||
|
@ -107,7 +109,9 @@ class rml_parse(object):
|
||||||
self._node = None
|
self._node = None
|
||||||
# self.already = {}
|
# self.already = {}
|
||||||
|
|
||||||
def setTag(self, oldtag, newtag, attrs={}):
|
def setTag(self, oldtag, newtag, attrs=None):
|
||||||
|
if not attrs:
|
||||||
|
attrs={}
|
||||||
node = self._find_parent(self._node, [oldtag])
|
node = self._find_parent(self._node, [oldtag])
|
||||||
if node:
|
if node:
|
||||||
node.tagName = newtag
|
node.tagName = newtag
|
||||||
|
@ -169,7 +173,9 @@ class rml_parse(object):
|
||||||
break
|
break
|
||||||
return node
|
return node
|
||||||
|
|
||||||
def _parse_text(self, text, level=[]):
|
def _parse_text(self, text, level=None):
|
||||||
|
if not level:
|
||||||
|
level=[]
|
||||||
res = self._regex.findall(text)
|
res = self._regex.findall(text)
|
||||||
todo = []
|
todo = []
|
||||||
# translate the text
|
# translate the text
|
||||||
|
@ -307,7 +313,9 @@ class report_sxw(report_rml):
|
||||||
table_obj = pooler.get_pool(cr.dbname).get(self.table)
|
table_obj = pooler.get_pool(cr.dbname).get(self.table)
|
||||||
return table_obj.browse(cr, uid, ids, list_class=browse_record_list, context=context)
|
return table_obj.browse(cr, uid, ids, list_class=browse_record_list, context=context)
|
||||||
|
|
||||||
def create(self, cr, uid, ids, data, context={}):
|
def create(self, cr, uid, ids, data, context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
cr.execute('select report_rml_content from ir_act_report_xml where report_name=%s', (self.name[7:],))
|
cr.execute('select report_rml_content from ir_act_report_xml where report_name=%s', (self.name[7:],))
|
||||||
result = cr.fetchone()
|
result = cr.fetchone()
|
||||||
if result and result[0]:
|
if result and result[0]:
|
||||||
|
|
|
@ -277,7 +277,11 @@ class common(netsvc.Service):
|
||||||
cr.close()
|
cr.close()
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def ir_get(self, db, uid, password, keys, args=[], meta=None, context={}):
|
def ir_get(self, db, uid, password, keys, args=None, meta=None, context=None):
|
||||||
|
if not args:
|
||||||
|
args=[]
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
security.check(db, uid, password)
|
security.check(db, uid, password)
|
||||||
cr = pooler.get_db(db).cursor()
|
cr = pooler.get_db(db).cursor()
|
||||||
res = ir.ir_get(cr,uid, keys, args, meta, context)
|
res = ir.ir_get(cr,uid, keys, args, meta, context)
|
||||||
|
@ -361,7 +365,9 @@ class wizard(netsvc.Service):
|
||||||
wiz = netsvc.LocalService('wizard.'+self.wiz_name[wiz_id])
|
wiz = netsvc.LocalService('wizard.'+self.wiz_name[wiz_id])
|
||||||
return wiz.execute(db, uid, self.wiz_datas[wiz_id], action, context)
|
return wiz.execute(db, uid, self.wiz_datas[wiz_id], action, context)
|
||||||
|
|
||||||
def create(self, db, uid, passwd, wiz_name, datas={}):
|
def create(self, db, uid, passwd, wiz_name, datas=None):
|
||||||
|
if not datas:
|
||||||
|
datas={}
|
||||||
security.check(db, uid, passwd)
|
security.check(db, uid, passwd)
|
||||||
#FIXME: this is not thread-safe
|
#FIXME: this is not thread-safe
|
||||||
self.id += 1
|
self.id += 1
|
||||||
|
@ -370,7 +376,9 @@ class wizard(netsvc.Service):
|
||||||
self.wiz_uid[self.id] = uid
|
self.wiz_uid[self.id] = uid
|
||||||
return self.id
|
return self.id
|
||||||
|
|
||||||
def execute(self, db, uid, passwd, wiz_id, datas, action='init', context={}):
|
def execute(self, db, uid, passwd, wiz_id, datas, action='init', context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
security.check(db, uid, passwd)
|
security.check(db, uid, passwd)
|
||||||
|
|
||||||
if wiz_id in self.wiz_uid:
|
if wiz_id in self.wiz_uid:
|
||||||
|
@ -398,7 +406,11 @@ class report_spool(netsvc.Service):
|
||||||
self.id = 0
|
self.id = 0
|
||||||
self.id_protect = threading.Semaphore()
|
self.id_protect = threading.Semaphore()
|
||||||
|
|
||||||
def report(self, db, uid, passwd, object, ids, datas={}, context={}):
|
def report(self, db, uid, passwd, object, ids, datas=None, context=None):
|
||||||
|
if not datas:
|
||||||
|
datas={}
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
security.check(db, uid, passwd)
|
security.check(db, uid, passwd)
|
||||||
|
|
||||||
self.id_protect.acquire()
|
self.id_protect.acquire()
|
||||||
|
|
|
@ -80,7 +80,9 @@ class fake_cursor:
|
||||||
fake_cursor.nbr += 1
|
fake_cursor.nbr += 1
|
||||||
return self.obj.execute(*args)
|
return self.obj.execute(*args)
|
||||||
|
|
||||||
def execute(self, sql, params=()):
|
def execute(self, sql, params=None):
|
||||||
|
if not params:
|
||||||
|
params=()
|
||||||
def base_string(s):
|
def base_string(s):
|
||||||
if isinstance(s, unicode):
|
if isinstance(s, unicode):
|
||||||
return s.encode('utf-8')
|
return s.encode('utf-8')
|
||||||
|
|
|
@ -460,7 +460,9 @@ class xml_import(object):
|
||||||
# delimiter: ,
|
# delimiter: ,
|
||||||
# encoding: UTF8
|
# encoding: UTF8
|
||||||
#
|
#
|
||||||
def convert_csv_import(cr, module, fname, csvcontent, idref={}, mode='init', noupdate=False):
|
def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init', noupdate=False):
|
||||||
|
if not idref:
|
||||||
|
idref={}
|
||||||
model = ('.'.join(fname.split('.')[:-1]).split('-'))[0]
|
model = ('.'.join(fname.split('.')[:-1]).split('-'))[0]
|
||||||
#remove folder path from model
|
#remove folder path from model
|
||||||
head, model = os.path.split(model)
|
head, model = os.path.split(model)
|
||||||
|
@ -490,7 +492,9 @@ def convert_csv_import(cr, module, fname, csvcontent, idref={}, mode='init', nou
|
||||||
#
|
#
|
||||||
# xml import/export
|
# xml import/export
|
||||||
#
|
#
|
||||||
def convert_xml_import(cr, module, xmlstr, idref={}, mode='init'):
|
def convert_xml_import(cr, module, xmlstr, idref=None, mode='init'):
|
||||||
|
if not idref:
|
||||||
|
idref={}
|
||||||
obj = xml_import(cr, module, idref, mode)
|
obj = xml_import(cr, module, idref, mode)
|
||||||
obj.parse(xmlstr)
|
obj.parse(xmlstr)
|
||||||
del obj
|
del obj
|
||||||
|
|
|
@ -189,8 +189,12 @@ def file_open(name, mode="r", subdir='addons'):
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
# Emails
|
# Emails
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
def email_send(email_from, email_to, subject, body, email_cc=[], email_bcc=[], on_error=False, reply_to=False):
|
def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=None, on_error=False, reply_to=False):
|
||||||
"""Send an email."""
|
"""Send an email."""
|
||||||
|
if not email_cc:
|
||||||
|
email_cc=[]
|
||||||
|
if not email_bcc:
|
||||||
|
email_bcc=[]
|
||||||
import smtplib
|
import smtplib
|
||||||
from email.MIMEText import MIMEText
|
from email.MIMEText import MIMEText
|
||||||
from email.MIMEMultipart import MIMEMultipart
|
from email.MIMEMultipart import MIMEMultipart
|
||||||
|
@ -225,8 +229,14 @@ def email_send(email_from, email_to, subject, body, email_cc=[], email_bcc=[], o
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
# Emails
|
# Emails
|
||||||
#----------------------------------------------------------
|
#----------------------------------------------------------
|
||||||
def email_send_attach(email_from, email_to, subject, body, email_cc=[], email_bcc=[], on_error=False, reply_to=False, attach=[]):
|
def email_send_attach(email_from, email_to, subject, body, email_cc=None, email_bcc=None, on_error=False, reply_to=False, attach=None):
|
||||||
"""Send an email."""
|
"""Send an email."""
|
||||||
|
if not email_cc:
|
||||||
|
email_cc=[]
|
||||||
|
if not email_bcc:
|
||||||
|
email_bcc=[]
|
||||||
|
if not attach:
|
||||||
|
attach=[]
|
||||||
import smtplib
|
import smtplib
|
||||||
from email.MIMEText import MIMEText
|
from email.MIMEText import MIMEText
|
||||||
from email.MIMEBase import MIMEBase
|
from email.MIMEBase import MIMEBase
|
||||||
|
|
|
@ -56,8 +56,10 @@ class interface(netsvc.Service):
|
||||||
node.setAttribute('string', trans.decode('utf8'))
|
node.setAttribute('string', trans.decode('utf8'))
|
||||||
for n in node.childNodes:
|
for n in node.childNodes:
|
||||||
self.translate_view(cr, uid, n, state, lang)
|
self.translate_view(cr, uid, n, state, lang)
|
||||||
|
|
||||||
def execute_cr(self, cr, uid, data, state='init', context={}):
|
def execute_cr(self, cr, uid, data, state='init', context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
res = {}
|
res = {}
|
||||||
try:
|
try:
|
||||||
state_def = self.states[state]
|
state_def = self.states[state]
|
||||||
|
@ -140,7 +142,9 @@ class interface(netsvc.Service):
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def execute(self, db, uid, data, state='init', context={}):
|
def execute(self, db, uid, data, state='init', context=None):
|
||||||
|
if not context:
|
||||||
|
context={}
|
||||||
cr = pooler.get_db(db).cursor()
|
cr = pooler.get_db(db).cursor()
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue