[REM] email_template: remove email_template_send wizard and IMP
bzr revid: rha@tinyerp.com-20110414131938-5y133uyx5j7hl5v0
This commit is contained in:
parent
0ad501441e
commit
99bac0b9be
|
@ -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'
|
||||
],
|
||||
|
|
|
@ -20,6 +20,5 @@
|
|||
#
|
||||
##############################################################################
|
||||
import email_template_preview
|
||||
import email_template_send_wizard
|
||||
import email_compose_message
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -1,166 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2009 Sharoon Thomas
|
||||
# Copyright (C) 2010-Today OpenERP SA (<http://www.openerp.com>)
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
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:
|
|
@ -1,62 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record model="ir.ui.view" id="email_template_send_wizard_form">
|
||||
<field name="name">email_template.send.wizard.form</field>
|
||||
<field name="model">email_template.send.wizard</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Send Email Wizard">
|
||||
<group col="4" colspan="4">
|
||||
<field name="smtp_server_id" widget="selection" required="1" colspan="4"/>
|
||||
</group>
|
||||
<group col="4" colspan="4">
|
||||
<group col="6" colspan="4">
|
||||
<field name="email_to" colspan="4"/>
|
||||
<field name="email_cc" colspan="4"/>
|
||||
<field name="email_bcc" colspan="4"/>
|
||||
<field name="subject" colspan="4" attrs="{'required':[('state','=','single')]}"/>
|
||||
<field name="report_name" colspan="4"/>
|
||||
<field name="user_signature" colspan="4"/>
|
||||
</group>
|
||||
<separator string="" colspan="4"/>
|
||||
<notebook colspan="4">
|
||||
<page string="Body">
|
||||
<field name="description" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
<!-- <page string="Body (HTML)">
|
||||
<field name="body_html" colspan="4" nolabel="1"/>
|
||||
</page> -->
|
||||
<page string="Attachments">
|
||||
<label string="Add here all attachments of the current document you want to include in the Email." colspan="4"/>
|
||||
<field name="attachment_ids" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
|
||||
</group>
|
||||
<field name="state" invisible="1"/>
|
||||
<group col="4" colspan="4" attrs="{'invisible':[('state','=','single')]}">
|
||||
<field name="requested"/>
|
||||
<field name="generated"/>
|
||||
<newline/>
|
||||
<label string="After clicking Send All, emails will be sent to outbox and cleared in next Send/Recieve" colspan="4"/>
|
||||
<label string="Tip: Multiple emails are sent in the same language (the first one is proposed). We suggest you send emails in groups according to language." colspan="4"/>
|
||||
<newline/>
|
||||
</group>
|
||||
<label string="" colspan="2"/>
|
||||
<group col="4" colspan="2" attrs="{'invisible':[('state','=','single')]}">
|
||||
<button icon="gtk-cancel" special="cancel" string="Discard" states="multi"/>
|
||||
<button icon="gtk-ok" name="get_generated" string="Send All" type="object" states="multi"/>
|
||||
<button icon="gtk-ok" special="cancel" string="Close" states="done"/>
|
||||
</group>
|
||||
<group col="4" colspan="2" attrs="{'invisible':[('state','!=','single')]}">
|
||||
<button icon="gtk-cancel" special="cancel" string="Discard"/>
|
||||
<button icon="gtk-ok" name="send_mail" string="Send now" type="object"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
Loading…
Reference in New Issue