summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrpa (Open ERP) <rpa@tinyerp.com>2010-06-09 18:10:06 +0530
committerrpa (Open ERP) <rpa@tinyerp.com>2010-06-09 18:10:06 +0530
commitb2b048737d6dd067be9cbfbf5dff729c4e9da3c8 (patch)
tree0a8a03d1110090690bc14d0483151cfc6f87f4db
parente02afffe617553c2213270868c65c4efe46e133e (diff)
[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
-rw-r--r--addons/fetchmail/fetchmail.py30
1 files changed, 22 insertions, 8 deletions
diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py
index 10a51f0f5b2..4b798cea9a4 100644
--- a/addons/fetchmail/fetchmail.py
+++ b/addons/fetchmail/fetchmail.py
@@ -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)