In this article, we'll show you how to integrate Eden AI's Invoice parser API into an Odoo Module to help streamline your financial operations and free up time for more important tasks. The same process applies if you want to include other features like : Image tagging, Explicit content detection, Text analysis and many more AI APIs we offer.
For the tutorial, it's important to have the Odoo server up and running on your machine.
Eden AI was created for no-coders having difficulties with choosing the right AI provider and/or integrating several APIs. Managing multiple accounts for each app can be a tough job, but with Eden AI, you can connect and manage all your APIs on a single account.
Since some AI providers can be complex to use, we wanted to simplify the “no code” part and make AI available to as many people as possible.
Eden AI allows you to solve multiple AI tasks on Odoo:
Just like Receipt and Resume Parsing, Invoice Parsing is a tool powered by OCR to extract and digitalize meaningful data, Computer Vision to identify structure of the document, and NLP techniques to pin down the fields. Invoice parser technology extracts key information from an invoice (.pdf, .png or .jpg format) such as the invoice ID, total amount due, invoice date, customer name, etc.
Invoice Processing implies the necessity of software and technology to automate the processing and management of invoices. It includes tasks such as capturing invoice data, validating it in comparison to purchase orders, and routing it for approval, payment and archiving. The goal of AI in invoice processing is to improve efficiency, accuracy, and speed in handling invoices without any human intervention.
Get started by signing in to Eden AI! Don't have an account? No worries, we're giving away $10 when you register. Once you're in, a world of possibilities opens up, including integrating with platforms like Salesforce.
First of all, you need to activate the Invoicing module (technical name: "account"). If you don’t find it in the menu, type “Invoicing” in the search bar above:
Once your invoicing module has been activated, you'll need to customize (or extend) it in order to use the Eden Invoice parser API.
Add a module called "invoice_parsing" to your custom add-ons and ensure that you set up the correct folder structure. This should be sufficient for now.
Also add the relevant details in your manifest.py file:
You should now activate your new custom module:
Note: You will have to remove the “Apps” filter in the search bar since we set "application" to False in the manifest.py file.
Refer to the folder structure shared above. In the models directory create these files:
Similarly, in the views directory create the following file:
The folder structure should now look (something) like this:
Paste the following code in your “models/eden_invoicing.py” file:
Likewise, paste the following code in the “views/eden_invoicing.xml” file:
Basically, in both of these cases we are inheriting the default Odoo invoicing in order to add our changes for integrating Eden’s Invoice Parsing API.
Note: As you can see, the name of the button “eden_api_button” matches with the method name in the python file above it i.e., “def eden_api_button(self):...”
Then, you need to add the path of the view in __manifest__.py and import the model in order to make the changes in the module accessible to Odoo:
Also, add the following lines in the __init__.py file of the invoice_parsing module and models directory respectively:
Now, go back to your “invoice_parsing” module in the Apps list and upgrade the module again.
Afterward, when you open the Invoicing form view, you will notice the following button:
Eventually, this button (i.e. Eden Parser) will enable us to upload a file and save it as a record on Odoo.
However, from now on, we’ll direct our focus on the API itself.
The next step is to integrate the Eden-AI API with the button we created in the last section. The goal here is to trigger the Eden AI API on the click of that button.
First, create a file in the models directory with the name “eden_ai_api.py”.
In the newly created file, copy the following code:
After pasting the provided code, it's essential to replace the placeholder "Your-API-Key" with your actual API key, and also update the path to your file by replacing "/path/to/invoice.pdf" with the correct file path.
Now, going back to the "eden_invoicing.py" file, call the "main" function from the above script. Go back to the "eden_api_button" method that we defined above. Modify the method to this:
Now that you have called the "eden_ai_api" script in your button method, restart your server and upgrade your custom module from the Apps menu. Finally, return to the location where the button was initially placed to continue with the next steps:
Click the “EDEN PARSER” button and check your logs in PyCharm, you will see a dictionary printed:
The screenshot below shows that your invoice has been successfully parsed by the Eden-AI invoice parsing API:
Here’s a summary of the steps you need to follow in order to be able to upload file from device:
2. Next, you need to create a component called Eden File Uploader, and provide all the definitions. In this case, you will be extending the base “FileUploader” Component functionality. You can find a sample code snippet in the same file:
Note: These code snippets will only act as a base for your own custom buttons and API functionality. You may have to work with controllers and pure JS too.
In case you didn’t understand what happened above, note the following points:
For now, this was just a simple flow of how integration with EdenAI API shall work. You can extend this flow to generate reports or automate your accounting/invoicing pipelines.
In this tutorial we have successfully integrated the EdenAI API with Odoo. You can use this API for different purposes like automating and streamlining your invoicing pipelines. Eden AI’s invoice parsing API will help you in swift parsing and transfer of data between modules in Odoo.
If you're interesting in more integration tools, have a look at our step-by-step tutorials on how to bring AI to your application with Power Apps, Zapier, Google App Script, Retool, Make, Dataiku, IFTTT, and n8n.