Search 1.9 billion lines of Odoo code on GitHub

account_invoice_import_invoice2data

Author: Akretion,Odoo Community Association (OCA)
License: AGPL-3
Branch: 8.0-ocabot-merge-pr-211-by-bealdav-bump-minor
Repository: abihedia/edi-1
Dependencies: account_invoice_import
Languages: PO File (26, 8.6%), Python (188, 62.0%), XML (32, 10.6%), and reStructuredText (57, 18.8%)
Other branches: 10.0, 12.0, 8.0, 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

<a class="reference external image-reference" 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.svg"> </a> <a name="account-invoice-import-invoice2data"></a> <h2>Account Invoice Import Invoice2data</h2> <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> <a name="installation"></a> <h3>Installation</h3> <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>.</p> <p>To install the right version of the library, run:</p> <pre class="code"> <code class="code">sudo pip install git+https://github.com/invoice-x/invoice2data.git</code> </pre> <p>In order to use a recent version of invoice2data on Odoo v8, you need an Odoo v8 dated after January 29th 2016, so that it contains <a class="reference external" href="https://github.com/odoo/odoo/commit/edeb5a8c0fb5c837364f1d92db731f89824bb28a">this fix</a> which fixes <a class="reference external" href="https://github.com/odoo/odoo/issues/10670">this bug</a>.</p> <p>The invoice2data library requires the latest version of the <em>pdftotext</em> utility, which is not yet packaged in Debian/Ubuntu. So you should download it from <a class="reference external" href="ftp://ftp.foolabs.com/pub/xpdf/xpdfbin-linux-3.04.tar.gz">the FTP server of Foolabs</a> then uncompress it and copy the file <em>bin64/pdftotext</em> to <em>/usr/local/bin</em>.</p> <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-get 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_invoice_import</em> available in the <a class="reference external" href="https://github.com/OCA/l10n-france/">French localization</a>, cf <a class="reference external" href="https://github.com/OCA/l10n-france/pull/55">this PR</a>.</p> <a name="configuration"></a> <h3>Configuration</h3> <p>Go to the form view of the supplier and configure it with the following parameters:</p> <ul class="simple"> <li><em>is a Company ?</em> is True</li> <li><em>Supplier</em> is True</li> <li>the <em>TIN</em> (i.e. VAT number) is set (the VAT number is used by default when searching the supplier in the Odoo partner database)</li> <li>in the <em>Accounting</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_invoice_pdf_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="usage"></a> <h3>Usage</h3> <p>Refer to the usage section of the module <em>account_invoice_import</em>.</p> <a class="reference external image-reference" href="https://runbot.odoo-community.org/runbot/226/8.0"><img alt="Try me on Runbot" src="https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas" /></a> <a name="bug-tracker"></a> <h3>Bug Tracker</h3> <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 feedback.</p> <a name="credits"></a> <h3>Credits</h3> <a name="contributors"></a> <h4>Contributors</h4> <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="maintainer"></a> <h4>Maintainer</h4> <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>This module is maintained by the OCA.</p> <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>To contribute to this module, please visit <a class="reference external" href="https://odoo-community.org">https://odoo-community.org</a>.</p>