summaryrefslogtreecommitdiff
path: root/addons/project_mailgate
diff options
context:
space:
mode:
Diffstat (limited to 'addons/project_mailgate')
-rw-r--r--addons/project_mailgate/project_mailgate.py66
-rw-r--r--addons/project_mailgate/project_mailgate_view.xml9
2 files changed, 13 insertions, 62 deletions
diff --git a/addons/project_mailgate/project_mailgate.py b/addons/project_mailgate/project_mailgate.py
index 808eede3b3c..7e794c7f75b 100644
--- a/addons/project_mailgate/project_mailgate.py
+++ b/addons/project_mailgate/project_mailgate.py
@@ -33,20 +33,11 @@ class project_tasks(osv.osv):
'message_ids': fields.one2many('mail.message', 'res_id', 'Messages', domain=[('model','=',_name)], readonly=True),
}
- def message_new(self, cr, uid, msg, context=None):
-# """
-# Automatically calls when new email message arrives
-#
-# @param self: The object pointer
-# @param cr: the current row, from the database cursor,
-# @param uid: the current user’s ID for security checks
-# """
- thread_obj = self.pool.get('email.thread')
+ def message_new(self, cr, uid, msg, custom_values=None, context=None):
+ thread_obj = self.pool.get('mail.thread')
subject = msg.get('subject')
- body = msg.get('body')
+ body = msg.get('body_text')
msg_from = msg.get('from')
- #TODO map email priority with openerp task priority
- priority = msg.get('priority')
data = {
'name': subject,
@@ -56,34 +47,11 @@ class project_tasks(osv.osv):
res = thread_obj.get_partner(cr, uid, msg_from)
if res:
data.update(res)
- res_id = self.create(cr, uid, data, context)
- attachments = msg.get('attachments', {})
- for attachment in attachments:
- data_attach = {
- 'name': attachment,
- 'datas': binascii.b2a_base64(str(attachments.get(attachment))),
- 'datas_fname': attachment,
- 'description': 'Mail attachment',
- 'res_model': self._name,
- 'res_id': res,
- }
- self.pool.get('ir.attachment').create(cr, uid, data_attach, context)
- self.history(cr, uid, [res_id], _('receive'), history=True,
- subject = msg.get('subject'),
- email = msg.get('to'),
- details = msg.get('body'),
- email_from = msg.get('from'),
- email_cc = msg.get('cc'),
- message_id = msg.get('message-id'),
- references = msg.get('references', False) or msg.get('in-reply-to', False),
- attach = attachments,
- email_date = msg.get('date'),
- body_html= msg.get('body_html'),
- sub_type = msg.get('sub_type'),
- headers = msg.get('headers'),
- priority = msg.get('priority'),
- context = context)
+ if custom_values and isinstance(custom_values, dict):
+ data.update(custom_values)
+ res_id = self.create(cr, uid, data, context)
+ self.append_mail(cr, uid, [res_id], msg, context=context)
return res_id
def message_update(self, cr, uid, ids, msg, data={}, default_act='pending'):
@@ -95,7 +63,7 @@ class project_tasks(osv.osv):
maps = {
'cost':'planned_hours',
}
- for line in msg['body'].split('\n'):
+ for line in msg['body_text'].split('\n'):
line = line.strip()
res = tools.misc.command_re.match(line)
if res:
@@ -112,23 +80,7 @@ class project_tasks(osv.osv):
self.write(cr, uid, ids, data, context=context)
getattr(self,act)(cr, uid, ids, context=context)
-
- attachments = msg.get('attachments', {})
- self.history(cr, uid, ids, _('receive'), history=True,
- subject = msg.get('subject'),
- email = msg.get('to'),
- details = msg.get('body'),
- email_from = msg.get('from'),
- email_cc = msg.get('cc'),
- message_id = msg.get('message-id'),
- references = msg.get('references', False) or msg.get('in-reply-to', False),
- attach = attachments,
- email_date = msg.get('date'),
- body_html= msg.get('body_html'),
- sub_type = msg.get('sub_type'),
- headers = msg.get('headers'),
- priority = msg.get('priority'),
- context = context)
+ self.append_mail(cr, uid, [res_id], msg, context=context)
return True
def thread_followers(self, cr, uid, ids, context=None):
diff --git a/addons/project_mailgate/project_mailgate_view.xml b/addons/project_mailgate/project_mailgate_view.xml
index 8c8816ebbd5..f2c8c7006e3 100644
--- a/addons/project_mailgate/project_mailgate_view.xml
+++ b/addons/project_mailgate/project_mailgate_view.xml
@@ -19,15 +19,14 @@
<field name="date"/>
<field name="email_to" widget="char" size="512"/>
<field name="email_cc" widget="char" size="512"/>
- <field name="name" colspan="4" widget="char" size="512"/>
- <field name="history" invisible="1"/>
+ <field name="subject" colspan="4" widget="char" size="512"/>
</group>
<notebook colspan="4">
<page string="Details">
- <group attrs="{'invisible': [('history', '!=', True)]}">
- <field name="description" colspan="4" nolabel="1" height="250"/>
+ <group attrs="{'invisible': [('email_from', '=', False)]}">
+ <field name="body_text" colspan="4" nolabel="1" height="250"/>
</group>
- <group attrs="{'invisible': [('history', '=', True)]}">
+ <group attrs="{'invisible': [('email_from', '!=', False)]}">
<field name="display_text" colspan="4" nolabel="1" height="250"/>
</group>
</page>