taskstemplates
feedback & roadmap30-day trialbook a demo

Odoo invoices to UBL with SFTP upload

This template retrieves outstanding invoices from Odoo, transforms them into UBL standard XML format, and uploads the resulting XML files to an SFTP server.

Template

Prerequisites

This template assumes that the following prerequisites are in place:

  • The Odoo user has permissions to access data through the API.
  • The SFTP user has write permissions to upload files.

Implementation and Usage Notes

The template makes a request for base invoice data located in Odoo's account.move model, as well as additional requests for supplementary data (e.g. customer information, banking details, and invoice lines) in other models. The data is mapped and converted to XML, which is transformed into UBL format using XSLT. Each file is then written to the SFTP server, named with the prefix 'invoice-' followed by the invoice ID from Odoo. If the file already exists in the directory, it will be overwritten. This can be changed in the SFTP Write task's settings.

The template can be customized depending on which data is needed for UBL invoices. The base request's arguments, fields and result limit can be adjusted through process variables, and other additional requests can be added in similar manner as the existing ones. While mapping and transforming the data to UBL, note that the select values in the XMLT need to match the mapped ones.

Error Handling

This template does not handle transient errors separately. The tasks for Odoo requests are checked for errors. If uploading a single invoice fails, the process continues to the next one, and the error is added to the result message.

Template Process Variables

OdooUrl The address of the Odoo instance.
OdooUsername Odoo user.
OdooPassword 🗝Odoo user's password.
OdooDatabase The name of the Odoo instance.
OdooArguments List of arguments to pass to the base Odoo request, to filter invoice data. Default gives outgoing invoices with the status "posted". Syntax: [["field_name", "evaluator", "value"], ["field_name", "evaluator", "value"]].
OdooFields List of fields to pass to the base Odoo request, to determine which data columns to get.
OdooInvoiceLimit Maximum value to pass to the base Odoo request, to limit the amount of resulting invoices.
TargetServerAddress The address of the SFTP server.
TargetServerUser SFTP server user.
TargetServerPassword 🗝SFTP server user's password.
TargetDirectory SFTP server's target directory, to which the invoices are uploaded.