Package: odoo14-addon-account-invoice-import-simple-pdf
This module is an extension of the moduleaccount_invoice_import: it adds support for simple PDF invoices i.e. PDF invoice that don’t have an embedded XML file. This module has been developped to solve the drawbacks of the OCA moduleaccount_invoice_import_invoice2data; its advantages are the following:Possibility to add support for a new vendor without developper skills: the accountant can do it!Adding support for a new vendor is faster.More tolerance on vendor invoice layout changes.Easier to install.With this module, you can import all the invoices that you were able to import with the moduleaccount_invoice_import_invoice2data. In fact, this module uses the same design when importing a PDF vendor bill:raw text extraction of the PDF file,identify the partner using the VAT number (if the VAT number is present in the raw text extraction) or some keywords,use regular expressions (regex) to extract the data needed to create the vendor bill in Odoo (single line configuration).The main difference with the OCA moduleaccount_invoice_import_invoice2datais that the regular expressions are auto-generated from the configuration made by the user in Odoo. No need to be a regex expert! But you can still write regex to extract some fields for some very specific needs.The module can extract the following fields:Total Amount with taxesTotal Untaxed AmountTotal Tax AmountInvoice DateDue DateStart DateEnd DateInvoice NumberDescription (for that field, you have to write a regex)In this list, only 3 fields are required:Invoice Date2 out of the 3 Amount fields (the 3rd can be deducted from the 2 others: Total Amount = Total Untaxed + Total Tax)To take advantage of the fieldsStart DateandEnd Date, you need the OCA moduleaccount_invoice_start_end_datesfrom theaccount-closingproject.To know the full story behind the development of this module, readAkretion’s blog post.Table of contentsInstallationInstall PyMuPDFInstall pdftotext python libInstall pdftotext command lineInstall pdfplumberInstall pypdfOther requirementsConfigurationBug TrackerCreditsAuthorsContributorsMaintainersInstallationThe most important technical component of this module is the tool that converts the PDF to text. Converting PDF to text is not an easy job. As outlined in thisblog post, different tools can give quite different results. The best results are usually achieved with tools based on a PDF viewer, which exclude pure-python tools. But pure-python tools are easier to install than tools based on a PDF viewer. It is important to understand that, if you change the PDF to text tool, you will certainly have a slightly different text output, which may oblige you to update the field extraction rule, which can be time-consuming if you have already configured many vendors.The module supports 5 different extraction methods:PyMuPDFwhich is a Python binding forMuPDF, a lightweight PDF toolkit/viewer/renderer published under the AGPL licence by the companyArtifex Software.pdftotext python library, which is a python binding for the pdftotext tool.pdftotext command line tool, which is based onpoppler, a PDF rendering library used byxpdfandEvince(the PDF reader ofGnome).pdfplumber, which is a python library built on top the of the python librarypdfminer.six. pdfplumber is a pure-python solution, so it’s very easy to install on all OSes.pypdf, which is one of the most common PDF lib for Python. pypdf is a pure-python solution, so it’s very easy to install on all OSes.PyMuPDF and pdftotext both give a very good text output. So far, I can’t say which one is best. pdfplumber and pypdf often give lower-quality text output, but their advantage is that they are pure-Python librairies, so you will always be able to install it whatever your technical environnement is.You can choose one extraction method and only install the tools/libs for that method.Install PyMuPDFInstall it via pip:sudo pip3 install --upgrade pymupdfBeware thatPyMuPDFis not a pure-python library: it uses MuPDF, which is written in C language. If a python wheel for your OS, CPU architecture and Python version is available on pypi (check thelist of PyMuPDF wheelson pypi), it will install smoothly. Otherwize, the installation via pip will require MuPDF and all its development libs to compile the binding.Install pdftotext python libTo installpdftotext python lib, run:sudo apt install build-essential libpoppler-cpp-dev pkg-config python3-devand then install the lib via pip:sudo pip3 install --upgrade pdftotextOn OSes other than Debian/Ubuntu, follow the instructions on theproject page.Install pdftotext command lineTo installpdftotext command line, run:sudo apt install poppler-utilsInstall pdfplumberTo install thepdfplumberpython lib, run:sudo pip3 install --upgrade pdfplumberInstall pypdfTo install thepypdfpython lib, run:sudo pip3 install --upgrade pypdfOther requirementsThis module also requires the following Python libraries:regexwhich is backward-compatible with theremodule of the Python standard library, but has additional functionalities.dateparserwhich is a powerful date parsing library.The dateparser lib depends itself on regex. So you can install these Python libraries via pip with the following command:sudo pip3 install --upgrade dateparserThe dateparser lib is not compatible with all regex lib versions. As of September 2022, theversion requirementdeclared by dateparser for regex is!=2019.02.19, !=2021.8.27, <2022.3.15. So the latest version of regex which is compatible with dateparser is2022.3.2. To know the version of regex installed in your environment, run:sudo pip3 show regexTo force regex to version 2022.3.2, run:sudo pip3 install regex==2022.3.2ConfigurationBy default, for the PDF to text conversion, the module tries the different methods in the order mentionned in the INSTALL section: it will first try to usePyMuPDF; if it fails (for example because the lib is not properly installed), then it will try to use thepdftotext python lib, if that one also fails, it will try to usepdftotext command lineand, if it also fails, it will eventually trypdfplumber. If none of the 4 methods work, Odoo will display an error message.If you want to force Odoo to use a specific text extraction method, go to the menuConfiguration > Technical > Parameters > System Parametersand create a new System Parameter:Key:invoice_import_simple_pdf.pdf2txtValue: select the proper value for the method you want to use:pymupdfpdftotext.libpdftotext.cmdpdfplumberpypdfIn this configuration, Odoo will only use the selected text extraction method and, if it fails, it will display an error message.You will find a full demonstration about how to configure each Vendor and import the PDF invoices in thisscreencast.Bug TrackerBugs are tracked onGitHub Issues.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomedfeedback.Do not contact contributors directly about support or help with technical issues.CreditsAuthorsAkretionContributorsAlexis de Lattre <alexis.delattre@akretion.com>MaintainersThis module is maintained by the OCA.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.Currentmaintainer:This module is part of theOCA/ediproject on GitHub.You are welcome to contribute. To learn how please visithttps://odoo-community.org/page/Contribute.