[MERGE] ir,osv,tools: replaced some mutable method parameters with None
lp bug: https://launchpad.net/bugs/525808 fixed bzr revid: odo@openerp.com-20101112180727-y6tz92etl6tfep11
This commit is contained in:
+1
-1
@@ -31,7 +31,7 @@ def ir_del(cr, uid, id):
|
||||
obj = pooler.get_pool(cr.dbname).get('ir.values')
|
||||
return obj.unlink(cr, uid, [id])
|
||||
|
||||
def ir_get(cr, uid, key, key2, models, meta=False, context={}, res_id_req=False):
|
||||
def ir_get(cr, uid, key, key2, models, meta=False, context=None, res_id_req=False):
|
||||
obj = pooler.get_pool(cr.dbname).get('ir.values')
|
||||
res = obj.get(cr, uid, key, key2, models, meta=meta, context=context, res_id_req=res_id_req)
|
||||
return res
|
||||
|
||||
+11
-9
@@ -63,8 +63,10 @@ class _column(object):
|
||||
_symbol_set = (_symbol_c, _symbol_f)
|
||||
_symbol_get = None
|
||||
|
||||
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):
|
||||
if not context:
|
||||
def __init__(self, string='unknown', required=False, readonly=False, domain=None, context=None, states=None, priority=0, change_default=False, size=None, ondelete="set null", translate=False, select=False, **args):
|
||||
if domain is None:
|
||||
domain = []
|
||||
if context is None:
|
||||
context = {}
|
||||
self.states = states or {}
|
||||
self.string = string
|
||||
@@ -76,7 +78,7 @@ class _column(object):
|
||||
self.change_default = change_default
|
||||
self.ondelete = ondelete
|
||||
self.translate = translate
|
||||
self._domain = domain or []
|
||||
self._domain = domain
|
||||
self._context = context
|
||||
self.write = False
|
||||
self.read = False
|
||||
@@ -403,7 +405,7 @@ class one2many(_column):
|
||||
assert(self.change_default != True)
|
||||
|
||||
def get_memory(self, cr, obj, ids, name, user=None, offset=0, context=None, values=None):
|
||||
if not context:
|
||||
if context is None:
|
||||
context = {}
|
||||
if self._context:
|
||||
context = context.copy()
|
||||
@@ -786,7 +788,7 @@ class function(_column):
|
||||
|
||||
class related(function):
|
||||
|
||||
def _fnct_search(self, tobj, cr, uid, obj=None, name=None, domain=None, context={}):
|
||||
def _fnct_search(self, tobj, cr, uid, obj=None, name=None, domain=None, context=None):
|
||||
self._field_get2(cr, uid, obj, context)
|
||||
i = len(self._arg)-1
|
||||
sarg = name
|
||||
@@ -803,7 +805,7 @@ class related(function):
|
||||
return [(self._arg[0], 'in', sarg)]
|
||||
|
||||
def _fnct_write(self,obj,cr, uid, ids, field_name, values, args, context=None):
|
||||
self._field_get2(cr, uid, obj, context)
|
||||
self._field_get2(cr, uid, obj, context=context)
|
||||
if type(ids) != type([]):
|
||||
ids=[ids]
|
||||
objlst = obj.browse(cr, uid, ids)
|
||||
@@ -884,7 +886,7 @@ class related(function):
|
||||
# TODO: improve here to change self.store = {...} according to related objects
|
||||
pass
|
||||
|
||||
def _field_get2(self, cr, uid, obj, context={}):
|
||||
def _field_get2(self, cr, uid, obj, context=None):
|
||||
if self._relations:
|
||||
return
|
||||
obj_name = obj._name
|
||||
@@ -904,10 +906,10 @@ class related(function):
|
||||
# ---------------------------------------------------------
|
||||
|
||||
class dummy(function):
|
||||
def _fnct_search(self, tobj, cr, uid, obj=None, name=None, domain=None, context={}):
|
||||
def _fnct_search(self, tobj, cr, uid, obj=None, name=None, domain=None, context=None):
|
||||
return []
|
||||
|
||||
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):
|
||||
return False
|
||||
|
||||
def _fnct_read(self, obj, cr, uid, ids, field_name, args, context=None):
|
||||
|
||||
+16
-12
@@ -126,12 +126,14 @@ class browse_record_list(list):
|
||||
class browse_record(object):
|
||||
logger = netsvc.Logger()
|
||||
|
||||
def __init__(self, cr, uid, id, table, cache, context=None, list_class = None, fields_process={}):
|
||||
def __init__(self, cr, uid, id, table, cache, context=None, list_class=None, fields_process=None):
|
||||
'''
|
||||
table : the object (inherited from orm)
|
||||
context : dictionary with an optional context
|
||||
'''
|
||||
if not context:
|
||||
if fields_process is None:
|
||||
fields_process = {}
|
||||
if context is None:
|
||||
context = {}
|
||||
self._list_class = list_class or browse_record_list
|
||||
self._cr = cr
|
||||
@@ -404,7 +406,9 @@ class orm_template(object):
|
||||
def read_group(self, cr, uid, domain, fields, groupby, offset=0, limit=None, context=None):
|
||||
raise NotImplementedError(_('The read_group method is not implemented on this object !'))
|
||||
|
||||
def _field_create(self, cr, context={}):
|
||||
def _field_create(self, cr, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
cr.execute("SELECT id FROM ir_model WHERE model=%s", (self._name,))
|
||||
if not cr.rowcount:
|
||||
cr.execute('SELECT nextval(%s)', ('ir_model_id_seq',))
|
||||
@@ -489,8 +493,8 @@ class orm_template(object):
|
||||
break
|
||||
cr.commit()
|
||||
|
||||
def _auto_init(self, cr, context={}):
|
||||
self._field_create(cr, context)
|
||||
def _auto_init(self, cr, context=None):
|
||||
self._field_create(cr, context=context)
|
||||
|
||||
def __init__(self, cr):
|
||||
if not self._name and not hasattr(self, '_inherit'):
|
||||
@@ -506,7 +510,7 @@ class orm_template(object):
|
||||
if not self._table:
|
||||
self._table = self._name.replace('.', '_')
|
||||
|
||||
def browse(self, cr, uid, select, context=None, list_class=None, fields_process={}):
|
||||
def browse(self, cr, uid, select, context=None, list_class=None, fields_process=None):
|
||||
"""
|
||||
Fetch records as objects allowing to use dot notation to browse fields and relations
|
||||
|
||||
@@ -517,8 +521,6 @@ class orm_template(object):
|
||||
:rtype: object or list of objects requested
|
||||
|
||||
"""
|
||||
if not context:
|
||||
context = {}
|
||||
self._list_class = list_class or browse_record_list
|
||||
cache = {}
|
||||
# need to accepts ints and longs because ids coming from a method
|
||||
@@ -526,7 +528,7 @@ class orm_template(object):
|
||||
if isinstance(select, (int, long)):
|
||||
return browse_record(cr, uid, select, self, cache, context=context, list_class=self._list_class, fields_process=fields_process)
|
||||
elif isinstance(select, list):
|
||||
return self._list_class([browse_record(cr, uid, id, self, cache, context=context, list_class=self._list_class, fields_process=fields_process) for id in select], context)
|
||||
return self._list_class([browse_record(cr, uid, id, self, cache, context=context, list_class=self._list_class, fields_process=fields_process) for id in select], context=context)
|
||||
else:
|
||||
return browse_null()
|
||||
|
||||
@@ -1498,14 +1500,14 @@ class orm_template(object):
|
||||
|
||||
return arch
|
||||
|
||||
def __get_default_search_view(self, cr, uid, context={}):
|
||||
def __get_default_search_view(self, cr, uid, context=None):
|
||||
|
||||
def encode(s):
|
||||
if isinstance(s, unicode):
|
||||
return s.encode('utf8')
|
||||
return s
|
||||
|
||||
view = self.fields_view_get(cr, uid, False, 'form', context)
|
||||
view = self.fields_view_get(cr, uid, False, 'form', context=context)
|
||||
|
||||
root = etree.fromstring(encode(view['arch']))
|
||||
res = etree.XML("""<search string="%s"></search>""" % root.get("string", ""))
|
||||
@@ -2410,7 +2412,9 @@ class orm(orm_template):
|
||||
self.__schema.debug("Table '%s': column '%s': dropped NOT NULL constraint",
|
||||
self._table, column['attname'])
|
||||
|
||||
def _auto_init(self, cr, context={}):
|
||||
def _auto_init(self, cr, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
store_compute = False
|
||||
create = False
|
||||
todo_end = []
|
||||
|
||||
@@ -655,7 +655,7 @@ form: module.record_id""" % (xml_id,)
|
||||
self.pool.get('ir.model.data').ir_set(cr, self.uid, 'action', 'tree_but_open', 'Menuitem', [('ir.ui.menu', int(pid))], action, True, True, xml_id=rec_id)
|
||||
return ('ir.ui.menu', pid)
|
||||
|
||||
def _assert_equals(self, f1, f2, prec = 4):
|
||||
def _assert_equals(self, f1, f2, prec=4):
|
||||
return not round(f1 - f2, prec)
|
||||
|
||||
def _tag_assert(self, cr, rec, data_node=None):
|
||||
|
||||
+3
-1
@@ -164,7 +164,7 @@ d[types.InstanceType] = _copy_inst
|
||||
|
||||
del d
|
||||
|
||||
def deepcopy(x, memo=None, _nil=[]):
|
||||
def deepcopy(x, memo=None, _nil=None):
|
||||
"""Deep copy operation on arbitrary Python objects.
|
||||
|
||||
See the module's __doc__ string for more info.
|
||||
@@ -172,6 +172,8 @@ def deepcopy(x, memo=None, _nil=[]):
|
||||
|
||||
if memo is None:
|
||||
memo = {}
|
||||
if _nil is None:
|
||||
_nil = {}
|
||||
|
||||
d = id(x)
|
||||
y = memo.get(d, _nil)
|
||||
|
||||
@@ -60,7 +60,7 @@ trailer
|
||||
%%EOF
|
||||
"""
|
||||
|
||||
def output_field( f ):
|
||||
def output_field(f):
|
||||
return "\xfe\xff" + "".join( [ "\x00"+c for c in f ] )
|
||||
|
||||
def extract_keys(lines):
|
||||
|
||||
Reference in New Issue
Block a user