From f376b23ae644d72fdb36194b1ed7e2667f7d9697 Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Tue, 19 Apr 2011 15:37:22 +0530 Subject: [PATCH 1/4] [FIX] mail: solved context in schedule_with_attach() bzr revid: rha@tinyerp.com-20110419100722-cijh152wl0urg75t --- addons/mail/email_message.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/mail/email_message.py b/addons/mail/email_message.py index a32c29ff759..39d5d8f9a8f 100644 --- a/addons/mail/email_message.py +++ b/addons/mail/email_message.py @@ -206,6 +206,8 @@ class email_message(osv.osv): def schedule_with_attach(self, cr, uid, email_from, email_to, subject, body, model=False, email_cc=None, email_bcc=None, reply_to=False, attach=None, message_id=False, references=False, openobject_id=False, debug=False, subtype='plain', x_headers={}, priority='3', smtp_server_id=False, context=None, auto_delete=False): + if context is None: + context = {} attachment_obj = self.pool.get('ir.attachment') if email_to and type(email_to) != list: email_to = [email_to] From 7ed0659f6e25f387f041f4d6f91cfb76459462cf Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Wed, 20 Apr 2011 11:36:05 +0530 Subject: [PATCH 2/4] [IMP] mail: improvement for message_new() and related modules bzr revid: rha@tinyerp.com-20110420060605-7q1z5917g1b7wapw --- addons/crm/crm_lead.py | 17 +++++++- addons/crm_claim/crm_claim.py | 17 +++++++- addons/crm_helpdesk/crm_helpdesk.py | 17 +++++++- addons/hr_recruitment/hr_recruitment.py | 17 +++++++- addons/mail/email_thread.py | 43 ++++++++++----------- addons/project_issue/project_issue.py | 20 ++++++++-- addons/project_mailgate/project_mailgate.py | 17 +++++++- 7 files changed, 117 insertions(+), 31 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index e796cf7e654..c9104421866 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -348,7 +348,22 @@ class crm_lead(crm_case, osv.osv): if res: vals.update(res) - return self.create(cr, uid, vals, context) + res_id = self.create(cr, uid, vals, context) + + attachments = msg.get('attachments', []) + 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'), + context = context) + + return res_id def message_update(self, cr, uid, ids, msg, vals={}, default_act='pending', context=None): """ diff --git a/addons/crm_claim/crm_claim.py b/addons/crm_claim/crm_claim.py index f5cceb59498..9a2ff90acc0 100644 --- a/addons/crm_claim/crm_claim.py +++ b/addons/crm_claim/crm_claim.py @@ -202,7 +202,22 @@ class crm_claim(crm.crm_case, osv.osv): if res: vals.update(res) - return self.create(cr, uid, vals, context) + res_id = self.create(cr, uid, vals, context) + + attachments = msg.get('attachments', []) + 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'), + context = context) + + return res_id def message_update(self, cr, uid, ids, msg, vals={}, default_act='pending', context=None): """ diff --git a/addons/crm_helpdesk/crm_helpdesk.py b/addons/crm_helpdesk/crm_helpdesk.py index ff503a8fb3e..03d16306df7 100644 --- a/addons/crm_helpdesk/crm_helpdesk.py +++ b/addons/crm_helpdesk/crm_helpdesk.py @@ -126,7 +126,22 @@ class crm_helpdesk(crm.crm_case, osv.osv): if res: vals.update(res) - return self.create(cr, uid, vals, context) + res_id = self.create(cr, uid, vals, context) + + attachments = msg.get('attachments', []) + 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'), + context = context) + + return res_id def message_update(self, cr, uid, ids, msg, vals={}, default_act='pending', context=None): """ diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 24b226f922e..f129934e8c0 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -327,7 +327,22 @@ class hr_applicant(crm.crm_case, osv.osv): res = thread_pool.get_partner(cr, uid, msg.get('from')) if res: vals.update(res) - return self.create(cr, uid, vals, context=context) + res_id = self.create(cr, uid, vals, context) + + attachments = msg.get('attachments', []) + 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'), + context = context) + + return res_id def message_update(self, cr, uid, ids, msg, vals={}, default_act='pending', context=None): """ diff --git a/addons/mail/email_thread.py b/addons/mail/email_thread.py index 78d5b18886f..f1ef3858fed 100644 --- a/addons/mail/email_thread.py +++ b/addons/mail/email_thread.py @@ -75,14 +75,11 @@ class email_thread(osv.osv): if not model: model = self._name model_pool = self.pool.get(model) - if hasattr(model_pool, 'message_new'): - res_id = model_pool.message_new(cr, uid, msg, context) - else: - fields = model_pool.fields_get(cr, uid, context=context) - data = model_pool.default_get(cr, uid, fields, context=context) - if 'name' in fields and not data.get('name',False): - data['name'] = msg.get('from','') - res_id = model_pool.create(cr, uid, data, context=context) + fields = model_pool.fields_get(cr, uid, context=context) + data = model_pool.default_get(cr, uid, fields, context=context) + if 'name' in fields and not data.get('name',False): + data['name'] = msg.get('from','') + res_id = model_pool.create(cr, uid, data, context=context) attachments = msg.get('attachments', {}) self.history(cr, uid, [res_id], _('receive'), history=True, @@ -109,8 +106,6 @@ class email_thread(osv.osv): if not model: model = self._name model_pool = self.pool.get(model) - if hasattr(model_pool, 'message_update'): - model_pool.message_update(cr, uid, ids, msg, vals=vals, default_act=default_act, context=context) attachments = msg.get('attachments', {}) self.history(cr, uid, ids, _('receive'), history=True, subject = msg.get('subject'), @@ -183,16 +178,17 @@ class email_thread(osv.osv): for thread in threads: attachments = [] - for attachment in attach: - data_attach = { - 'name': attachment[0], - 'datas': binascii.b2a_base64(str(attachment[1])), - 'datas_fname': attachment[0], - 'description': _('Mail attachment'), - 'res_model': thread._name, - 'res_id': thread.id, - } - attachments.append(att_obj.create(cr, uid, data_attach)) + if attach: + for fname, fcontent in attach.items(): + data_attach = { + 'name': fname, + 'datas': binascii.b2a_base64(str(fcontent)), + 'datas_fname': fname, + 'description': _('Mail attachment'), + 'res_model': thread._name, + 'res_id': thread.id, + } + attachments.append(att_obj.create(cr, uid, data_attach)) partner_id = hasattr(thread, 'partner_id') and (thread.partner_id and thread.partner_id.id or False) or False if not partner_id and thread._name == 'res.partner': @@ -305,7 +301,6 @@ class email_thread(osv.osv): email_message_pool = self.pool.get('email.message') res_id = False - # Parse Message # Warning: message_from_string doesn't always work correctly on unicode, # we must use utf-8 strings here :-( @@ -316,7 +311,8 @@ class email_thread(osv.osv): # Create New Record into particular model def create_record(msg): - new_res_id = self.message_new(cr, uid, msg, context=context) + if hasattr(model_pool, 'message_new'): + new_res_id = model_pool.message_new(cr, uid, msg, context=context) if custom_values: model_pool.write(cr, uid, [res_id], custom_values, context=context) return new_res_id @@ -340,7 +336,8 @@ class email_thread(osv.osv): if res_id: res_id = int(res_id) if model_pool.exists(cr, uid, res_id): - self.message_update(cr, uid, [res_id], msg, {}, context=context) + if hasattr(model_pool, 'message_new'): + model_pool.message_update(cr, uid, [res_id], msg, {}, context=context) if not res_id: res_id = create_record(msg) diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 11e76f142a1..7d58bd77d36 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -395,9 +395,23 @@ class project_issue(crm.crm_case, osv.osv): if res: vals.update(res) context.update({'state_to' : 'draft'}) - res = self.create(cr, uid, vals, context=context) - self.convert_to_bug(cr, uid, [res], context=context) - return res + + res_id = self.create(cr, uid, vals, context) + + attachments = msg.get('attachments', []) + 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'), + context = context) + self.convert_to_bug(cr, uid, [res_id], context=context) + return res_id def message_update(self, cr, uid, ids, msg, vals=None, default_act='pending', context=None): """ diff --git a/addons/project_mailgate/project_mailgate.py b/addons/project_mailgate/project_mailgate.py index 29c813b5d8a..212fe161094 100644 --- a/addons/project_mailgate/project_mailgate.py +++ b/addons/project_mailgate/project_mailgate.py @@ -52,7 +52,22 @@ class project_tasks(osv.osv): res = thread_obj.get_partner(cr, uid, msg_from) if res: data.update(res) - return self.create(cr, uid, data) + res_id = self.create(cr, uid, vals, context) + + attachments = msg.get('attachments', []) + 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'), + context = context) + + return res_id def message_update(self, cr, uid, id, msg, data={}, default_act='pending'): thread_obj = self.pool.get('email.thread') From 280e446ceffeae725249a2687db203e9f97d8abe Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Wed, 20 Apr 2011 11:56:46 +0530 Subject: [PATCH 3/4] [FIX]: attachment type as dictionary bzr revid: rha@tinyerp.com-20110420062646-ngijwvt2395cihuw --- addons/crm/crm_lead.py | 2 +- addons/crm_claim/crm_claim.py | 2 +- addons/crm_helpdesk/crm_helpdesk.py | 2 +- addons/hr_recruitment/hr_recruitment.py | 2 +- addons/mail/email_thread.py | 27 ++++++++++----------- addons/project_issue/project_issue.py | 2 +- addons/project_mailgate/project_mailgate.py | 2 +- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index c9104421866..86930613212 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -350,7 +350,7 @@ class crm_lead(crm_case, osv.osv): res_id = self.create(cr, uid, vals, context) - attachments = msg.get('attachments', []) + attachments = msg.get('attachments', {}) self.history(cr, uid, [res_id], _('receive'), history=True, subject = msg.get('subject'), email = msg.get('to'), diff --git a/addons/crm_claim/crm_claim.py b/addons/crm_claim/crm_claim.py index 9a2ff90acc0..5ad78c53465 100644 --- a/addons/crm_claim/crm_claim.py +++ b/addons/crm_claim/crm_claim.py @@ -204,7 +204,7 @@ class crm_claim(crm.crm_case, osv.osv): res_id = self.create(cr, uid, vals, context) - attachments = msg.get('attachments', []) + attachments = msg.get('attachments', {}) self.history(cr, uid, [res_id], _('receive'), history=True, subject = msg.get('subject'), email = msg.get('to'), diff --git a/addons/crm_helpdesk/crm_helpdesk.py b/addons/crm_helpdesk/crm_helpdesk.py index 03d16306df7..c983acf78b3 100644 --- a/addons/crm_helpdesk/crm_helpdesk.py +++ b/addons/crm_helpdesk/crm_helpdesk.py @@ -128,7 +128,7 @@ class crm_helpdesk(crm.crm_case, osv.osv): res_id = self.create(cr, uid, vals, context) - attachments = msg.get('attachments', []) + attachments = msg.get('attachments', {}) self.history(cr, uid, [res_id], _('receive'), history=True, subject = msg.get('subject'), email = msg.get('to'), diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index f129934e8c0..3931d053666 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -329,7 +329,7 @@ class hr_applicant(crm.crm_case, osv.osv): vals.update(res) res_id = self.create(cr, uid, vals, context) - attachments = msg.get('attachments', []) + attachments = msg.get('attachments', {}) self.history(cr, uid, [res_id], _('receive'), history=True, subject = msg.get('subject'), email = msg.get('to'), diff --git a/addons/mail/email_thread.py b/addons/mail/email_thread.py index f1ef3858fed..87cd459608b 100644 --- a/addons/mail/email_thread.py +++ b/addons/mail/email_thread.py @@ -156,7 +156,7 @@ class email_thread(osv.osv): if context is None: context = {} if attach is None: - attach = [] + attach = {} model = context.get('thread_model', False) if not model: @@ -178,17 +178,16 @@ class email_thread(osv.osv): for thread in threads: attachments = [] - if attach: - for fname, fcontent in attach.items(): - data_attach = { - 'name': fname, - 'datas': binascii.b2a_base64(str(fcontent)), - 'datas_fname': fname, - 'description': _('Mail attachment'), - 'res_model': thread._name, - 'res_id': thread.id, - } - attachments.append(att_obj.create(cr, uid, data_attach)) + for fname, fcontent in attach.items(): + data_attach = { + 'name': fname, + 'datas': binascii.b2a_base64(str(fcontent)), + 'datas_fname': fname, + 'description': _('Mail attachment'), + 'res_model': thread._name, + 'res_id': thread.id, + } + attachments.append(att_obj.create(cr, uid, data_attach)) partner_id = hasattr(thread, 'partner_id') and (thread.partner_id and thread.partner_id.id or False) or False if not partner_id and thread._name == 'res.partner': @@ -313,8 +312,8 @@ class email_thread(osv.osv): def create_record(msg): if hasattr(model_pool, 'message_new'): new_res_id = model_pool.message_new(cr, uid, msg, context=context) - if custom_values: - model_pool.write(cr, uid, [res_id], custom_values, context=context) + if custom_values: + model_pool.write(cr, uid, [new_res_id], custom_values, context=context) return new_res_id res_id = False diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index 7d58bd77d36..c8b55067fc5 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -398,7 +398,7 @@ class project_issue(crm.crm_case, osv.osv): res_id = self.create(cr, uid, vals, context) - attachments = msg.get('attachments', []) + attachments = msg.get('attachments', {}) self.history(cr, uid, [res_id], _('receive'), history=True, subject = msg.get('subject'), email = msg.get('to'), diff --git a/addons/project_mailgate/project_mailgate.py b/addons/project_mailgate/project_mailgate.py index 212fe161094..7610f35d648 100644 --- a/addons/project_mailgate/project_mailgate.py +++ b/addons/project_mailgate/project_mailgate.py @@ -54,7 +54,7 @@ class project_tasks(osv.osv): data.update(res) res_id = self.create(cr, uid, vals, context) - attachments = msg.get('attachments', []) + attachments = msg.get('attachments', {}) self.history(cr, uid, [res_id], _('receive'), history=True, subject = msg.get('subject'), email = msg.get('to'), From 190148f759d9134a2ecae103342cdba19cec5dec Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Wed, 20 Apr 2011 13:41:41 +0530 Subject: [PATCH 4/4] [FIX]: changes in message_update() bzr revid: rha@tinyerp.com-20110420081141-4w1wi70e290m2a69 --- addons/crm/crm_lead.py | 13 +++++++++++++ addons/crm_claim/crm_claim.py | 13 +++++++++++++ addons/crm_helpdesk/crm_helpdesk.py | 13 +++++++++++++ addons/hr_recruitment/hr_recruitment.py | 13 +++++++++++++ addons/mail/email_thread.py | 4 ++-- addons/project_issue/project_issue.py | 13 +++++++++++++ addons/project_mailgate/project_mailgate.py | 19 ++++++++++++++++--- 7 files changed, 83 insertions(+), 5 deletions(-) diff --git a/addons/crm/crm_lead.py b/addons/crm/crm_lead.py index 86930613212..ea59a66238b 100644 --- a/addons/crm/crm_lead.py +++ b/addons/crm/crm_lead.py @@ -400,6 +400,19 @@ class crm_lead(crm_case, osv.osv): if case.state in CRM_LEAD_PENDING_STATES: values.update(state=crm.AVAILABLE_STATES[1][0]) #re-open res = self.write(cr, uid, [case.id], values, 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'), + context = context) return res def on_change_optin(self, cr, uid, ids, optin): diff --git a/addons/crm_claim/crm_claim.py b/addons/crm_claim/crm_claim.py index 5ad78c53465..04836a2ed79 100644 --- a/addons/crm_claim/crm_claim.py +++ b/addons/crm_claim/crm_claim.py @@ -254,6 +254,19 @@ class crm_claim(crm.crm_case, osv.osv): if case.state in CRM_CLAIM_PENDING_STATES: values.update(state=crm.AVAILABLE_STATES[1][0]) #re-open res = self.write(cr, uid, [case.id], values, 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'), + context = context) return res crm_claim() diff --git a/addons/crm_helpdesk/crm_helpdesk.py b/addons/crm_helpdesk/crm_helpdesk.py index c983acf78b3..9bfde3f189c 100644 --- a/addons/crm_helpdesk/crm_helpdesk.py +++ b/addons/crm_helpdesk/crm_helpdesk.py @@ -178,6 +178,19 @@ class crm_helpdesk(crm.crm_case, osv.osv): if case.state in CRM_HELPDESK_STATES: values.update(state=crm.AVAILABLE_STATES[1][0]) #re-open res = self.write(cr, uid, [case.id], values, 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'), + context = context) return res crm_helpdesk() diff --git a/addons/hr_recruitment/hr_recruitment.py b/addons/hr_recruitment/hr_recruitment.py index 3931d053666..4951b7e21fa 100644 --- a/addons/hr_recruitment/hr_recruitment.py +++ b/addons/hr_recruitment/hr_recruitment.py @@ -377,6 +377,19 @@ class hr_applicant(crm.crm_case, osv.osv): vals.update(vls) res = self.write(cr, uid, ids, vals, 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'), + context = context) return res def case_open(self, cr, uid, ids, *args): diff --git a/addons/mail/email_thread.py b/addons/mail/email_thread.py index 87cd459608b..796fc35bb92 100644 --- a/addons/mail/email_thread.py +++ b/addons/mail/email_thread.py @@ -90,7 +90,7 @@ class email_thread(osv.osv): 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.items(), + attach = attachments, email_date = msg.get('date'), context = context) return res_id @@ -115,7 +115,7 @@ class email_thread(osv.osv): 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.items(), + attach = attachments, email_date = msg.get('date'), context = context) return True diff --git a/addons/project_issue/project_issue.py b/addons/project_issue/project_issue.py index c8b55067fc5..e9e5521d94b 100644 --- a/addons/project_issue/project_issue.py +++ b/addons/project_issue/project_issue.py @@ -454,6 +454,19 @@ class project_issue(crm.crm_case, osv.osv): vals.update(vls) res = self.write(cr, uid, ids, vals) + + 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'), + context = context) return res def copy(self, cr, uid, id, default=None, context=None): diff --git a/addons/project_mailgate/project_mailgate.py b/addons/project_mailgate/project_mailgate.py index 7610f35d648..dc0f04aeddf 100644 --- a/addons/project_mailgate/project_mailgate.py +++ b/addons/project_mailgate/project_mailgate.py @@ -69,7 +69,7 @@ class project_tasks(osv.osv): return res_id - def message_update(self, cr, uid, id, msg, data={}, default_act='pending'): + def message_update(self, cr, uid, ids, msg, data={}, default_act='pending'): thread_obj = self.pool.get('email.thread') msg_actions, body_data = thread_obj.msg_act_get(msg) data.update({ @@ -90,8 +90,21 @@ class project_tasks(osv.osv): if msg_actions['priority'] in ('1','2','3','4','5'): data['priority'] = msg_actions['priority'] - self.write(cr, uid, [id], data) - getattr(self,act)(cr, uid, [id]) + self.write(cr, uid, ids, data) + getattr(self,act)(cr, uid, ids) + + 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'), + context = context) return True def thread_followers(self, cr, uid, ids, context=None):