[FIX] unmutable defaults in base addons.

bzr revid: ls@numerigraphe.fr-20111107151949-n9prrufvqe3ohz18
This commit is contained in:
Numerigraphe - Lionel Sausin 2011-11-07 16:19:49 +01:00
parent b6defa5269
commit 9ed5cbb24c
16 changed files with 38 additions and 30 deletions

View File

@ -34,7 +34,7 @@ class ir_default(osv.osv):
'company_id': fields.many2one('res.company','Company')
}
def _get_company_id(self, cr, uid, context={}):
def _get_company_id(self, cr, uid, context=None):
res = self.pool.get('res.users').read(cr, uid, [uid], ['company_id'], context=context)
if res and res[0]['company_id']:
return res[0]['company_id'][0]

View File

@ -53,7 +53,7 @@ class ir_filters(osv.osv):
return False
return self.create(cr, uid, vals, context)
def _auto_init(self, cr, context={}):
def _auto_init(self, cr, context=None):
super(ir_filters, self)._auto_init(cr, context)
# Use unique index to implement unique constraint on the lowercase name (not possible using a constraint)
cr.execute("SELECT indexname FROM pg_indexes WHERE indexname = 'ir_filters_name_model_uid_unique_index'")

View File

@ -161,7 +161,7 @@ class ir_model(osv.osv):
#pooler.restart_pool(cr.dbname)
return res
def instanciate(self, cr, user, model, context={}):
def instanciate(self, cr, user, model, context=None):
class x_custom_model(osv.osv):
pass
x_custom_model._name = model

View File

@ -38,7 +38,7 @@ class ir_sequence_type(openerp.osv.osv.osv):
('code_unique', 'unique(code)', '`code` must be unique.'),
]
def _code_get(self, cr, uid, context={}):
def _code_get(self, cr, uid, context=None):
cr.execute('select code, name from ir_sequence_type')
return cr.fetchall()

View File

@ -62,7 +62,7 @@ class ir_translation(osv.osv):
'xml_id': fields.char('External ID', size=128, help='Maps to the ir_model_data for which this translation is provided.'),
}
def _auto_init(self, cr, context={}):
def _auto_init(self, cr, context=None):
super(ir_translation, self)._auto_init(cr, context)
# FIXME: there is a size limit on btree indexed values so we can't index src column with normal btree.

View File

@ -109,7 +109,7 @@ class view(osv.osv):
(view_id, model))
return cr.fetchall()
def write(self, cr, uid, ids, vals, context={}):
def write(self, cr, uid, ids, vals, context=None):
if not isinstance(ids, (list, tuple)):
ids = [ids]
result = super(view, self).write(cr, uid, ids, vals, context)
@ -122,7 +122,7 @@ class view(osv.osv):
return result
def graph_get(self, cr, uid, id, model, node_obj, conn_obj, src_node, des_node,label,scale,context={}):
def graph_get(self, cr, uid, id, model, node_obj, conn_obj, src_node, des_node, label, scale, context=None):
if not label:
label = []
nodes=[]

View File

@ -210,7 +210,7 @@ class report_graph(report.interface.report_int):
else:
return (False, False, False)
def create(self, cr, uid, ids, data, context={}):
def create(self, cr, uid, ids, data, context=None):
self.obj = report_graph_instance(cr, uid, ids, data)
return (self.obj.get(), 'pdf')

View File

@ -45,7 +45,7 @@ class workflow(osv.osv):
wf_service.clear_cache(cr, user)
return super(workflow, self).write(cr, user, ids, vals, context=context)
def get_active_workitems(self, cr, uid, res, res_id, context={}):
def get_active_workitems(self, cr, uid, res, res_id, context=None):
cr.execute('select * from wkf where osv=%s limit 1',(res,))
wkfinfo = cr.dictfetchone()
@ -212,7 +212,7 @@ class wkf_triggers(osv.osv):
'instance_id': fields.many2one('workflow.instance', 'Destination Instance', ondelete="cascade"),
'workitem_id': fields.many2one('workflow.workitem', 'Workitem', required=True, ondelete="cascade"),
}
def _auto_init(self, cr, context={}):
def _auto_init(self, cr, context=None):
super(wkf_triggers, self)._auto_init(cr, context)
cr.execute('SELECT indexname FROM pg_indexes WHERE indexname = \'wkf_triggers_res_id_model_index\'')
if not cr.fetchone():

View File

@ -402,7 +402,7 @@ class module(osv.osv):
}
# update the list of available packages
def update_list(self, cr, uid, context={}):
def update_list(self, cr, uid, context=None):
res = [0, 0] # [update, add]
known_mods = self.browse(cr, uid, self.search(cr, uid, []))

View File

@ -156,7 +156,7 @@ class ir_property(osv.osv):
return time.strftime('%Y-%m-%d', time.strptime(record.value_datetime, '%Y-%m-%d %H:%M:%S'))
return False
def get(self, cr, uid, name, model, res_id=False, context={}):
def get(self, cr, uid, name, model, res_id=False, context=None):
domain = self._get_domain(cr, uid, name, model, context=context)
if domain is not None:
domain = [('res_id', '=', res_id)] + domain

View File

@ -190,7 +190,7 @@ class res_partner_bank(osv.osv):
res.append((val.id, result))
return res
def onchange_company_id(self, cr, uid, ids, company_id, context={}):
def onchange_company_id(self, cr, uid, ids, company_id, context=None):
result = {}
if company_id:
c = self.pool.get('res.company').browse(cr, uid, company_id, context=context)
@ -201,7 +201,7 @@ class res_partner_bank(osv.osv):
result = r
return result
def onchange_bank_id(self, cr, uid, ids, bank_id, context={}):
def onchange_bank_id(self, cr, uid, ids, bank_id, context=None):
result = {}
if bank_id:
bank = self.pool.get('res.bank').browse(cr, uid, bank_id, context=context)
@ -210,7 +210,7 @@ class res_partner_bank(osv.osv):
return {'value': result}
def onchange_partner_id(self, cr, uid, id, partner_id, context={}):
def onchange_partner_id(self, cr, uid, id, partner_id, context=None):
result = {}
if partner_id:
part = self.pool.get('res.partner').browse(cr, uid, partner_id, context=context)

View File

@ -148,7 +148,7 @@ class res_company(osv.osv):
_sql_constraints = [
('name_uniq', 'unique (name)', 'The company name must be unique !')
]
def on_change_header(self, cr, uid, ids, phone, email, fax, website, vat, reg=False, context={}):
def on_change_header(self, cr, uid, ids, phone, email, fax, website, vat, reg=False, context=None):
val = []
if phone: val.append(_('Phone: ')+phone)
if fax: val.append(_('Fax: ')+fax)
@ -201,7 +201,7 @@ class res_company(osv.osv):
ids = self.search(cr, uid, [('parent_id','child_of',[company])])
return ids
def _get_partner_hierarchy(self, cr, uid, company_id, context={}):
def _get_partner_hierarchy(self, cr, uid, company_id, context=None):
if company_id:
parent_id = self.browse(cr, uid, company_id)['parent_id']
if parent_id:
@ -210,7 +210,7 @@ class res_company(osv.osv):
return self._get_partner_descendance(cr, uid, company_id, [], context)
return []
def _get_partner_descendance(self, cr, uid, company_id, descendance, context={}):
def _get_partner_descendance(self, cr, uid, company_id, descendance, context=None):
descendance.append(self.browse(cr, uid, company_id).partner_id.id)
for child_id in self._get_company_children(cr, uid, company_id):
if child_id != company_id:
@ -239,7 +239,7 @@ class res_company(osv.osv):
self.cache_restart(cr)
return super(res_company, self).write(cr, *args, **argv)
def _get_euro(self, cr, uid, context={}):
def _get_euro(self, cr, uid, context=None):
try:
return self.pool.get('res.currency').search(cr, uid, [])[0]
except:

View File

@ -125,10 +125,10 @@ class lang(osv.osv):
return False
return True
def _get_default_date_format(self,cursor,user,context={}):
def _get_default_date_format(self, cursor, user, context=None):
return '%m/%d/%Y'
def _get_default_time_format(self,cursor,user,context={}):
def _get_default_time_format(self, cursor, user, context=None):
return '%H:%M:%S'
_columns = {

View File

@ -41,7 +41,7 @@ class res_log(osv.osv):
_order='create_date desc'
_index_name = 'res_log_uid_read'
def _auto_init(self, cr, context={}):
def _auto_init(self, cr, context=None):
super(res_log, self)._auto_init(cr, context)
cr.execute('SELECT 1 FROM pg_indexes WHERE indexname=%s',
(self._index_name,))

View File

@ -98,7 +98,7 @@ class res_partner_title(osv.osv):
_order = 'name'
res_partner_title()
def _lang_get(self, cr, uid, context={}):
def _lang_get(self, cr, uid, context=None):
obj = self.pool.get('res.lang')
ids = obj.search(cr, uid, [], context=context)
res = obj.read(cr, uid, ids, ['code', 'name'], context)
@ -142,7 +142,9 @@ class res_partner(osv.osv):
'color': fields.integer('Color Index'),
}
def _default_category(self, cr, uid, context={}):
def _default_category(self, cr, uid, context=None):
if context is None:
context = {}
if 'category_id' in context and context['category_id']:
return [context['category_id']]
return []
@ -156,7 +158,9 @@ class res_partner(osv.osv):
'color': 0,
}
def copy(self, cr, uid, id, default={}, context={}):
def copy(self, cr, uid, id, default=None, context=None):
if default is None:
default = {}
name = self.read(cr, uid, [id], ['name'])[0]['name']
default.update({'name': name+ _(' (copy)'), 'events':[]})
return super(res_partner, self).copy(cr, uid, id, default, context)
@ -182,10 +186,12 @@ class res_partner(osv.osv):
# _constraints = [(_check_ean_key, 'Error: Invalid ean code', ['ean13'])]
def name_get(self, cr, uid, ids, context={}):
def name_get(self, cr, uid, ids, context=None):
if context is None:
context = {}
if not len(ids):
return []
if context and context.get('show_ref'):
if context.get('show_ref', False):
rec_name = 'ref'
else:
rec_name = 'name'
@ -224,7 +230,9 @@ class res_partner(osv.osv):
ids = ids[16:]
return True
def address_get(self, cr, uid, ids, adr_pref=['default']):
def address_get(self, cr, uid, ids, adr_pref=None):
if adr_pref is None:
adr_pref = ['default']
address_obj = self.pool.get('res.partner.address')
address_ids = address_obj.search(cr, uid, [('partner_id', 'in', ids)])
address_rec = address_obj.read(cr, uid, address_ids, ['type'])
@ -308,7 +316,7 @@ class res_partner_address(osv.osv):
'company_id': lambda s,cr,uid,c: s.pool.get('res.company')._company_default_get(cr, uid, 'res.partner.address', context=c),
}
def name_get(self, cr, user, ids, context={}):
def name_get(self, cr, user, ids, context=None):
if context is None:
context = {}
if not len(ids):

View File

@ -22,7 +22,7 @@
from osv import osv, fields
import time
def _links_get(self, cr, uid, context={}):
def _links_get(self, cr, uid, context=None):
obj = self.pool.get('res.request.link')
ids = obj.search(cr, uid, [])
res = obj.read(cr, uid, ids, ['object', 'name'], context)