odoo-xmlrpc icon indicating copy to clipboard operation
odoo-xmlrpc copied to clipboard

Multiple Connection when doing different api xmlrpc calls?

Open diezcode opened this issue 3 years ago • 1 comments

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

diezcode avatar May 06 '21 05:05 diezcode

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();

fnaquira avatar Jul 07 '23 20:07 fnaquira