There's more...

To modify existing templates, you can use the inherit_id attribute on the template and then use an xpath element like the view inheritance. For example, we want to display the count of authors near the Authors label by inheriting the books template. We can do this in the following way:

<template id="books_ids_inh" inherit_id="my_library.books">
<xpath expr="//div[@class='card-body']/b" position="replace">
<b class="mt8"> Authors (<t t-esc="len(book.author_ids)"/>) </b>
</xpath>
</template>

Inheritance works exactly like views, because internally, QWeb templates are a normal view with the type qweb. The template element is a shorthand for a record element that sets some properties on the record for you. While there's never a reason to not use the convenience of the template element, you should know what happens under the hood: the element creates a record of the ir.ui.view model with the qweb type. Then, depending on the template element's name and inherit_id attributes, the inherit_id field on the view record will be set.

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

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