Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


How to make downloading a pdf file

on 6/7/16, 5:36 AM 285 views


I'm currently creating an Odoo 9 module and I've got a Class with a report_coupon function called by a button.

Here is my class :

class loyalty_coupon(models.Model):

    _name = 'loyalty.coupon'

    _columns = {

        'name': fields.char('Name', size=32, select=1, required=True, help='An internal identification for this loyalty coupon'),

       'loyalty_program_id': fields.many2one('loyalty.program', 'Loyalty Program', help='The Loyalty Program this coupon belongs to'),

       'reduction': fields.float('Reduction', help='The amount of reduction of this coupon in EUR'),

       'date': fields.date('Date Limit', help='The date limit of the coupon'),

       'limited': fields.boolean('Limited', help='The kind of coupon'),

       'used': fields.boolean('Used', help='The state of the coupon, used or not used'),

       'barcode': fields.char('Barcode', help="International Article Number used for coupon identification.", oldname='ean13', copy=False),



    def report_coupon(self):


I want this function to allow the user to download a pdf file generated (composed of attributes of the class).

How can I do this ? :)

Thank you in advance for your replies and help !


Emipro Technologies Pvt. Ltd.

--Emipro Technologies Pvt. Ltd.--
Tiny ERP Pvt Ltd
| 6 7 8
Rajkot, India
--Emipro Technologies Pvt. Ltd.--

Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. A ray of relief & satisfaction to  our customers heart by our successful deployment in their organization, purely represents our success in Odoo platform. Hence, we take pride for being an Odoo partner with a vision of expanding our strategic alliances with our customers to offer them high value-added, trustworthy & cost effective solutions.


Since establishment, our business has span across 11 countries of the world. Our customers are companies of all sizes ranging from start-ups to large enterprises, who realize that they need a professional business solutions to generate revenue streams, establish proper communication channels or streamline business operations. Standing with strong determination of customer satisfaction, observing each minute detail of their business processes, providing proper guidance and moving forth to develop product accordingly adds our value and reliability among our customers. 


We are blessed with efficient, passionate & eclectic young developers who have come across almost all kinds of business profiles, working with full dedication, applying creativity & new features in existing modules and completing customer's projects successfully on predefined target. Our in-depth knowledge while giving business solutions in Odoo allows us to offer following services to our customers :


  • Consulting
  • Installation, Configuration & Customization
  • Training & Support
  • Maintenance
  • Upgradation
  • Documentation
  • Crafting community modules
  • Drafting videos on demand
  • Smart Apps development

We will be :) to welcome you @ www.emiprotechnologies.com to solve any kind of your business needs around Odoo. However we are just an inch away from you by email info@emiprotechnologies.com or a tweet to @EmiproTech

Emipro Technologies Pvt. Ltd.
On 6/10/16, 1:52 AM


Please make one button inside your form. i.e. 

<button name="report_coupon"  type="object" string="Download PDF" />

According to the button defination you need to define one method inside your model with following lines of code. thats it.

def report_coupon(self):
return self.env['report'].get_action(self, 'modulename.xmlidofyourreport') #modulename.custom_report_coupon


Above line of code will give the option to download pdf report on clicking of that button.

Please try it in your module.

Well, thank you, it's better but i've got an error :

raise ValueError('External ID not found in the system: %s' % (xmlid))

ValueError: External ID not found in the system:


on 6/10/16, 4:16 AM

I have updated my answer, you just need to give external ID of your report. thats it.

Emipro Technologies Pvt. Ltd.
on 6/10/16, 6:39 AM

Thank you ! Now, a new error appeared :

Bad Report ReferenceThis report is not loaded into the database: loyalty.report_coupon

Why is it still not working ? What's wrong ?

on 6/13/16, 5:29 AM
On 6/9/16, 10:17 AM

Currently, I have the following reports and records in an XML file called "report.xml" :

<template id="report_coupon">

  <t t-call="report.external_layout">

   <div class="page">

    <div class="row">






<template id="report_without_prices">

  <t t-call="report.html_container">

   <t t-foreach="doc_ids" t-as="doc_id">

    <t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang', 'account.coupon')"/>




In my view, I have










So, my question is how to call this from a button and allow the user to download a pdf file of this view ?

Thanks in advance !

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)


Asked: 6/7/16, 5:36 AM
Seen: 285 times
Last updated: 6/11/16, 5:38 PM