Merge lp:~therp-nl/server-env-tools/7.0_email_template_template_rst into lp:~server-env-tools-core-editors/server-env-tools/7.0

Proposed by Holger Brunn (Therp)
Status: Merged
Merged at revision: 51
Proposed branch: lp:~therp-nl/server-env-tools/7.0_email_template_template_rst
Merge into: lp:~server-env-tools-core-editors/server-env-tools/7.0
Diff against target: 96 lines (+35/-32)
1 file modified
email_template_template/__openerp__.py (+35/-32)
To merge this branch: bzr merge lp:~therp-nl/server-env-tools/7.0_email_template_template_rst
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp Approve
Pedro Manuel Baeza code review, no test Approve
Stefan Rijnhart (Opener) Approve
Review via email: mp+189108@code.launchpad.net

Description of the change

To post a comment you must log in.
Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Tnx!

review: Approve
Revision history for this message
Pedro Manuel Baeza (pedro.baeza) wrote :

LGTM

review: Approve (code review, no test)
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'email_template_template/__openerp__.py'
2--- email_template_template/__openerp__.py 2013-06-17 09:03:49 +0000
3+++ email_template_template/__openerp__.py 2013-10-03 15:09:26 +0000
4@@ -32,8 +32,9 @@
5 in the other templates. Changing the layout is then only a matter of changing
6 the template template.
7
8-
9-Usage:
10+-----
11+Usage
12+-----
13 Create an email template with the related document model 'Email Templates'. Now
14 most of the fields gray out and you can only edit body_text and body_html. Be
15 sure to use ${body_text} and ${body_html} respectively in your template
16@@ -43,48 +44,50 @@
17 templates.
18
19 For example, create a template template
20------
21-Example Corp logo
22-Example Corp header
23-${object.body_text} <- this gets evaluated to the body_text of a template using this template template
24-Example Corp
25-Example street 42
26-Example city
27-Example Corp footer
28------
29+
30+::
31+
32+ Example Corp logo
33+ Example Corp header
34+ ${object.body_text} <- this gets evaluated to the body_text of a template using this template template
35+ Example Corp
36+ Example street 42
37+ Example city
38+ Example Corp footer
39
40 Then in your template you write
41
42------
43-Dear ${object.partner_id.name},
44+::
45
46-Your order has been booked on date ${object.date} for a total amount of ${object.sum}.
47------
48+ Dear ${object.partner_id.name},
49+
50+ Your order has been booked on date ${object.date} for a total amount of ${object.sum}.
51
52 And it will be evaluated to
53
54------
55-Example Corp logo
56-Example Corp header
57-Dear Jane Doe,
58-
59-Your order has been booked on date 04/17/2013 for a total amount of 42.
60-Example Corp
61-Example street 42
62-Example city
63-Example Corp footer
64------
65+::
66+
67+ Example Corp logo
68+ Example Corp header
69+ Dear Jane Doe,
70+
71+ Your order has been booked on date 04/17/2013 for a total amount of 42.
72+ Example Corp
73+ Example street 42
74+ Example city
75+ Example Corp footer
76
77 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):
78
79 In your template template:
80
81-------
82-Dear ${'${object.name}'}, <-- gets evaluated to "${object.name}" in the first step, then to the content of object.name
83-${object.body_html}
84-Best,
85-Example Corp
86-------""",
87+::
88+
89+ Dear ${'${object.name}'}, <-- gets evaluated to "${object.name}" in the first step, then to the content of object.name
90+ ${object.body_html}
91+ Best,
92+ Example Corp
93+""",
94 'website': 'http://therp.nl',
95 'images': [],
96 'depends': ['email_template'],