[IMP] email_template: added a minimal form view + some custo in mass mailing views
bzr revid: tde@openerp.com-20140324171017-mcv5m493zpba5tgd
This commit is contained in:
parent
3752e22481
commit
7945d4bb97
|
@ -78,6 +78,35 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="email_template_form_minimal">
|
||||
<field name="name">email.template.form.minimal</field>
|
||||
<field name="model">email.template</field>
|
||||
<field name="priority">32</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Templates" version="7.0">
|
||||
<sheet>
|
||||
<div class="oe_title">
|
||||
<label for="name"/><field name="name" required="1" class="oe_inline"/><br />
|
||||
<label for="model_id"/><field name="model_id" required="1" class="oe_inline"
|
||||
options="{'no_open': True, 'no_create': True}"
|
||||
on_change="onchange_model_id(model_id)"/>
|
||||
</div>
|
||||
<div class="oe_right oe_button_box" name="buttons">
|
||||
<button name="%(wizard_email_template_preview)d" string="Preview"
|
||||
type="action" target="new"
|
||||
context="{'template_id':active_id}"/>
|
||||
</div>
|
||||
<notebook>
|
||||
<page string="Body">
|
||||
<field name="body_html" nolabel="1"/>
|
||||
<field name="attachment_ids" widget="many2many_binary"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.ui.view" id="email_template_tree">
|
||||
<field name="name">email.template.tree</field>
|
||||
<field name="model">email.template</field>
|
||||
|
|
|
@ -14,8 +14,10 @@ class EmailTemplate(osv.Model):
|
|||
}
|
||||
|
||||
def action_new_mailing(self, cr, uid, ids, context=None):
|
||||
template = self.browse(cr, uid, ids[0], context=context)
|
||||
ctx = dict(context)
|
||||
ctx.update({
|
||||
'default_mailing_model': template.model,
|
||||
'default_template_id': ids[0],
|
||||
})
|
||||
return {
|
||||
|
@ -25,7 +27,5 @@ class EmailTemplate(osv.Model):
|
|||
'view_mode': 'form',
|
||||
'res_model': 'mail.mass_mailing',
|
||||
'views': [(False, 'form')],
|
||||
'view_id': False,
|
||||
# 'target': 'new',
|
||||
'context': ctx,
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import urllib
|
|||
import urlparse
|
||||
|
||||
from openerp import tools
|
||||
from openerp.exceptions import Warning
|
||||
from openerp.tools.safe_eval import safe_eval as eval
|
||||
from openerp.tools.translate import _
|
||||
from openerp.osv import osv, fields
|
||||
|
@ -442,7 +443,7 @@ class MassMailing(osv.Model):
|
|||
),
|
||||
'template_id': fields.many2one(
|
||||
'email.template', 'Email Template',
|
||||
domain=[('use_in_mass_mailing', '=', True)],
|
||||
domain="[('use_in_mass_mailing', '=', True), ('model', '=', mailing_model)]",
|
||||
required=True,
|
||||
),
|
||||
'body_html': fields.related(
|
||||
|
@ -625,6 +626,24 @@ class MassMailing(osv.Model):
|
|||
'context': context,
|
||||
}
|
||||
|
||||
def action_template_copy(self, cr, uid, ids, context=None):
|
||||
mailing = self.browse(cr, uid, ids[0], context=context)
|
||||
if not mailing.template_id:
|
||||
return False
|
||||
new_tpl_id = self.pool['email.template'].copy(cr, uid, mailing.template_id.id, context=context)
|
||||
self.write(cr, uid, [mailing.id], {'template_id': new_tpl_id}, context=context)
|
||||
view_id = self.pool['ir.model.data'].xmlid_to_res_id(cr, uid, 'email_template.email_template_form_minimal')
|
||||
return {
|
||||
'type': 'ir.actions.act_window',
|
||||
'view_type': 'form',
|
||||
'view_mode': 'form',
|
||||
'res_model': 'email.template',
|
||||
'res_id': new_tpl_id,
|
||||
'view_id': view_id,
|
||||
'target': 'new',
|
||||
'context': context,
|
||||
}
|
||||
|
||||
#------------------------------------------------------
|
||||
# Email Sending
|
||||
#------------------------------------------------------
|
||||
|
@ -700,6 +719,8 @@ class MassMailing(osv.Model):
|
|||
for mailing in self.browse(cr, uid, ids, context=context):
|
||||
# res_ids = self._set_up_test_mailing(cr, uid, mailing.mailing_model, context=context)
|
||||
res_ids = [c.id for c in mailing.email_to]
|
||||
if not res_ids:
|
||||
raise Warning('Please specifiy test email adresses.')
|
||||
all_mail_values = self.pool['mail.compose.message'].generate_email_for_composer_batch(
|
||||
cr, uid, mailing.template_id.id, res_ids,
|
||||
context=context,
|
||||
|
|
|
@ -3,17 +3,28 @@
|
|||
min-height: 270px !important;
|
||||
}
|
||||
|
||||
|
||||
.html_preview {
|
||||
.form_html_preview {
|
||||
width: 600px;
|
||||
height: 400px;
|
||||
max-height: 1000px;
|
||||
-webkit-transform: scale(.50);
|
||||
-ms-transform: scale(.50);
|
||||
transform: scale(.50);
|
||||
-webkit-transform-origin: 0 0;
|
||||
-ms-transform-origin: 0 0;
|
||||
transform-origin: 0 0;
|
||||
margin: 0 0px -300px 0;
|
||||
overflow: visible !important;
|
||||
}
|
||||
|
||||
.kanban_html_preview {
|
||||
width: 600px;
|
||||
height: 600px;
|
||||
-webkit-transform: scale(.50);
|
||||
-ms-transform: scale(.50);
|
||||
transform: scale(.50);
|
||||
-webkit-transform-origin: 0 0;
|
||||
-ms-transform-origin: 0 0;
|
||||
transform-origin: 0 0;
|
||||
border: 2px solid gray;
|
||||
margin: 0 0px -300px 0;
|
||||
overflow: hidden !important;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<data>
|
||||
|
||||
<!-- Email Templates -->
|
||||
<record id="view_marketing_settings_mass_mailing" model="ir.ui.view">
|
||||
<record id="email_template_form_mass_mailing" model="ir.ui.view">
|
||||
<field name="name">email.template.form.mass.mailing</field>
|
||||
<field name="model">email.template</field>
|
||||
<field name="inherit_id" ref="email_template.email_template_form"/>
|
||||
|
@ -14,6 +14,17 @@
|
|||
</field>
|
||||
</record>
|
||||
|
||||
<record id="email_template_form_minimal_mass_mailing" model="ir.ui.view">
|
||||
<field name="name">email.template.form.minimal.mass.mailing</field>
|
||||
<field name="model">email.template</field>
|
||||
<field name="inherit_id" ref="email_template.email_template_form_minimal"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='model_id']" position="after">
|
||||
<br /><label for="use_in_mass_mailing"/><field name="use_in_mass_mailing"/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="view_email_template_search_mass_mailing" model="ir.ui.view">
|
||||
<field name="name">email.template.search.mass.mailing</field>
|
||||
<field name="model">email.template</field>
|
||||
|
@ -54,7 +65,7 @@
|
|||
<h3>
|
||||
<field name="name"/>
|
||||
</h3>
|
||||
<div class="html_preview">
|
||||
<div class="kanban_html_preview">
|
||||
<t t-raw="record.body_html.raw_value"/>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -71,6 +82,7 @@
|
|||
<field name="res_model">email.template</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">kanban,tree,form</field>
|
||||
<field name="view_id" ref="email_template.email_template_form_minimal"/>
|
||||
<field name="context">{'search_default_use_in_mass_mailing': 1}</field>
|
||||
</record>
|
||||
|
||||
|
|
|
@ -243,9 +243,18 @@
|
|||
<label for="template_id"/>
|
||||
<div style="max-height: 200px; overflow: hidden !important;">
|
||||
<field name="template_id" string="Select Template" nolabel="1"
|
||||
options="{'no_create': True, 'no_open': True}"
|
||||
on_change="on_change_template_id(template_id, context)"/>
|
||||
<field name="body_html" class="html_preview" nolabel="1"
|
||||
<button string='Create a New Template' class='oe_inline oe_link oe_edit_only'
|
||||
type='object' name='action_template_new'
|
||||
attrs="{'invisible': [('template_id', '!=', False)]}"/>
|
||||
<button string='Copy and Edit Template' class='oe_inline oe_link oe_edit_only'
|
||||
type='object' name='action_template_copy'
|
||||
attrs="{'invisible': [('template_id', '=', False)]}"/>
|
||||
<div style="max-width: 300px !important;">
|
||||
<field name="body_html" class="form_html_preview" nolabel="1"
|
||||
attrs="{'invisible': [('template_id', '=', False)]}"/>
|
||||
</div>
|
||||
</div>
|
||||
<field name="email_from"/>
|
||||
<field name="reply_to"/>
|
||||
|
|
Loading…
Reference in New Issue