From 79f7a3e7fd77dfce87cacca37fd529819ce62f4e Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Wed, 16 Feb 2011 11:26:00 +0530 Subject: [PATCH 01/27] [IMP]email_template:- also check template has no smtp_server_id then it take default smtp_server. bzr revid: ysa@tinyerp.com-20110216055600-z8avrlljeatr3kp7 --- addons/email_template/email_template.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py index e75b3cf9325..78cacbb7586 100644 --- a/addons/email_template/email_template.py +++ b/addons/email_template/email_template.py @@ -30,6 +30,7 @@ import re from tools.translate import _ import tools import pooler +import types class email_template(osv.osv): "Templates for sending Email" @@ -371,8 +372,11 @@ This is useful for CRM leads for example"), report_xml_pool = self.pool.get('ir.actions.report.xml') template = self.get_email_template(cr, uid, template_id, record_id, context) smtp_server_id = context.get('smtp_server_id', False) - if not smtp_server_id: + if not smtp_server_id and template.smtp_server_id: smtp_server_id = template.smtp_server_id.id + else: + smtp_ids = smtp_pool.search(cr, uid, [('default','=',True)]) + smtp_server_id = smtp_ids and smtp_ids[0] smtp_server = smtp_pool.browse(cr, uid, smtp_server_id, context=context) # determine name of sender, either it is specified in email_id @@ -481,6 +485,8 @@ class email_message(osv.osv): context = {} notemplate = context.get('notemplate', False) if (not notemplate) and model and openobject_id: + if type(openobject_id) != list: + openobject_id = [openobject_id] template_pool = self.pool.get('email.template') template_ids = template_pool.search(cr, uid, [('model','=',model)]) if template_ids and len(template_ids): From a084e73585c87dda1d42102447b744f19f9c9522 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Wed, 16 Feb 2011 13:03:12 +0530 Subject: [PATCH 02/27] [IMP] email_template :- openobject_id pass as a int in generate_email method. bzr revid: ysa@tinyerp.com-20110216073312-6m133fmnzgf61v71 --- addons/email_template/email_template.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py index 78cacbb7586..5a746b8608b 100644 --- a/addons/email_template/email_template.py +++ b/addons/email_template/email_template.py @@ -30,7 +30,6 @@ import re from tools.translate import _ import tools import pooler -import types class email_template(osv.osv): "Templates for sending Email" @@ -452,14 +451,13 @@ This is useful for CRM leads for example"), - def generate_email(self, cr, uid, ids, record_ids, context=None): + def generate_email(self, cr, uid, ids, record_id, context=None): if context is None: context = {} email_ids = [] for template in self.browse(cr, uid, ids, context=context): - for record_id in record_ids: - email_id = self._generate_email(cr, uid, template.id, record_id, context) - email_ids.append(email_id) + email_id = self._generate_email(cr, uid, template.id, record_id, context) + email_ids.append(email_id) return email_ids email_template() @@ -485,8 +483,6 @@ class email_message(osv.osv): context = {} notemplate = context.get('notemplate', False) if (not notemplate) and model and openobject_id: - if type(openobject_id) != list: - openobject_id = [openobject_id] template_pool = self.pool.get('email.template') template_ids = template_pool.search(cr, uid, [('model','=',model)]) if template_ids and len(template_ids): From 99c4933b50cdc107bf66748d3d20d1e78a197b94 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Thu, 17 Feb 2011 16:28:44 +0530 Subject: [PATCH 03/27] [ADD] emails :- add email.message send wizard. bzr revid: ysa@tinyerp.com-20110217105844-sj5o5y1qmszp6mtw --- addons/email_template/email_template.py | 16 ++++++++-------- addons/emails/__init__.py | 1 + addons/emails/__openerp__.py | 2 +- addons/emails/email_message.py | 2 +- addons/emails/email_view.xml | 3 ++- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/addons/email_template/email_template.py b/addons/email_template/email_template.py index 5a746b8608b..59025fa5162 100644 --- a/addons/email_template/email_template.py +++ b/addons/email_template/email_template.py @@ -451,14 +451,12 @@ This is useful for CRM leads for example"), - def generate_email(self, cr, uid, ids, record_id, context=None): + def generate_email(self, cr, uid, template_id, record_id, context=None): if context is None: context = {} - email_ids = [] - for template in self.browse(cr, uid, ids, context=context): - email_id = self._generate_email(cr, uid, template.id, record_id, context) - email_ids.append(email_id) - return email_ids + email_id = self._generate_email(cr, uid, template_id, record_id, context) + return email_id + email_template() class email_message(osv.osv): @@ -481,15 +479,17 @@ class email_message(osv.osv): message_id=False, openobject_id=False, debug=False, subtype='plain', x_headers={}, priority='3', smtp_server_id=False, context=None): if context is None: context = {} - notemplate = context.get('notemplate', False) + notemplate = context.get('notemplate', True) if (not notemplate) and model and openobject_id: template_pool = self.pool.get('email.template') template_ids = template_pool.search(cr, uid, [('model','=',model)]) if template_ids and len(template_ids): template_id = template_ids[0] - return template_pool.generate_email(cr, uid, [template_id], openobject_id, context=context) + return template_pool.generate_email(cr, uid, template_id, openobject_id, context=context) + return super(email_message, self).email_send(cr, uid, email_from, email_to, subject, body, model=model, email_cc=email_cc, email_bcc=email_bcc, reply_to=reply_to, attach=attach, message_id=message_id, openobject_id=openobject_id, debug=debug, subtype=subtype, x_headers=x_headers, priority=priority, smtp_server_id=smtp_server_id, context=context) + email_message() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/emails/__init__.py b/addons/emails/__init__.py index 5e481d8e957..dd9a7e703d0 100644 --- a/addons/emails/__init__.py +++ b/addons/emails/__init__.py @@ -22,6 +22,7 @@ import email_smtp_server import email_message import res_partner +import wizard # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/emails/__openerp__.py b/addons/emails/__openerp__.py index 9e2c1ae2dd8..a3b6456921f 100644 --- a/addons/emails/__openerp__.py +++ b/addons/emails/__openerp__.py @@ -32,11 +32,11 @@ 'depends': ['base', 'base_tools'], 'init_xml': [], 'update_xml': [ + "wizard/email_message_wizard_send_view.xml", "email_view.xml", "res_partner_view.xml", 'security/ir.model.access.csv', 'email_data.xml', - ], 'demo_xml': [], 'installable': True, diff --git a/addons/emails/email_message.py b/addons/emails/email_message.py index 07572916fbf..ec2aa7ccca0 100644 --- a/addons/emails/email_message.py +++ b/addons/emails/email_message.py @@ -284,7 +284,7 @@ class email_message(osv.osv): for attachment in attach: attachment_data = { 'name': (subject or '') + _(' (Email Attachment)'), - 'datas': base64.b64encode(attachment[1]), + 'datas': attachment[1], 'datas_fname': attachment[0], 'description': subject or _('No Description'), 'res_model':'email.message', diff --git a/addons/emails/email_view.xml b/addons/emails/email_view.xml index 4a2da7fb106..929c96626e1 100644 --- a/addons/emails/email_view.xml +++ b/addons/emails/email_view.xml @@ -3,7 +3,7 @@ + id="base.menu_lunch_survey_root" sequence="20"/> email.message.form @@ -34,6 +34,7 @@