From 99bac0b9be878df5ccdb9c1118f4cb2245b35be7 Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Thu, 14 Apr 2011 18:49:38 +0530 Subject: [PATCH] [REM] email_template: remove email_template_send wizard and IMP bzr revid: rha@tinyerp.com-20110414131938-5y133uyx5j7hl5v0 --- addons/email_template/__openerp__.py | 1 - addons/email_template/wizard/__init__.py | 1 - .../wizard/email_compose_message.py | 10 +- .../wizard/email_template_preview.py | 3 +- .../wizard/email_template_send_wizard.py | 166 ------------------ .../email_template_send_wizard_view.xml | 62 ------- 6 files changed, 6 insertions(+), 237 deletions(-) delete mode 100644 addons/email_template/wizard/email_template_send_wizard.py delete mode 100644 addons/email_template/wizard/email_template_send_wizard_view.xml diff --git a/addons/email_template/__openerp__.py b/addons/email_template/__openerp__.py index ef2d314e561..eab9f8bc148 100644 --- a/addons/email_template/__openerp__.py +++ b/addons/email_template/__openerp__.py @@ -42,7 +42,6 @@ for leads, the action will be added to the right side panel of the Lead form. "update_xml": [ 'wizard/email_template_preview_view.xml', 'email_template_view.xml', - 'wizard/email_template_send_wizard_view.xml', 'wizard/email_compose_message_view.xml', 'security/ir.model.access.csv' ], diff --git a/addons/email_template/wizard/__init__.py b/addons/email_template/wizard/__init__.py index 1bac2d4aaad..b0ad4313b4f 100644 --- a/addons/email_template/wizard/__init__.py +++ b/addons/email_template/wizard/__init__.py @@ -20,6 +20,5 @@ # ############################################################################## import email_template_preview -import email_template_send_wizard import email_compose_message diff --git a/addons/email_template/wizard/email_compose_message.py b/addons/email_template/wizard/email_compose_message.py index fc357c88a6e..82381c838e3 100644 --- a/addons/email_template/wizard/email_compose_message.py +++ b/addons/email_template/wizard/email_compose_message.py @@ -44,12 +44,10 @@ class email_compose_message(osv.osv_memory): else: return self.get_template_value(cr, uid, getattr(template, field), template.model, resource_id, context=context) - body = _get_template_value('body') or False - if context.get('active_model') and resource_id and template.user_signature: - model_pool = self.pool.get(context['active_model']) - user = model_pool.browse(cr, uid, resource_id, context=context).user_id - signature = user and user.signature or '' - body = body + '\n' + signature + body = _get_template_value('body') + if template.user_signature: + signature = self.pool.get('res.users').browse(cr, uid, uid, context).signature + body += '\n' + signature result.update({ 'template_id' : template.id, diff --git a/addons/email_template/wizard/email_template_preview.py b/addons/email_template/wizard/email_template_preview.py index a1281831c4f..2538244ebea 100644 --- a/addons/email_template/wizard/email_template_preview.py +++ b/addons/email_template/wizard/email_template_preview.py @@ -46,8 +46,9 @@ class email_template_preview(osv.osv_memory): template = template_pool.browse(cr, uid, int(template_id), context=context) template_object = template.model_id model = self.pool.get(template_object.model) - record_ids = model.search(cr, uid, [], 0, 20, 'id', context=context) + record_ids = model.search(cr, uid, [], 0, 10, 'id', context=context) default_id = context.get('default_res_id') + if default_id and default_id not in record_ids: record_ids.insert(0, default_id) diff --git a/addons/email_template/wizard/email_template_send_wizard.py b/addons/email_template/wizard/email_template_send_wizard.py deleted file mode 100644 index b1c91401e55..00000000000 --- a/addons/email_template/wizard/email_template_send_wizard.py +++ /dev/null @@ -1,166 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################################## -# -# OpenERP, Open Source Management Solution -# Copyright (C) 2009 Sharoon Thomas -# Copyright (C) 2010-Today OpenERP SA () -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see -# -############################################################################## - -from osv import osv, fields -import netsvc -from tools.translate import _ - -class email_template_send_wizard(osv.osv_memory): - _name = 'email_template.send.wizard' - _inherit = 'email.template' - _description = 'This is the wizard for sending mail' - - def default_get(self, cr, uid, fields, context=None): - if context is None: - context = {} - result = super(email_template_send_wizard, self).default_get(cr, uid, fields, context=context) - - template_pool = self.pool.get('email.template') - model_pool = self.pool.get('ir.model') - template_id=context.get('template_id', False) - template = template_pool.get_email_template(cr, uid, template_id=template_id, context=context) - def _get_template_value(field): - if not template: - return False - if len(context['src_rec_ids']) > 1: # Multiple Mail: Gets original template values for multiple email change - return getattr(template, field) - else: # Simple Mail: Gets computed template values - return self.get_template_value(cr, uid, getattr(template, field), template.model, context.get('active_id'), context) - - if 'user_signature' in fields: - result['user_signature'] = template.user_signature - - if 'report_template' in fields: - result['report_template'] = template.report_template and template.report_template.id or False - - if 'template_id' in fields: - result['template_id'] = template.id - - if 'smtp_server_id' in fields: - result['smtp_server_id'] = template.smtp_server_id.id - - if 'attachment_ids' in fields: - result['attachment_ids'] = template_pool.read(cr, uid, template.id, ['attachment_ids'])['attachment_ids'] - - if 'requested' in fields: - result['requested'] = len(context.get('src_rec_ids','')) - - if 'state' in fields: - result['state'] = len(context.get('src_rec_ids','')) > 1 and 'multi' or 'single' - - if 'model_id' in fields: - result['model_id'] = model_pool.search(cr, uid, [('model','=',context.get('src_model'))],context=context)[0] - - if 'res_id' in fields: - result['res_id'] = context['active_id'] - - if 'email_to' in fields: - result['email_to'] = _get_template_value('email_to') - - if 'email_cc' in fields: - result['email_cc'] = _get_template_value('email_cc') - - if 'email_bcc' in fields: - result['email_bcc'] = _get_template_value('email_bcc') - - if 'subject' in fields: - result['subject'] = _get_template_value('subject') - - if 'body' in fields: - result['body'] = _get_template_value('description') - - #if 'body_html' in fields: - # result['body_html'] = _get_template_value('body_html') - - if 'reply_to' in fields: - result['reply_to'] = _get_template_value('reply_to') - - if 'report_name' in fields: - result['report_name'] = _get_template_value('report_name') - - return result - - _columns = { - 'requested':fields.integer('No of requested Mails',readonly=True), - 'generated':fields.integer('No of generated Mails',readonly=True), - 'full_success':fields.boolean('Complete Success',readonly=True), - 'attachment_ids': fields.many2many('ir.attachment','send_wizard_attachment_rel', 'wizard_id', 'attachment_id', 'Attachments'), - 'state':fields.selection([ - ('single','Simple Mail Wizard Step 1'), - ('multi','Multiple Mail Wizard Step 1'), - ('done','Wizard Complete') - ],'State',readonly=True), - } - - _defaults = { - } - - #def fields_get(self, cr, uid, fields=None, context=None, write_access=True): - # if context is None: - # context = {} - # result = super(email_template_send_wizard, self).fields_get(cr, uid, fields, context, write_access) - # if 'attachment_ids' in result and 'src_model' in context: - # result['attachment_ids']['domain'] = [('res_model','=',context['src_model']),('res_id','=',context['active_id'])] - # return result - - def send_mail(self, cr, uid, ids, context=None): - if context is None: - context = {} - mailid = self.save_to_mailbox(cr, uid, ids, context) - return {'type': 'ir.actions.act_window_close'} - - def get_generated(self, cr, uid, ids=None, context=None): - if ids is None: - ids = [] - if context is None: - context = {} - logger = netsvc.Logger() - if context.get('src_rec_ids'): - #Means there are multiple items selected for email. - mail_ids = self.save_to_mailbox(cr, uid, ids, context) - if mail_ids: - logger.notifyChannel("email-template", netsvc.LOG_INFO, _("Emails for multiple items saved in outbox.")) - self.write(cr, uid, ids, { - 'generated':len(mail_ids), - 'state':'done' - }, context) - else: - raise osv.except_osv(_("Email Template"),_("Email sending failed for one or more objects.")) - return True - - def save_to_mailbox(self, cr, uid, ids, context=None): - #def get_end_value(id, value): - # if len(context['src_rec_ids']) > 1: # Multiple Mail: Gets value from the template - # return self.get_value(cr, uid, template, value, context, id) - # else: - # return value - - email_ids = [] - for template in self.browse(cr, uid, ids, context=context): - for record_id in context.get('src_rec_ids',[]): - email_id = self.generate_email(cr, uid, template.id, record_id, context) - email_ids.append(email_id) - return email_ids - -email_template_send_wizard() - -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/email_template/wizard/email_template_send_wizard_view.xml b/addons/email_template/wizard/email_template_send_wizard_view.xml deleted file mode 100644 index f82288575bb..00000000000 --- a/addons/email_template/wizard/email_template_send_wizard_view.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - email_template.send.wizard.form - email_template.send.wizard - form - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -