[IMP] get hostname using get_param + add default value in get_param
bzr revid: tfr@openerp.com-20110712152027-oj6b42o0bttijkst
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user