[IMP]Improve code : save the host name value to avoid writing each time.

bzr revid: dbr@tinyerp.com-20110630084124-gd84vzblzarth5lg
This commit is contained in:
DBR (OpenERP) 2011-06-30 14:11:24 +05:30
parent f9c9c79bbf
commit ffe4df20d4
2 changed files with 13 additions and 2 deletions

View File

@ -237,12 +237,22 @@ class user_preference(osv.osv_memory):
collection_obj = self.pool.get('document.directory')
ids = collection_obj.search(cr, uid, [('name', '=', 'c')])
return ids[0]
def _get_default_host(self, cr, uid, context):
ids=self.search(cr,uid,[])
host_name = ''
if ids:
ids = len(ids)> 1 and len(ids)-1 or ids[0] # Use len(ids)-1 for taking the value of last id
host_obj = self.browse(cr, uid,[ids],context=context)[0]
host_name = host_obj.host_name
return host_name
_defaults={
'service': 'webdav',
'collection' : _get_default_collection,
'calendar' : _get_default_calendar,
'device' : 'other',
'host_name':_get_default_host
}

View File

@ -28,11 +28,12 @@
<field name="model">user.preference</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Host name configuration for caldev synchronization">
<separator string="Hostname example : " colspan="4"/>
<form string="Caldav's host name configuration">
<label string="Configure your openerp hostname. For example : " colspan="4"></label>
<newline/>
<label string="database.my.openerp.com or companyserver.com" colspan="4"/>
<newline/>
<separator colspan="4"/>
<field name="host_name" colspan="4" width="250" />
<separator colspan="4"/>
<group col="4" colspan="4">