Akretion's Christmas present for the Odoo community

Akretion is happy to offer you a Christmas present ! This Christmas present is for all the users of the accounting module of Odoo version 8 (and hopefully for the users of Odoo version 9 soon). If you are one of them, we hope that you will use and appreciate our present !

But, before going more in details about our present, let me tell you its story. This story started during the last week-end of September 2015. Akretion France’s fiscal year closes on June 30th and, in France, we have to send to the fiscal administration the financial statements and the corporate income tax declaration 3 months maximum after the end of the fiscal year. So the deadline for Akretion France was September 30th 2015. Of course, to generate the financial statements, we need to have all our supplier invoices in Odoo ! But, as we are very busy with the work for our customers and our contributions to the Odoo Community Association (OCA), we are often very late on the encoding of the “small” invoices (phone bill, Internet bill, train ticket, …) and the last fiscal year was no exception. So we had one week-end to encode the backlog of supplier invoices and finalize the financial statements…

As Sébastien Beau was looking at the many train tickets he had to encode as supplier invoices, he decided to try to develop a script to do it for him. As with most suppliers, we have access to the PDF of the invoice in the customer Web access, but there is no webservice nor API to retreive the invoices automatically. OVH, the leading hosting provider, provides a webservice to access the invoices with very detailed information and Akretion developped a module for Odoo 8 named ovh_supplier_invoice to automate the download of OVH invoices and their creation as supplier invoices in Odoo. But, for all the other suppliers of Akretion, no such thing exists. We only have the PDF file of the invoice in our mailbox or on the extranet of the supplier, and nothing else !

So Sébastien had all the PDF files of his train tickets in his mailbox and didn’t want to spend one hour to encode them manually one by one in Odoo. So he started to explore the possibilities of extracting the text out of the PDF file with a Python library called pdfminer and create the supplier invoice in Odoo. After several hours of work, he came out with a Python script that was able to extract all the data needed to encode the train ticket as invoice (date, amount, ticket number, description of the travel) for all the PDF files he had in his mailbox. Then we thought that, as it was working for the train tickets, it would be great to have it also for the phone bills, the Internet access bills, the hosting bills, the office rental bills and all those recurring invoices that we have receive without generating a PO from Odoo. That’s how we got the idea of developping a module dedicated to PDF invoice import.

This reminds us about the introduction of EDI in OpenERP 6.1. At that time, it was presented as a way to automate the transmission of invoices between a supplier and a customer. Have you ever used it ? Probably never. One of the reasons of the low adoption is that both the customer and the supplier would have to open-up Odoo on the Internet or setup a VPN link between them. Another reason is that the EDI format proposed by Odoo was yet another format (and there are already many in the EDI world).

Our German friends are taking another approch for the transmission of invoices ; their approch is very simple and pragmatic. They published a standard called ZUGFeRD that specifies that a PDF invoice should contain an embedded XML file that provides a structured representation of the invoice. For the XML file, they decided to use the Cross Industry Invoice (CII) format published by an agency of the United nations called UN/CEFACT. In this domain, there are 2 main standards for the description of invoices in XML : the CII format of UN/CEFACT and the Universal Business Language (UBL) standardized by the OASIS. This approch is very pragmatic because:

  • users don’t have to change their habbits: they can continue to send the invoices to their customers via email with the PDF file attached,
  • the same PDF document contains both the computer-readable information in the embedded XML file and the human-readable information that is displayed by the usual PDF reader of the user,
  • the same PDF invoice can be used both by companies that have a modern ERP software such as Odoo that can take advantage of the embedded XML file and by the companies that have an old ERP software in which users will manually encode their supplier invoices by viewing the invoice in their prefered PDF reader.

For the good old PDF invoices that don’t have any embedded XML file, we found an existing Python library called invoice2data that was already doing what we needed: extract the text of a PDF file, try to match it to an existing template and parse the text via the regexp provided by the template to retreive the information needed to create a simple supplier invoice in an accounting software. If your suppliers are not yet supported by this library, you should take a few minutes to add a template for your supplier and submit of pull request on github. Akretion already contributed to this library the support of several French mobile phone operators (SFR, Bouygues Telecom, Free mobile, Sosh) and several French Internet operators (SFR, Free, Orange fiber) in this pull request.

With all these discoveries, we started to develop an Odoo module that would be able to handle both the modern PDF invoices with an embedded XML file and the good old PDF invoices without embedded structured data. Our module, called account_invoice_import, works the following way:

Odoo PDF import wizard

  1. the user starts a wizard and uploads the PDF invoice, as shown in the above screenshot.
  2. if the PDF file has an embedded XML file in ZUGFeRD/CII format, Odoo will read the XML file.
  3. otherwise, Odoo will use the invoice2data Python library to try to interpret the text of the PDF.
  4. Odoo will create a new draft supplier invoice and attach the PDF to it.

This module is available in this pull request on the OCA project account-invoicing for Odoo version 8 under the AGPL licence. Please take the time to read the detailed instructions to install, configure and use this module. French users may also need the module l10n_fr_invoice_import available in this pull request on the French localization of the OCA ; this module allows to find the related supplier in Odoo by the SIREN number and not just by the TIN or VAT number.

When you import a PDF invoice in Odoo and Odoo already has a draft invoice for the same supplier, it will ask you if you want to create a new invoice or update the existing draft invoice (that may have been generated from a PO or a reception), as you can see in the screenshot below:

Odoo invoice update

Akretion team wishes your a merry Christmas and hope that you will like our Christmas present ! Our dream is that this new Odoo module would transform your painful duty of manually encoding your recurring supplier invoices into a fast and enjoyable task ! If it is the case, please share your experience with us and with the Odoo community.

Lumière sur l'auteur

Alexis de Lattre
Fondateur - France
Spécialiste Odoo et logiciel libre
Alexis de Lattre is a co-founder of the French company Anevia, where he held the positions of Managing Director and Financial Director of Production and Logistics and Director of Computer Services. Anevia is a company with 40 employees and specializes in the development and sale of video server...
Nous utilisons des cookies pour vous garantir la meilleure expérience sur notre site. Si vous continuez à utiliser ce dernier, nous considérerons que vous acceptez l'utilisation des cookies.