How to do it...

Follow these steps to send a reminder email to the borrower:

  1. Add the QWeb template into the my_library/data/mail_template.xml file:
<template id="book_return_reminder_qweb">
<p>Dear <span t-field="object.borrower_id.name"/>,</p>
<p>You had rented the
<b>
<span t-field="object.book_id.name"/>
</b> book on <span t-field="object.rent_date"/>
<br/>
The due date of book is
<b style="color:red;">
<span t-field="object.return_date"/>
</b>
</p>
<br/>

<p>Best regards,
<br/>
Librarian
</p>
</template>
  1. Add a Send reminder (QWeb) button in the form view of the library.book.rent model to send the email:
...
<header>
<button name="book_return" string="Return the Book" states="ongoing" type="object"/>
<button name="book_return_reminder" string="Send reminder" states="ongoing" type="object"/>
<button name="book_return_reminder_qweb" string="Send reminder(QWeb)" states="ongoing" type="object"/>
<field name="state" widget="statusbar"/>
</header>
...
  1. Add the book_return_reminder_qweb() method in the library.book.rent model:
...
def book_return_reminder_qweb(self):
self.message_post_with_view('my_library.book_return_reminder_qweb')

Update the my_library module to apply the changes. This will add a Send reminder (QWeb) button in the form view of the library.book.rent model. When the button is clicked, followers will get a message like this:


The procedure shown in this recipe works exactly like the previous recipe Sending mail using the Jinja template. The only difference is the template type, as this recipe uses QWeb templates.

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

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