node-red-contrib-odoo-xmlrpc-with-filters 0.0.5
Odoo XMLRPC API client nodes for Node Red
node-red-contrib-odoo-xmlrpc
A set of nodes for making calls to the Odoo XML-RPC API.
Installation
Assuming that you have Node-RED already installed.
You can install this module directly from the palette of Node-RED or using the other official methods, by searching for "node-red-contrib-odoo-xmlrpc-with-filters".
macOS and Linux
From your terminal:
# Go to the folder where your Node-RED plugins would be installed.
cd ~/.node-red
# Install the plugin using the following command
npm install node-red-contrib-odoo-xmlrpc-with-filters
Windows
From cmd:
# Go to the folder where your Node-RED plugins would be installed. Create it if it doesn't exist
cd %userprofile%
mkdir .node-red
cd .node-red
# Install the plugin using the following command
npm install node-red-contrib-odoo-xmlrpc-with-filters
What if a message "No git binary found in $PATH" appears?
Well, you'd need to download and install git. You might then need to close & re-open your terminal. 😕
What if I already installed the original node-red-contrib-odoo-xmlrpc module?
- Export your existing flows (just in case) and close the Node-RED server/application
- Delete the "node-red-contrib-odoo-xmlrpc" folder from ~/.node-red/node_modules/
- Install the "node-red-contrib-odoo-xmlrpc-with-filters" module from the palette
- Restart the Node-RED application
- Load/create your flows, if necessary
That should be it.
Usage
Documentation of each node is found in the "info" tab in the Node-RED Flow editor.
See Odoo Web Service API for more information.
Example
Still, if you are new to Node-RED or Odoo, here is a simple example showing you how to read quotes/draft invoices and logging them to the debug tab of Node-RED:
First node: The first node is an "inject" node, that will be used to trigger/start the Flow
Second node:
The second node is a "function" node, that we will used to specify conditions in our Odoo query (by adding attributes to the msg
object). In this example, we wrote a function (see screenshot below) to filter Odoo records and keep only invoice drafts (first line of the function; format is described in the Odoo documentation). We also specified that we want to skip the first result from the answer (second line of the function), and that we want to keep only 2 records afterwards. At the end, don't forget to return msg
to pass along your query settings to the next node. Note that this node is not necessary, but rather useful if you want to perform precise searches on Odoo's data. Each of msg.filters
, msg.offset
and msg.limit
are optional parameters.
Third node:
The third node is a "odoo-xmlrpc-search-read" node, that actually sends the query to Odoo and waits for a response. You have specify the Odoo connection settings (the "pencil" button) and the data model from which you want to read (in this example: sale.order
)
Connection settings:
Fourth node:
The fourth node is a simple "debug" node, that will by default write the contents of msg.payload
(which, in this case and at this stage, will be the response from the previous "odoo-xmlrpc-search-read" node)
Note
This is currently still a work in progress. As you may see not all the API functionality has been covered yet.
Patches welcome.
Orignally written by Ross Golder. Improved by Ahmad Benmrad.