Odoo v12 API get invoice PDF

Odoo v12 API get invoice PDF

This question got me started with my C# Odoo API implementation. I have working code using CookComputing.XmlRpcV2 to retrieve a list of invoices.

What I would like to implement is the option to retrieve/download a PDF of a selected invoice. Does anybody know what I would need to get this done?

When I search, I find forum posts stating reporting doesn't work since V11, such as this one. Neither do I see it mentioned in the online documentation for V12, although there is mention of it at the bottom of the page for V10.


Someone mentioned to construct an URL:


Where 1 is the invoice ID. Technically this works, but requires me to be logged in to the portal using the browser. Even if I can log into the portal from my C# service, I do not know where/how to retrieve the correct access token. I can see this is in GUID form. Does anybody know whether this is the same token I could retrieve from the OAuth2 REST API (which is a paid module b.t.w.)?

Correct. You can download the PDF by placing in the access_token.

This is the only way I managed to figure it out for Odoo v.12. after smashing my head against a brick wall repeatedly. My example programming language is with Python 3 though, not C#, but I'm sure you can adapt it.

odoo_url_host = "https://company.odoo.com"

The access_token can be found in the invoice's JSON response.

invoice_id = 1234
models = xmlrpcclient.ServerProxy('{}/xmlrpc/2/object'.format(odoo_url_host))
invoice = models.execute_kw(db, uid, password, "account.invoice", read, [[invoice_id]])

which, provided you get back a found invoice, you can use the response like so:


download_url = "%s/%s/my/invoices/%d?report_type=pdf&download=true&access_token=%s" % (odoo_url_host, invoice_id, invoice["access_token"])

Which if you simply want to automatically download, can be done like so:

import urllib.request

pdf_destination = "./invoices/invoice-%d.pdf" % invoice_id

urllib.request.urlretrieve(download_url, pdf_destination)

You'd need to change the way this is written for Python 2.7.

Also, make sure that you click 'share' on the invoice (within odoo) as sometimes the access_token doesn't get generated for that invoice and returns false otherwise.

Or if you'd like to seamlessly have the access_token generated, execute this before trying to get the access token:

ctx = {'active_model': 'account.invoice', 'active_id': invoice_id}
print(models.execute_kw(db, uid, password, 'portal.share', 'default_get',[{}],{'context': ctx}))

That should get you the share_link for the entire document, but all you need is the access_token to be generated. You can extract the access_token from the share_link value in the JSON response, if you'd like to do it that way. Anyway :) Happy coding.

Generate PDF from api, Hello I want to generate report through API. E.g. I I create API like /api/​generate_pdf with type="htpp" and method="GET".after accessing this API able to generate  Send Invoices Whenever and Wherever You Want with Wave’s Free Apps for iOS and Android. Set Up Recurring Invoices and Automatic Credit Card Payments for Your Repeat Customers.

I would try to use /xmlrpc/2/object with model ir.actions.report and method render_qweb_pdf. Bear in mind that you'll need a ir.actions.report record, because render_qweb_pdf isn't a "model method" (in OOP class method).

How to retrieve invoices using the web API in Odoo 11?, Anyone managed to get it to work? I also want to access the Invoice PDF using the Odoo 12 API. Any working PHP example would be very  Search invoicing online. Explore Teoma.us, the leading search site for results around the web.

I am currently testing a similar functionality but with stock.picking where I need delivery form downloaded from a remote Odoo instance and saved as an attachment in another instance. What I did is adding this function to stock.picking in remote Odoo.

def sd_get_delivery_form(self, uid):
    picking = self.env['stock.picking'].sudo().search([('sd_uid', 'like', uid)], limit=1)
    if picking and picking.sale_id:
        pdf = self.env.ref('sale.action_report_saleorder').sudo().render_qweb_pdf([picking.sale_id.id])
        b64_pdf = base64.b64encode(pdf[0])
        order_pdf = b64_pdf.decode('utf-8')
        return {'file': order_pdf}
        return False

Then calling it using xmlrpc and save it as an attachment

attachment_name = "delivery_order_({})".format(self.id)
    'name': attachment_name,
    'type': 'binary',
    'datas': dt['file'],
    'datas_fname': attachment_name + '.pdf',
    'store_fname': attachment_name,
    'res_model': self._name,
    'res_id': self.id,
    'mimetype': 'application/x-pdf'

What you can do in C# is getting the base64 and save it as PDF if you like to go in this similar way.

[11.0] External API, Correct. You can download the PDF by placing in the access_token. This is the only way I managed to figure it out for Odoo v.12. after smashing my head  Generate Invoices & Get Paid 2x Faster with the World's Friendly Invoicing+Payments App. Award-Winning Customer Happiness. PCMag Editors' Choice 2018.

The simplest way is to use OdooRPC library : https://pythonhosted.org/OdooRPC/ref_report.html

Professional Odoo REST API 1 OAS3, get/api/auth/get_tokens .order.line, product.template, account .invoice, account.​invoice.line. <h3><b description: Odoo v12. tags:. Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc. Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

[PDF] Odoo development Documentation, http://odoo-new-api-guide-line.readthedocs.org/en/latest/decorator.html Get variable transmitted by render() in XML template XmlReceipt - prints in PosBox after pressing the button Print receipt on the Payment screen if  Odoo Proprietary License v1.0 This software and associated files (the "Software") may only be used (executed, modified, executed after modifications) if you have purchased a valid license from the authors, typically via Odoo Apps, or if you have received a written agreement from the authors of the Software (see the COPYRIGHT file).

Odoo POS Invoice On Receipt, Now onwards, your customers can track their payments via receipt only. It is possible because now you can get an invoice number on a receipt. Odoo POS Invoice  Odoo v12 API get invoice PDF I am currently testing a similar functionality but with stock.picking where I need delivery form downloaded from a remote Odoo instance and saved as an attachment in another instance.

Odoo tips of the Month : October 2019, Odoo : You can sign directly the contract, create an invoice, get paid… #​OdooExperience; In Accounting app #Odoo reads PDF files for you. In #​odoo13 @ api.multi is deletedhttps://github.com/odoo/odoo/commit/ (Till v12 it has no effect on Non-editable views); #Odoo 13 includes an easy way to  Overview This module allows you to mention discount on Total of sale order and Total of Customer Invoice as percentage or as amount.