To modify the actual presentation of the web page, we need to extend the QWeb template being used.
We will be extending the library_app.book_list_template to show additional information on the books that are not available.
Add the library_member/views/book_list_template.xml file by using the following code:
<odoo>
<template id="book_list_extended"
name="Extended Book List"
inherit_id="library_app.book_list_template">
<xpath expr="//span[@t-field='book.publisher_id']" position="after">
<t t-if="not book.is_available">
<b>(Not Available)</b>
</t>
</xpath>
</template>
</odoo>
Web page templates are XML documents, just like the other Odoo View types, and we can use xpath to locate elements and then manipulate them, just like we could with the other View types. The inherited template is identified in the <template> element by the inherit_id attribute.
We should not forget to declare this additional data file in our add-on manifest, library_member/__manifest__.py:
'data': [
'views/book_view.xml',
'security/library_security.xml',
'security/ir.model.access.csv',
'views/member_view.xml',
'views/library_menu.xml',
'views/book_list_template.xml',
],
After this, accessing http://localhost:8069/library/books should show the additional (Not Available) information on the books that are not available.