How it works...

In the first step, we created a dynamic route for the book details page. In this route, we have added <model("library.book"):book>. This accepts URLs with integers, like /books/1. Odoo considers this integer as the ID of the library.book model, and when this URL is accessed, Odoo fetches a recordset and passes it to the function as the argument. So, when /books/1 is accessed from the browser, the book parameter in the function library_book_detail() will have a recordset of the library.book model with the ID 1. We passed this book recordset and rendered a new template called my_library.book_detail.

In the second step, we created a new QWeb template called book_detail to render a book details page. This is simple and is created using the Bootstrap structure. If you check, we have added html_description in the detail page. The field html_description has a field type of HTML, so you can store the HTML data in the field. Odoo automatically adds the snippet drag and drop support to the HTML types of fields. So, now we are able to use snippets in the book details page. The snippets dropped in the HTML fields are stored in a book's records, so you can design different content for different books.

In the last step, we added a link with the anchor tag so that a visitor can be redirected to the book details page.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset