Offering dynamic snippets to the user
In this recipe, we will see how we can create dynamic snippets for Odoo. We will generate content based on database values.
Getting ready
For this recipe, we will be using the my_library
module from the previous recipe.
How to do it...
Perform the following steps to add a dynamic snippet that shows a list of books:
- Add a given QWeb template for the snippet in
views/snippets.xml
:<template id="snippet_book_dynamic" name="Latest Books"> Â Â Â Â <section class="book_list"> Â Â Â Â Â Â Â Â <div class="container"> Â Â Â Â Â Â Â Â Â Â Â Â <h2>Latest books</h2> Â Â Â Â Â Â Â Â Â Â Â Â <table class="table book_snippet table-striped" Â Â Â Â Â Â Â Â Â Â Â Â Â ...