[IMP]: mail_gateway: Improvements for mailgate message creation on new mail fetched + view improvement

bzr revid: rpa@tinyerp.com-20100602112158-0tgg94lpcpr73pig
This commit is contained in:
rpa (Open ERP)
2010-06-02 16:51:58 +05:30
parent 6883726ee4
commit 819c10ca65
2 changed files with 24 additions and 18 deletions
+19 -9
View File
@@ -14,14 +14,19 @@
</group>
<notebook colspan="4">
<page string="Details">
<group col="4" colspan="4">
<group col="2" colspan="2">
<separator string="Email Details" colspan="4"/>
<field name="email_from" />
<field name="email_to" />
<field name="email_cc" />
<field name="email_bcc" />
<field name="message_id" />
<field name="email_bcc" invisible="1"/>
</group>
<group col="2" colspan="2">
<separator string="Message Details" colspan="4"/>
<field name="model" readonly="1"/>
<field name="res_id" readonly="1"/>
<field name="message_id" />
</group>
<separator string="Description" colspan="4"/>
<field name="description" nolabel="1" colspan="4" />
</page>
@@ -70,9 +75,6 @@
<form string="Mailgateway Thread">
<group col="6" colspan="4">
<field name="thread" select="1" colspan="3"/>
<newline/>
<field name="model" />
<field name="res_id" />
</group>
<separator string="Logs" colspan="4"/>
<field name="log_ids" nolabel="1" colspan="4" domain="[('history', '=', True)]">
@@ -169,9 +171,17 @@
<field name="view_id" ref="view_mailgate_thread_form"/>
<field name="act_window_id" ref="action_view_mailgate_thread"/>
</record>
<menuitem id="menu_mailgate_thread" name="Mailgateway Threads" action="action_view_mailgate_thread"
<!-- Mailgateway message action-->
<record model="ir.actions.act_window" id="action_view_mailgate_message">
<field name="name">Mailgateway Messages</field>
<field name="res_model">mailgate.message</field>
<field name="view_mode">tree,form</field>
<field name="view_type">form</field>
<field name="view_id" ref="view_mailgate_message_tree"/>
</record>
<menuitem id="menu_mailgate_message" name="Mailgateway Messages" action="action_view_mailgate_message"
parent="base.menu_base_config" sequence="20"/>
<act_window domain="[('partner_id', '=', active_id), ('history', '=', True)]"
@@ -177,17 +177,13 @@ class email_parser(object):
s = decode_header(s.replace('\r', ''))
return ''.join(map(lambda x:self._to_decode(x[0], [x[1]]), s or []))
def history(self, model, new_id, subject, msg_to, msg_from, body, attach):
thread_data = {
'model': model,
'res_id': new_id,
'thread': subject,
}
thread_id = self.rpc('mailgate.thread', 'create', thread_data)
def history(self, model, new_id, msg_id, subject, msg_to, msg_from, body, attach):
msg_data = {
'name': subject,
'history': True,
'thread_id': thread_id,
'model': model,
'res_id': new_id,
'message_id': msg_id,
'user_id': self.rpc.user_id,
'date': time.strftime('%Y-%m-%d %H:%M:%S'),
'email_from': msg_from,
@@ -232,7 +228,7 @@ class email_parser(object):
try:
self.rpc(self.model, 'history', [new_id], 'Receive', True, msg_to, message['body'], msg_from, False, {'model' : self.model})
except Exception, e:
self.history(self.model, new_id, msg_subject, msg_to, msg_from, message['body'], att_ids)
self.history(self.model, new_id, msg['Message-Id'], msg_subject, msg_to, msg_from, message['body'], att_ids)
except Exception, e:
if getattr(e, 'faultCode', '') and 'AccessError' in e.faultCode:
e = '\n\nThe Specified user does not have an access to the Model.'