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] [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'),