[IMP]: fetchmail: * If the model for which mails to be fetched do not have message_new, we should use basic create method.
* Improved history maintenance (Put proper data + attachment in history) bzr revid: rpa@tinyerp.com-20100609124006-84whz7b92fgnmr7e
This commit is contained in:
@@ -282,7 +282,6 @@ class email_server(osv.osv):
|
||||
ref = msg.get('references').split('\r\n')
|
||||
else:
|
||||
ref = msg.get('references').split(' ')
|
||||
|
||||
if ref:
|
||||
hids = history_pool.search(cr, uid, [('name','=',ref[0].strip())])
|
||||
if hids:
|
||||
@@ -306,9 +305,18 @@ class email_server(osv.osv):
|
||||
if hasattr(model_pool, 'message_new'):
|
||||
res_id = model_pool.message_new(cr, uid, msg, context)
|
||||
else:
|
||||
logger.notifyChannel('imap', netsvc.LOG_WARNING, 'method def message_new is not define in model %s' % (model_pool._name))
|
||||
return False
|
||||
|
||||
data = {
|
||||
'name': msg.get('subject'),
|
||||
'email_from': msg.get('from'),
|
||||
'email_cc': msg.get('cc'),
|
||||
'user_id': False,
|
||||
'description': msg.get('body'),
|
||||
'state' : 'draft',
|
||||
}
|
||||
res_id = model_pool.create(cr, uid, data, context=context)
|
||||
logger.notifyChannel('imap', netsvc.LOG_WARNING, 'method def message_new is not define in model %s. Using default method' % (model_pool._name))
|
||||
|
||||
att_ids = []
|
||||
if server.attach:
|
||||
for attactment in attachents or []:
|
||||
data_attach = {
|
||||
@@ -319,19 +327,25 @@ class email_server(osv.osv):
|
||||
'res_model': server.object_id.model,
|
||||
'res_id': res_id,
|
||||
}
|
||||
self.pool.get('ir.attachment').create(cr, uid, data_attach)
|
||||
att_ids.append(self.pool.get('ir.attachment').create(cr, uid, data_attach))
|
||||
|
||||
if server.action_id:
|
||||
action_pool = self.pool.get('ir.actions.server')
|
||||
action_pool.run(cr, uid, [server.action_id.id], {'active_id':res_id, 'active_ids':[res_id]})
|
||||
|
||||
res = {
|
||||
'name': message_id,
|
||||
'name': msg.get('subject', 'No subject'),
|
||||
'message_id': message_id,
|
||||
'date': msg.get('date'),
|
||||
'res_id': res_id,
|
||||
'email_from': msg.get('from'),
|
||||
'email_to': msg.get('to'),
|
||||
'email_cc': msg.get('cc'),
|
||||
'model': server.object_id.model,
|
||||
'server_id': server.id,
|
||||
'description': msg.get('body', msg.get('from')),
|
||||
'ref_id':msg.get('references', msg.get('id')),
|
||||
'type':server.type
|
||||
'type':server.type,
|
||||
'attachment_ids': [(6, 0, att_ids)]
|
||||
}
|
||||
his_id = history_pool.create(cr, uid, res)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user