[IMP] get hostname using get_param + add default value in get_param

bzr revid: tfr@openerp.com-20110712152027-oj6b42o0bttijkst
This commit is contained in:
tfr@openerp.com 2011-07-12 17:20:27 +02:00
parent cea05b572e
commit f6acf31295
2 changed files with 6 additions and 2 deletions

View File

@ -62,7 +62,7 @@ class ir_config_parameter(osv.osv):
if not ids:
self.set_param(cr, 1, key, func())
def get_param(self, cr, uid, key, context=None):
def get_param(self, cr, uid, key, default=False, context=None):
""" Get the value of a parameter.
@param key: The key of the parameter.
@ -72,7 +72,7 @@ class ir_config_parameter(osv.osv):
"""
ids = self.search(cr, uid, [('key','=',key)], context=context)
if not ids:
return False
return default
param = self.browse(cr, uid, ids[0], context=context)
value = param.value
return value

View File

@ -248,6 +248,10 @@ def flatten(list):
r.append(e)
return r
def get_hostname(obj, cr, uid):
return obj.pool.get('ir.config_parameter').get_param(cr, uid, 'network.hostname', default="localhost")
def reverse_enumerate(l):
"""Like enumerate but in the other sens