[FIX]: fix a problem if no method defined for email event

message_new
message_update

bzr revid: mga@tinyerp.com-20100420202359-iwsu3wcybupaf2qc
This commit is contained in:
Mantavya Gajjar
2010-04-21 01:53:59 +05:30
parent 0e53e4b64a
commit b63dd0fd7a
2 changed files with 17 additions and 33 deletions
+17 -8
View File
@@ -253,7 +253,8 @@ class mail_server(osv.osv):
msg['body'] = body
msg['attachments'] = attachents
res_id = False
if msg.get('references', False):
id = False
ref = msg.get('references')
@@ -274,12 +275,20 @@ class mail_server(osv.osv):
vals = {
}
model_pool.message_update(cr, uid, [history.res_id], vals, msg, context=context)
if hasattr(model_pool, 'message_update'):
model_pool.message_update(cr, uid, [history.res_id], vals, msg, context=context)
else:
logger.notifyChannel('imap', netsvc.LOG_WARNING, 'method def message_update is not define in model %s' % (model_pool._name))
return False
res_id = id
else:
model_pool = self.pool.get(server.object_id.model)
res_id = model_pool.message_new(cr, uid, msg, context)
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
for attactment in attachents or []:
data_attach = {
'name': attactment,
@@ -333,10 +342,10 @@ class mail_server(osv.osv):
result, data = imap_server.search(None, '(UNSEEN)')
for num in data[0].split():
result, data = imap_server.fetch(num, '(RFC822)')
self._process_email(cr, uid, server, data[0][1], context)
imap_server.store(num, '+FLAGS', '\\Seen')
count += 1
logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail fetch %s email(s) from %s' % (count, server.name))
if self._process_email(cr, uid, server, data[0][1], context):
imap_server.store(num, '+FLAGS', '\\Seen')
count += 1
logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail fetch/process %s email(s) from %s' % (count, server.name))
imap_server.close()
imap_server.logout()
-25
View File
@@ -43,31 +43,6 @@
<field name="view_id" ref="view_server_statistics_graph" />
</record>
<record model="ir.ui.view" id="company_form">
<field name="name">smtp.company.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form" />
<field name="type">form</field>
<field name="arch" type="xml">
<notebook position="inside">
<page string="SMTP Settings">
<field name="addresses" colspan="4"
nolabel="1">
<tree string="Email Address">
<field name="name" />
<field name="email" />
</tree>
<form string="Email Address">
<field name="name" />
<field name="email"
domain="[('state','=','confirm')]" />
</form>
</field>
</page>
</notebook>
</field>
</record>
<record model="ir.ui.view" id="email_smtpclient_form_new">
<field name="name">email.smtpclient.form</field>
<field name="model">email.smtpclient</field>