odoo-xmlrpc
odoo-xmlrpc copied to clipboard
Multiple Connection when doing different api xmlrpc calls?
Is there a way to do only 1 connect and then use the same connection for all api calls? If you do multiple odoo.connect calls the odoo service shows erro because to many connections are in the pool.
Any Information on this?
Thanks
I keep it as a constant, so only one connection. I personally use a connection file:
const Odoo = require('odoo-xmlrpc');
module.exports = () => {
return new Promise((resolve, reject) => {
const odoo = new Odoo({
url: process.env.ADMIN_SERVER,
db: process.env.ADMIN_DB,
port: process.env.ADMIN_PORT,
username: process.env.ADMIN_USER,
password: process.env.ADMIN_PWD
});
odoo.connect(function (err) {
if (err) {
reject(err);
}
resolve(odoo);
});
});
};
This way, I only have to call it once and use wherever on the project:
const odoo = await odooAdmin();