How to do it...

  1. Define a view for your report in reports/book_loan_templates.xml:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="my_module.book_loans_template">
<t t-call="web.html_container">
<t t-foreach="docs" t-as="doc">
<t t-call="web.internal_layout">
<div class="page">
<div class="oe_structure">
<h1>Book Loans for <t t-esc="doc.name"/></h1>
<table class="table table-condensed">
<thead>
<tr><th>Title</th><th>Expected return date</th></tr>
</thead>
<tbody>
<tr t-foreach="doc.loan_ids" t-as="loan" >
<td><t t-esc="loan.book_id.name" /></td>
<td><t t-esc="loan.expected_return_date" /></td>
</tr>
</tbody>
</table>
</div>
</div>
</t>
</t>
</t>
</template>
</odoo>
  1. Use this view in a report tag in reports/book_loan_report.xml:
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<report id="report_book_loans"
name="my_module.book_loans_template"
model="library.member"
string="Book Loans"
report_type="qweb-pdf" />
</odoo>
  1. Add both files in the manifest of the addon:
{
'name': 'Chapter 13 code for the qweb report recipe',
'depends': ['mail'],
'data': [
'views/library_book.xml',
'views/library_member.xml',
'reports/book_loan_report.xml',
'reports/book_loan_report_template.xml',
],
'demo': ['demo/demo.xml'],
}

Now, when opening a library member form view or when selecting members in the list view, you should be offered to print the book loans.

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

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