Search 1.9 billion lines of Odoo code on GitHub

account_invoice_import_invoice2data

Author: Akretion,Odoo Community Association (OCA)
License: AGPL-3
Branch: 12.0
Repository: abihedia/edi-1
Dependencies: account_invoice_import
Languages: HTML (390, 44.9%), PO File (157, 18.1%), Python (194, 22.3%), XML (41, 4.7%), and reStructuredText (87, 10.0%)
Other branches: 10.0, 8.0, 8.0-ocabot-merge-pr-211-by-bealdav-bump-minor, and 9.0
Other repositories: AizenL/edi, BT-aestebanez/edi, Billolha/edi, Bubbles-IT/edi, Callino/edi, Change2improve/edi, D4N/edi, Develoman/edi, ERPLibre/edi, EssentNovaTeam/edi, ForgeFlow/edi, Gabinete-Digital/edi, Ingeos/edi, JayVora-SerpentCS/edi, MathBenTech/edi, NeatNerdPrime/edi, Noviat/edi, OCA-MUK/edi, OCA/edi, ORETEK/edi, PlanetaTIC/edi, SSISoftware/edi, SanteLibre/edi, SeuMarco/edi, SimoRubi/edi, SimoneVagile/edi, Stargue/edi, TDu/edi, Tecnativa/edi, VisiionSolucionesTecnologicas/edi, aacceess75/edi, aaltinisik/edi, acsone/account-invoicing, acsone/edi, adolfoeliazat/edi, akretion/account-invoicing, akretion/edi, akretion/purchase-workflow, amendoncabh/edi, anhvu-sg/edi, anodino-dev/edi, antoinecln/edi, apachesep/edi, apetbiz/edi, aurestic/edi, bealdav/edi, bellyfat/edi, brain-tec/edi, bvkl/edi, camptocamp/edi, crece365/edi, cubicltd/odoo-OCA-edi, daramousk/edi, decodio-applications/edi, diagramsoftware/edi, edi-sprint/edi, eguane/edi, elego/edi, etobella/edi, exosoftware/oca-edi, feketemihai/edi, flotho/edi, freighttrust/edi-1, gfcapalbo/edi, gurneyalex/edi, haroldtamo/edi, hbrunn/edi, initOS/edi, inoio/oca-edi, invitu/edi, jason156/edi, joytao-zhu/edi, kbentaleb/edi, legalsylvain/edi, lideritjnma/edi, llamasfSpn/edi, maljac/edi, mjadily/edi, mohamed-helmy/edi, muguli22/edi, myceliandre/edi, njeudy/edi, onesteinbv/edi, open-net-sarl/edi, open-synergy/edi, open2bizz/edi, pasgou/edi, pscloud/edi, rconjour/edi, redcor/edi, richar-osse/edi, rousseldenis/edi, rubdos/edi, sanube/edi, saxomanu/edi, sbejaoui/edi, sebalix/edi, shine-it/edi, simahawk/edi, smkerz/edi, ssisoftwaresolutions/edi, steingabelgaard/edi, sunflowerit/edi, tarteo/edi, tegin/edi, tirma-sa/edi, vrenaville/edi, westlyou/edi, yogesh-serpentcs/edi, yucer/edi, and yvaucher/edi

<h1 class="title">Account Invoice Import Invoice2data</h1> <p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/edi/tree/12.0/account_invoice_import_invoice2data"><img alt="OCA/edi" src="https://img.shields.io/badge/github-OCA%2Fedi-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/edi-12-0/edi-12-0-account_invoice_import_invoice2data"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/226/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p> <p>This module is an extension of the module <em>account_invoice_import</em>: it adds support for regular PDF invoices i.e. PDF invoice that don't have an embedded XML file. It uses the <a class="reference external" href="https://github.com/invoice-x/invoice2data">invoice2data library</a> which takes care of extracting the text of the PDF invoice, find an existing invoice template and execute the invoice template to extract the useful information from the invoice.</p> <p>To know the full story behind the development of this module, read this <a class="reference external" href="http://www.akretion.com/blog/akretions-christmas-present-for-the-odoo-community">blog post</a>.</p> <p><strong>Table of contents</strong></p> <div class="contents local topic" id="contents"> <ul class="simple"> <li><a class="reference internal" href="#installation" id="id1">Installation</a></li> <li><a class="reference internal" href="#configuration" id="id2">Configuration</a></li> <li><a class="reference internal" href="#bug-tracker" id="id3">Bug Tracker</a></li> <li><a class="reference internal" href="#credits" id="id4">Credits</a><ul> <li><a class="reference internal" href="#authors" id="id5">Authors</a></li> <li><a class="reference internal" href="#contributors" id="id6">Contributors</a></li> <li><a class="reference internal" href="#maintainers" id="id7">Maintainers</a></li> </ul> </li> </ul> </div> <a name="installation"></a> <h2><a class="toc-backref" href="#id1">Installation</a></h2> <p>This module requires the Python library <em>invoice2data</em> available on <a class="reference external" href="https://github.com/invoice-x/invoice2data">Github</a> with a version &gt;= 0.2.74 (February 2018).</p> <p>To install the latest version of this library, run:</p> <pre class="code"> <code class="code">sudo pip3 install --upgrade invoice2data</code> </pre> <p>If you use Ubuntu 16.04 LTS or higher, you can use the pdftotext version 0.41.0 that is packaged in the distribution:</p> <pre class="code"> <code class="code">sudo apt install poppler-utils</code> </pre> <p>If you want the invoice2data library to fallback on OCR if the PDF doesn't contain text (only a very small minority of PDF invoices are image-based and require OCR), you should also install <a class="reference external" href="http://www.imagemagick.org/">Imagemagick</a> (to get the <em>convert</em> utility to convert PDF to TIFF) and <a class="reference external" href="https://github.com/tesseract-ocr/tesseract">Tesseract OCR</a> :</p> <pre class="code"> <code class="code">sudo apt install imagemagick tesseract-ocr</code> </pre> <p>If you want to use custom invoice templates for the invoice2data lib (in addition to the templates provided by the invoice2data lib), you should add a line in your Odoo server configuration file such as:</p> <pre class="code"> <code class="code">invoice2data_templates_dir = /opt/invoice2data_local_templates</code> </pre> <p>and store your invoice templates in YAML format (<em>.yml</em> extension) in the directory that you have configured above. If you add invoice tempates in this directory, you don't have to restart Odoo, they will be used automatically on the next invoice import.</p> <p>If you want to use only your custom invoice templates and ignore the templates provided by the invoice2data lib, you should have in your Odoo server configuration file:</p> <pre class="code"> <code class="code">invoice2data_templates_dir = /opt/invoice2data_local_templates invoice2data_exclude_built_in_templates = True</code> </pre> <p>French users should also install the module <em>l10n_fr_business_document_import</em> available in the <a class="reference external" href="https://github.com/OCA/l10n-france/">French localization</a>.</p> <a name="configuration"></a> <h2><a class="toc-backref" href="#id2">Configuration</a></h2> <p>Go to the form view of the supplier and configure it with the following parameters:</p> <ul class="simple"> <li><em>Is a Vendor</em> is True</li> <li>the <em>VAT</em> is set (the VAT number is used by default when searching the supplier in the Odoo partner database)</li> <li>in the <em>Invoicing</em> tab, create an <em>Invoice Import Configuration</em>.</li> </ul> <p>For the PDF invoice of your supplier that don't have an embedded XML file, you will have to create a <a class="reference external" href="https://github.com/invoice-x/invoice2data/tree/master/src/invoice2data/extract/templates">template file</a> in YAML format in the invoice2data Python library. It is quite easy to do ; if you are familiar with <a class="reference external" href="https://docs.python.org/2/library/re.html">regexp</a>, it should not take more than 10 minutes for each supplier.</p> <p>Here are some hints to help you add a template for your supplier:</p> <ul class="simple"> <li>Take <a class="reference external" href="https://github.com/invoice-x/invoice2data/blob/master/src/invoice2data/extract/templates/fr/fr.free.adsl-fiber.yml">Free SAS template file</a> as an example. You will find a sample PDF invoice for this supplier under invoice2data/test/pdfs/2015-07-02-invoice_free_fiber.pdf</li> <li>Try to run the invoice2data library manually on the sample invoice of Free:</li> </ul> <pre class="code"> <code class="code">% python -m invoice2data.main --debug invoice2data/test/pdfs/2015-07-02-invoice_free_fiber.pdf</code> </pre> <p>On the output, you will get first the text of the PDF, then some debug info on the parsing of the invoice and the regexps, and, on the last line, you will have the dict that contain the result of the parsing.</p> <ul class="simple"> <li>if the VAT number of the supplier is present in the text of the PDF invoice, I think it's a good idea to use it as the keyword. It is a good practice to add 2 other keywoards: one for the language (for example, match on the word <em>Invoice</em> in the language of the invoice) and one for the currency, so as to match only the invoices of that supplier in this particular language and currency.</li> <li>the list of <em>fields</em> should contain the following entries:<ul> <li>'vat' with the VAT number of the supplier (if the VAT number of the supplier is not in the text of PDF file, add a 'partner_name' key, or, if the supplier is French and the module <em>l10n_fr_business_document_import</em> is installed, add a 'siren' key)</li> <li>'amount' ('amount' is the total amount with taxes)</li> <li>'amount_untaxed' or 'amount_tax' (one or the other, no need for both)</li> <li>'date': the date of the invoice</li> <li>'invoice_number'</li> <li>'date_due', if this information is available in the text of the PDF file.</li> </ul> </li> </ul> <a name="bug-tracker"></a> <h2><a class="toc-backref" href="#id3">Bug Tracker</a></h2> <p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/edi/issues">GitHub Issues</a>. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us smashing it by providing a detailed and welcomed <a class="reference external" href="https://github.com/OCA/edi/issues/new?body=module:%20account_invoice_import_invoice2data%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p> <p>Do not contact contributors directly about support or help with technical issues.</p> <a name="credits"></a> <h2><a class="toc-backref" href="#id4">Credits</a></h2> <a name="authors"></a> <h3><a class="toc-backref" href="#id5">Authors</a></h3> <ul class="simple"> <li>Akretion</li> </ul> <a name="contributors"></a> <h3><a class="toc-backref" href="#id6">Contributors</a></h3> <ul class="simple"> <li>Alexis de Lattre &lt;<a class="reference external" href="mailto:alexis.delattre&#64;akretion.com">alexis.delattre&#64;akretion.com</a>&gt;</li> </ul> <a name="maintainers"></a> <h3><a class="toc-backref" href="#id7">Maintainers</a></h3> <p>This module is maintained by the OCA.</p> <a class="reference external image-reference" href="https://odoo-community.org"><img alt="Odoo Community Association" src="https://odoo-community.org/logo.png" /></a> <p>OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use.</p> <p>This module is part of the <a class="reference external" href="https://github.com/OCA/edi/tree/12.0/account_invoice_import_invoice2data">OCA/edi</a> project on GitHub.</p> <p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>