[IMP] fetchmail: Introduce the fetchmail_model keyword in the context to specify the default value for the object field of the fetchmail.server object

bzr revid: stw@openerp.com-20110922130827-ny2i17lng1x1ua59
This commit is contained in:
Stephane Wirtel 2011-09-22 15:08:27 +02:00
parent e3e5fe5cbe
commit 7afbca3af9
1 changed files with 16 additions and 0 deletions

View File

@ -78,6 +78,22 @@ class fetchmail_server(osv.osv):
'attach': True,
}
def default_get(self, cr, uid, fields, context=None):
if context is None:
context = {}
result = super(fetchmail_server, self).default_get(cr, uid, fields, context=context)
model = context.pop('fetchmail_model', False) or False
if isinstance(model, basestring):
model_id = self.pool.get('ir.model').search(cr, uid, [('model', '=', model)], context=context)
result.update(
object_id = model_id[0],
)
return result
def onchange_server_type(self, cr, uid, ids, server_type=False, ssl=False):
port = 0
if server_type == 'pop':