Community mailing list archives

community@mail.odoo.com

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

by
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.
  odoo.search('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 <abdul.bsse1399@gmail.com> wrote:
Hi,
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++) {
        ids.push(i);
    }
    var params = {
        ids,
        fields: ['name', 'email']

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

        console.log(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..
regards
Abdul Qudoos Mehdi

_______________________________________________
Mailing-List: https://www.odoo.com/groups/community-59
Post to: mailto:community@mail.odoo.com
Unsubscribe: https://www.odoo.com/groups?unsubscribe