How to do it...

Follow these steps to add a custom credit template:

  1. Add a template with service information at views/templates.xml:
<odoo>
<template id="no_credit_info" name="No credit info">
<section class="jumbotron text-center bg-primary">
<div class="container pb32 pt32">
<h1 class="jumbotron-heading">Library ISBN</h1>
<p class="lead text-muted">
Get full book information with cover image just by the ISBN number.
</p>
<span class="badge badge-warning" style="font-size: 30px;">
20% Off
</span>
</div>
</section>
<div class="container">
<div class="row">
<div class="col">
<div class="card mb-3">
<div class="card-header">
<i class="fa fa-database"/> Large books database
</div>
<div class="card-body">
<p class="card-text">
We have largest book databse. It contains more
then 2500000+ books.
</p>
</div>
</div>
</div>
<div class="col">
<div class="card mb-3">
<div class="card-header">
<i class="fa fa-image"/>
With cover image
</div>
<div class="card-body">
<p class="card-text">
More then 95% of our books having high quality
book cover images.
</p>
</div>
</div>
</div>
</div>
</div>
</template>
</odoo>

  1. Add a template to __manifest__.py:
...
'data': [
'security/ir.model.access.csv',
'views/book_info_views.xml',
'data/books_data.xml',
'views/res_config_settings.xml',
'views/templates.xml'
]
...
  1. Add a template reference to iap.charge at controllers/main.py:
...
with iap.charge(request.env, service_key, account_token, credits_to_reserve, credit_template='iap_isbn_service.no_credit_info'):
data = request.env['book.info'].sudo()._books_data_by_isbn(isbn_number)
if data['status'] == 'not found':
raise Exception('Book not found')

Update the module to apply the changes. After the update, you will see a credit popup if all of the customer's credit is consumed:

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

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