Community mailing list archives

Re: How to fetch only employee data using node api?

Hardikgiri Goswami
- 06/22/2016 10:53:21
Hi Abdul,

You can use following way :

var Odoo = require('node-odoo');

var odoo = new Odoo({
  host: 'localhost',
  port: 4569,
  database: '4yopping',
  username: 'admin',
  password: '4yopping'

// Connect to Odoo
odoo.connect(function (err) {
  if (err) { return console.log(err); }
  // Get ids of Employee
  var params = {[]}; // domain will goes here. right now it is empty.'hr.employee', params, function (err, emp_ids) {
    if (err) { return console.log(err); }

    console.log('employee idss', emp_ids);
So above code will get you Ids of employee and after that you can use odoo.get("hr.employee", params, callback).

On Wed, Jun 22, 2016 at 4:02 PM Abdul Qudoos <> wrote:
I am using Node-odoo api to fetching data from odoo in json format, but I have two issues in it.
my code is

// Connect to Odoo
odoo.connect(function (err) {
    if (err) {
        return console.log(err);
    var ids = []
        //////////////////////// total no. contacts for testing
    for (var i = 1; i <= 100000; i++) {
    var params = {
        fields: ['name', 'email']

    }; //params
    odoo.get('res.partner', params, function (err, partners) {
        if (err) {
            return console.log(err);
        obj = partners;

        jsonfile.writeFileSync(file, obj)

    }); //get

by using ''res.partner" I also get junk data, because I don't know the employee record ids, thats why I ended loop to 100000 only for testing,
How can I get employee ids and in which model.
I don't know odoo tecnically..
Abdul Qudoos Mehdi

Post to: