Offering dynamic snippets to the user
Dynamic snippets refer to reusable components or blocks that are capable of displaying dynamic content pulled from various sources such as databases, models, or external services. These snippets enable the creation of versatile and adaptable web pages that display real-time or context-specific information.
Identify data sources:
- Determine the data sources you want to use in your dynamic snippet. This can include Odoo models, databases, APIs, and so on.
- Implement dynamic placeholders using QWeb templating tags (
{% %}
) or Odoo-specific directives (<t
t-foreach="..." t-as="...">
).
We will see how we can create dynamic snippets for Odoo. We will generate content based on database values.
How to do it…
Perform the following steps to add a dynamic snippet that shows a list of hostel data:
- Add a given QWeb template for the snippet in
views/snippets.xml
:<template id="snippet_hostel_dynamic...