Skip to main content

Add conditional mako template to any reporton models that inherits comment.template.

Project description

Beta License: AGPL-3 OCA/reporting-engine Translate me on Weblate Try me on Runboat

Add a new mixin class to define templates of comments to print on documents. The comment templates can be defined like make templates, so you can use variables from linked models.

Two positions are available for the comments:

  • above document lines (before_lines)

  • below document lines (after_lines)

The template are general, and can be attached to any Model and based on some domain defined in the template. You can define one default template per Model and domain, which can be overwritten for any company and partners. It has a priority field (smaller number = higher priority)

In existing reports, if you add this line will get the comment template if you created one like

  • <span t-raw=”o.get_comment_template(‘position’,company_id=o.company_id, partner_id=o.parnter_id )”/> ( or without any parameter)

This module is the base module for following modules:

  • sale_comment_template

  • purchase_comment_template

  • invoice_comment_template

  • stock_picking_comment_template

Table of contents

Configuration

Go to Settings > Technical > Reporting > Comment Templates and start designing you comment templates.

This module is the base module for following modules:

  • sale_comment_template

  • purchase_comment_template

  • invoice_comment_template

  • stock_picking_comment_template

Usage

  1. Go to Settings and activate the developer mode.

  2. Go to Settings > Technical > Reporting > Comment Templates.

  3. Create a new record.

  4. Define the Company the template is linked or leave default for all companies.

  5. Define the Partner the template is linked or leave default for all partners.

  6. Define the Model, Domain the template is linked.

  7. Define the Position where the template will be printed:

    • above document lines

    • below document lines

You should have at least one template with Default field set, if you choose a Partner the template is deselected as a Default one. 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.

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.

Change the report related to the model from configuration and add a statement like:

<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)” />

</t>

<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)” />

</t>

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

Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed feedback.

Do not contact contributors directly about support or help with technical issues.

Credits

Authors

  • Camptocamp

Contributors

Maintainers

This module is maintained by the OCA.

Odoo Community Association

OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.

This module is part of the OCA/reporting-engine project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

File details

Details for the file odoo14_addon_base_comment_template-14.0.4.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for odoo14_addon_base_comment_template-14.0.4.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3b8f431f96b6f5daf24eb37fd36253be183b345b07bebc6f01a00dc2bc60648d
MD5 01154c4be15681a7abf6cb307f16eee8
BLAKE2b-256 c1f5c338c761858c6984619dd77d6e8914788ab9452175c10086b0986da67c42

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page