[UPD] README.rst

This commit is contained in:
OCA-git-bot
2022-05-30 10:54:37 +00:00
parent 9484aff29f
commit ca479c4595
2 changed files with 43 additions and 15 deletions

View File

@@ -87,20 +87,33 @@ The template is a html field which will be rendered just like a mail template, s
Change the report related to the model from configuration and add a statement like: Change the report related to the model from configuration and add a statement like:
<p t-if="o.get_comment_template('before_lines', o.company_id.id, o.partner_id and o.partner_id.id or False)"> <t t-foreach="o.comment_template_ids.filtered(lambda x: x.position == 'before_lines')" t-as="comment_template_top">
<div t-raw="o.render_comment(comment_template_top)" />
<span t-raw="o.get_comment_template('before_lines', o.company_id.id, o.partner_id and o.partner_id.id or False)"/> </t>
</p>
<p t-if="o.get_comment_template('after_lines', o.company_id.id, o.partner_id and o.partner_id.id or False)"> <t t-foreach="o.comment_template_ids.filtered(lambda x: x.position == 'after_lines')" t-as="comment_template_bottom">
<div t-raw="o.render_comment(comment_template_bottom)" />
<span t-raw="o.get_comment_template('after_lines', o.company_id.id, o.partner_id and o.partner_id.id or False)"/> </t>
</p>
You should always use t-if since the method returns False if no template is found. You should always use t-if since the method returns False if no template is found.
If you want to use Qweb templates, or different context, you can specify it just like in
mail.render.mixin with parameters:
- engine: "jinja" or "qweb",
- add_context: dict with your own context,
- post_process: perform a post processing on rendered result
so you could use it :
<t t-foreach="o.comment_template_ids.filtered(lambda x: x.position == 'before_lines')" t-as="comment_template_top">
<div t-raw="o.render_comment(comment_template_top, engine='qweb', add_context={my dict}, postprocess=True)" />
</t>
Bug Tracker Bug Tracker
=========== ===========

View File

@@ -433,15 +433,30 @@ It has a priority field (smaller number = higher priority)</p>
If you create a new template with the same configuration (Model, Domain, Position) and set it as Default, the previous one will be deselected as a default one.</p> If you create a new template with the same configuration (Model, Domain, Position) and set it as Default, the previous one will be deselected as a default one.</p>
<p>The template is a html field which will be rendered just like a mail template, so you can use variables like ${object}, ${user}, ${ctx} to add dynamic content.</p> <p>The template is a html field which will be rendered just like a mail template, so you can use variables like ${object}, ${user}, ${ctx} to add dynamic content.</p>
<p>Change the report related to the model from configuration and add a statement like:</p> <p>Change the report related to the model from configuration and add a statement like:</p>
<p>&lt;p t-if=”o.get_comment_template(before_lines, o.company_id.id, o.partner_id and o.partner_id.id or False)”&gt;</p> <dl class="docutils">
<blockquote> <dt>&lt;t t-foreach=”o.comment_template_ids.filtered(lambda x: x.position == before_lines)” t-as=”comment_template_top”&gt;</dt>
&lt;span t-raw=”o.get_comment_template(before_lines, o.company_id.id, o.partner_id and o.partner_id.id or False)”/&gt;</blockquote> <dd>&lt;div t-raw=”o.render_comment(comment_template_top)” /&gt;</dd>
<p>&lt;/p&gt;</p> </dl>
<p>&lt;p t-if=”o.get_comment_template(after_lines, o.company_id.id, o.partner_id and o.partner_id.id or False)”&gt;</p> <p>&lt;/t&gt;</p>
<blockquote> <dl class="docutils">
&lt;span t-raw=”o.get_comment_template(after_lines, o.company_id.id, o.partner_id and o.partner_id.id or False)”/&gt;</blockquote> <dt>&lt;t t-foreach=”o.comment_template_ids.filtered(lambda x: x.position == after_lines)” t-as=”comment_template_bottom”&gt;</dt>
<p>&lt;/p&gt;</p> <dd>&lt;div t-raw=”o.render_comment(comment_template_bottom)” /&gt;</dd>
</dl>
<p>&lt;/t&gt;</p>
<p>You should always use t-if since the method returns False if no template is found.</p> <p>You should always use t-if since the method returns False if no template is found.</p>
<p>If you want to use Qweb templates, or different context, you can specify it just like in
mail.render.mixin with parameters:</p>
<ul class="simple">
<li>engine: “jinja” or “qweb”,</li>
<li>add_context: dict with your own context,</li>
<li>post_process: perform a post processing on rendered result</li>
</ul>
<p>so you could use it :</p>
<dl class="docutils">
<dt>&lt;t t-foreach=”o.comment_template_ids.filtered(lambda x: x.position == before_lines)” t-as=”comment_template_top”&gt;</dt>
<dd>&lt;div t-raw=”o.render_comment(comment_template_top, engine=qweb, add_context={my dict}, postprocess=True)” /&gt;</dd>
</dl>
<p>&lt;/t&gt;</p>
</div> </div>
<div class="section" id="bug-tracker"> <div class="section" id="bug-tracker">
<h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1> <h1><a class="toc-backref" href="#id3">Bug Tracker</a></h1>