[IMP] email_template: previw improvements :

- usability improveemnts on the sample document, more clear
- add partner_ids fields, displaying result of email template rendering that now also
generated partner_ids that will be recipient_ids on a mail_mail
- added attachment display

bzr revid: tde@openerp.com-20140327141241-2w2lxj5hkq8nqcu5
This commit is contained in:
Thibault Delavallée 2014-03-27 15:12:41 +01:00
parent 272a7e5f80
commit e65b472cb5
2 changed files with 10 additions and 5 deletions

View File

@ -66,6 +66,7 @@ class email_template_preview(osv.osv_memory):
_columns = {
'res_id': fields.selection(_get_records, 'Sample Document'),
'partner_ids': fields.many2many('res.partner', string='Recipients'),
}
def on_change_res_id(self, cr, uid, ids, res_id, context=None):
@ -80,7 +81,7 @@ class email_template_preview(osv.osv_memory):
# generate and get template values
mail_values = email_template.generate_email(cr, uid, template_id, res_id, context=context)
vals = dict((field, mail_values.get(field, False)) for field in ('email_from', 'email_to', 'email_cc', 'reply_to', 'subject', 'body_html', 'partner_to'))
vals = dict((field, mail_values.get(field, False)) for field in ('email_from', 'email_to', 'email_cc', 'reply_to', 'subject', 'body_html', 'partner_to', 'partner_ids', 'attachment_ids'))
vals['name'] = template.name
return {'value': vals}

View File

@ -8,14 +8,17 @@
<field name="arch" type="xml">
<form string="Email Preview" version="7.0">
<field name="model_id" invisible="1"/>
<h2 style="color: #7c7bad;">Preview of <field name="name" readonly="1" nolabel="1" class="oe_inline"/></h2>
Using sample document <field name="res_id" on_change="on_change_res_id(res_id, context)" class="oe_inline"/>
<h3>Preview of <field name="name" readonly="1" nolabel="1" class="oe_inline"/></h3>
Choose an example <field name="model_id" class="oe_inline" readonly="1"/> record:
<field name="res_id" on_change="on_change_res_id(res_id, context)" class="oe_inline"
style="margin-left: 8px;"/>
<group>
<field name="subject" readonly="1"/>
<field name="email_from" readonly="1"
attrs="{'invisible':[('email_from','=',False)]}"/>
<field name="email_to" readonly="1"/>
<field name="partner_to" readonly="1"/>
<field name="partner_ids" widget="many2many_tags" readonly="1"/>
<field name="email_to" readonly="1"
attrs="{'invisible':[('email_to','=',False)]}"/>
<field name="email_cc" readonly="1"
attrs="{'invisible':[('email_cc','=',False)]}"/>
<field name="reply_to" readonly="1"
@ -23,6 +26,7 @@
</group>
<field name="body_html" widget="html" readonly="1"
nolabel="1" options='{"safe": True}'/>
<field name="attachment_ids" widget="many2many_binary" radonly="1"/>
</form>
</field>
</record>