[PEP8] email_template_template
parent
a2b37d8d2e
commit
d82b1574f6
|
@ -60,7 +60,7 @@ Then in your template you write
|
||||||
::
|
::
|
||||||
|
|
||||||
Dear ${object.partner_id.name},
|
Dear ${object.partner_id.name},
|
||||||
|
|
||||||
Your order has been booked on date ${object.date} for a total amount of ${object.sum}.
|
Your order has been booked on date ${object.date} for a total amount of ${object.sum}.
|
||||||
|
|
||||||
And it will be evaluated to
|
And it will be evaluated to
|
||||||
|
@ -77,13 +77,18 @@ And it will be evaluated to
|
||||||
Example city
|
Example city
|
||||||
Example Corp footer
|
Example Corp footer
|
||||||
|
|
||||||
Given the way evaluation works internally (body_text of the template template is evaluated two times, first with the instance of email.template of your own template, then with the object your template refers to), you can do some trickery if you know that a template template is always used with the same kind of model (that is, models that have the same field name):
|
Given the way evaluation works internally (body_text of the template template
|
||||||
|
is evaluated two times, first with the instance of email.template of your own
|
||||||
|
template, then with the object your template refers to), you can do some
|
||||||
|
trickery if you know that a template template is always used with the same
|
||||||
|
kind of model (that is, models that have the same field name):
|
||||||
|
|
||||||
In your template template:
|
In your template template:
|
||||||
|
|
||||||
::
|
::
|
||||||
|
|
||||||
Dear ${'${object.name}'}, <-- gets evaluated to "${object.name}" in the first step, then to the content of object.name
|
Dear ${'${object.name}'}, <-- gets evaluated to "${object.name}" in the
|
||||||
|
first step, then to the content of object.name
|
||||||
${object.body_html}
|
${object.body_html}
|
||||||
Best,
|
Best,
|
||||||
Example Corp
|
Example Corp
|
||||||
|
|
|
@ -28,7 +28,7 @@ class email_template(Model):
|
||||||
|
|
||||||
def _get_is_template_template(self, cr, uid, ids, fields_name, arg,
|
def _get_is_template_template(self, cr, uid, ids, fields_name, arg,
|
||||||
context=None):
|
context=None):
|
||||||
cr.execute('''select
|
cr.execute('''select
|
||||||
id, (select count(*) > 0 from email_template e
|
id, (select count(*) > 0 from email_template e
|
||||||
where email_template_id=email_template.id)
|
where email_template_id=email_template.id)
|
||||||
from email_template
|
from email_template
|
||||||
|
@ -45,7 +45,7 @@ class email_template(Model):
|
||||||
def get_email_template(self, cr, uid, template_id=False, record_id=None,
|
def get_email_template(self, cr, uid, template_id=False, record_id=None,
|
||||||
context=None):
|
context=None):
|
||||||
this = super(email_template, self).get_email_template(
|
this = super(email_template, self).get_email_template(
|
||||||
cr, uid, template_id, record_id, context)
|
cr, uid, template_id, record_id, context)
|
||||||
|
|
||||||
if this.email_template_id and not this.is_template_template:
|
if this.email_template_id and not this.is_template_template:
|
||||||
for field in ['body_html']:
|
for field in ['body_html']:
|
||||||
|
|
Loading…
Reference in New Issue