Dynamic Template Renderer
by Opportunities Soft https://apps.odoo.com/apps/browse?repo_maintainer_id=717323
Odoo
$ 10.96
Availability |
Odoo Online
Odoo.sh
On Premise
|
Lines of code | 44 |
Technical Name |
dynamic_template_renderer |
License | OPL-1 |
Website | https://apps.odoo.com/apps/browse?repo_maintainer_id=717323 |
Versions | 16.0 17.0 18.0 |
Availability |
Odoo Online
Odoo.sh
On Premise
|
Lines of code | 44 |
Technical Name |
dynamic_template_renderer |
License | OPL-1 |
Website | https://apps.odoo.com/apps/browse?repo_maintainer_id=717323 |
Versions | 16.0 17.0 18.0 |
Dynamic Template Renderer Module
Overview
The Dynamic Template Renderer Module provides an intuitive way to dynamically render templates with placeholders in Odoo 17. Use this module to create customizable templates that replace placeholders with field values from your models, including nested relational fields and formatted dates.
Key Features
- Dynamically replace placeholders with model field values.
- Support for nested and relational fields (One2many, Many2many).
- Automated formatting for date and datetime fields.
- Reusable Abstract Model for seamless integration across multiple modules.
- Effortlessly create dynamic templates for reports, emails, and more.
Benefits
- Save time with automated template rendering.
- Enhance accuracy by eliminating manual entry errors.
- Deliver professional documents and reports effortlessly.
How to Use
Step 1: Add the Mixin
Inherit the mixin in your model:
from odoo import models, fields, api class YourModel(models.Model): _name = 'your.model' _inherit = 'dynamic.template.mixin' base_template = fields.Html(string="Base Template") next_template = fields.Html(string="Next Template") other_template = fields.Html(string="Rendered Base Template") render_template = fields.Html(string="Rendered Next Template") @api.onchange('base_template', 'next_template') def update_description(self): for rec in self: rec.other_template = self.update_dynamic_field(rec.base_template) rec.render_template = self.update_dynamic_field(rec.next_template)
Step 2: Use Placeholders
Define placeholders in your templates:
Hello {{object.name}}, your ID is {{object.st_id}}. Your address is {{object.st_address}}.
Relational fields can be accessed using dot notation:
Your product is {{object.line_ids.product_id.name}}.
Screenshots

Form View Example

Rendered Template Example

Module in App List
Contact
mehedikhan.cse@gmail.com
Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file). You may develop Odoo modules that use the Software as a library (typically by depending on it, importing it and using its resources), but without copying any source code or material from the Software. You may distribute those modules under the license of your choice, provided that this license is compatible with the terms of the Odoo Proprietary License (For example: LGPL, MIT, or proprietary licenses similar to this one). It is forbidden to publish, distribute, sublicense, or sell copies of the Software or modified copies of the Software. The above copyright notice and this permission notice must be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please log in to comment on this module