[IMP] email_template: cleaned wizard behavior (no more reloading, only value update); cleaned form view for chatter. Also cleaned form view for compose wizard (removed unnecessary colspan=4).
bzr revid: tde@openerp.com-20120717130718-w8c8dwv1ga9uhivs
This commit is contained in:
parent
dee27fa90a
commit
b92f0df86c
|
@ -34,12 +34,22 @@
|
|||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//field[@name='dest_partner_ids']" position="after">
|
||||
<field name="use_template" colspan="1" nolabel="1" invisible="1"/>
|
||||
<field name="template_id" colspan="4" nolabel="1"
|
||||
<field name="use_template" colspan="2" nolabel="1" invisible="1"
|
||||
on_change="onchange_use_template(use_template, context)"/>
|
||||
<field name="template_id" colspan="2" nolabel="1"
|
||||
attrs="{'invisible':[('use_template','=',False)]}"
|
||||
on_change="on_change_template(use_template, template_id, False, False, context)"/>
|
||||
</xpath>
|
||||
<xpath expr="//a[@class='oe_mail_compose_message_checklist']" position="before">
|
||||
<!--
|
||||
<a href="#" class="oe_mail_compose_message_template">
|
||||
<img src='/mail/static/src/img/template.png/' alt='Use template'
|
||||
title='Use a message template'/>
|
||||
</a>
|
||||
<a href="#" class="oe_mail_compose_message_template_save">
|
||||
<img src='/mail/static/src/img/template.png/' alt='Save as template'
|
||||
title='Use a message template'/>
|
||||
</a> -->
|
||||
<button icon="gtk-paste" type="object" name="template_toggle"
|
||||
string="" help="Use a message template" />
|
||||
<button icon="gtk-save" type="object" name="save_as_template"
|
||||
|
|
|
@ -114,20 +114,30 @@ class mail_compose_message(osv.osv_memory):
|
|||
|
||||
return {'value': values}
|
||||
|
||||
|
||||
def template_toggle(self, cr, uid, ids, context=None):
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
had_template = record.use_template
|
||||
print had_template
|
||||
record.write({'use_template': not(had_template)})
|
||||
if had_template:
|
||||
values = {}
|
||||
use_template = record.use_template
|
||||
print 'template_toggle: use_template: %d' % (use_template)
|
||||
# update use_template value
|
||||
|
||||
# simulate an on_change on use_template
|
||||
values.update(self.onchange_use_template(cr, uid, ids, not use_template, context=context)['value'])
|
||||
print 'template_toggle: values %s' % (str(values))
|
||||
record.write(values)
|
||||
|
||||
return False
|
||||
|
||||
def onchange_use_template(self, cr, uid, ids, use_template, context=None):
|
||||
values = {'use_template': use_template}
|
||||
for record in self.browse(cr, uid, ids, context=context):
|
||||
if not use_template:
|
||||
# equivalent to choosing an empty template
|
||||
onchange_defaults = self.on_change_template(cr, uid, record.id, not(had_template),
|
||||
False, email_from=record.email_from,
|
||||
email_to=record.email_to, context=context)
|
||||
print onchange_defaults
|
||||
record.write(onchange_defaults['value'])
|
||||
return _reopen(self, record.id, record.res_id, record.model)
|
||||
onchange_template_values = self.on_change_template(cr, uid, record.id, use_template,
|
||||
False, email_from=record.email_from, email_to=record.email_to, context=context)
|
||||
values.update(onchange_template_values['value'])
|
||||
print 'onchange_use_template: values %s' % (str(values))
|
||||
return {'value': values}
|
||||
|
||||
def save_as_template(self, cr, uid, ids, context=None):
|
||||
if context is None:
|
||||
|
|
|
@ -44,14 +44,14 @@
|
|||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Compose Email" version="7.0" >
|
||||
<group col="4">
|
||||
<field name="subject" colspan="4" nolabel="1" placeholder="Subject..."
|
||||
<group>
|
||||
<field name="subject" colspan="2" nolabel="1" placeholder="Subject..."
|
||||
class="oe_mail_compose_message_subject oe_mail_compose_message_invisible"/>
|
||||
<field name="body_text" colspan="4" nolabel="1" placeholder="What are you working on ?"
|
||||
<field name="body_text" colspan="2" nolabel="1" placeholder="What are you working on ?"
|
||||
class="oe_mail_compose_message_body_text"/>
|
||||
<field name="body_html" colspan="4" nolabel="1" placeholder="What are you working on HTML ?"
|
||||
<field name="body_html" colspan="2" nolabel="1" placeholder="What are you working on HTML ?"
|
||||
class="oe_mail_compose_message_body_html oe_mail_compose_message_invisible" widget="text_html"/>
|
||||
<field name="dest_partner_ids" colspan="4" nolabel="1" widget="many2many_tags"
|
||||
<field name="dest_partner_ids" colspan="2" nolabel="1" widget="many2many_tags"
|
||||
placeholder="Add contacts to notify..."
|
||||
class="oe_mail_compose_message_partner_ids oe_mail_compose_message_invisible"/>
|
||||
<div>
|
||||
|
|
Loading…
Reference in New Issue