Search 1.9 billion lines of Odoo code on GitHub

sale_order_import_invoice2data

Author: Sunflower IT,Therp BV,Odoo Community Association (OCA)
License: AGPL-3
Branch: 14.0
Repository: EssentNovaTeam/edi
Dependencies: document, invoice2data_template, and sale_order_import
Languages: Python (202, 70.4%), XML (36, 12.5%), and reStructuredText (49, 17.1%)
Other repositories: gfcapalbo/edi, hbrunn/edi, and sunflowerit/edi

<h1 class="title">Sale Order Import Invoice2data</h1> <p>This module is an extension of the module <em>sale_order_import</em>: it adds support for regular PDF Sale Order i.e. PDF Sale Order that don't have an embedded XML file. It uses the <a class="reference external" href="https://github.com/m3nu/invoice2data">invoice2data library</a> which takes care of extracting the text of the PDF Sale Order, 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> <h2>Installation</h2> <p>This module requires the Python library <em>invoice2data</em>.</p> <p>To install it, run:</p> <pre class="code"> <code class="code">sudo pip install invoice2data</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 <em>pdftotext</em> utility, which you can install on Debian/Ubuntu with:</p> <pre class="code"> <code class="code">sudo apt-get install poppler-utils</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 sale order 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 sale order 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> <h2>Configuration</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 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/m3nu/invoice2data/blob/master/invoice2data/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/m3nu/invoice2data/blob/master/invoice2data/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 Sale Order, 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: * '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) * 'amount' ('amount' is the total amount with taxes) * 'amount_untaxed' or 'amount_tax' (one or the other, no need for both) * 'date': the date of the invoice * 'invoice_number' * 'date_due', if this information is available in the text of the PDF file.</li> </ul> <a name="credits"></a> <h2>Credits</h2> <a name="contributors"></a> <h3>Contributors</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> <li>Tom Blauwendraat &lt;<a class="reference external" href="mailto:info&#64;sunflowerweb.nl">info&#64;sunflowerweb.nl</a>&gt;</li> <li>Holger Brunn &lt;<a class="reference external" href="mailto:hbrunn&#64;therp.nl">hbrunn&#64;therp.nl</a>&gt;</li> <li>Terence Nzaywa &lt;<a class="reference external" href="mailto:terrence&#64;sunflowerweb.nl">terrence&#64;sunflowerweb.nl</a>&gt;</li> </ul> <a name="maintainer"></a> <h3>Maintainer</h3> <p>This module is maintained by the OCA.</p>