This repository was archived by the owner on Jun 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
47 lines (44 loc) · 1.57 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//Add package
const OdooApi = require('./OdooApi.js');
//Create instance of the scraper
var instance = new OdooApi({
"nameSuffix": "-test", // used for log
"callQueueTimer": 250, // processes a request every 250ms
"maxRecordsPerCall": 200, //how many records max requested per query, if you query more, it will be fetched recursively
"url": "odoo.com", // domain of your odoo instance
"port": 80, //port of your odoo instance
"protocol": "http", //protocol used for odoo instance
"db": 'TEST_DB', //db of your odoo instance
"username": "username", //user to use
"password": "password" //pass for this user
});
//test function
async function test() {
try {
//get models
var results = await instance.getModelByFilters(
'sale.order', //data model
[], //filters for search
['id', 'name', 'state'], //fields to retrieve
0, //offset for records
2, //limit of records to pull
false //sorting
);
console.log(results);
var results = await instance.getModelByFilters(
'mail.message', //data model
[
['message_type', '=', 'comment'],
['channel_ids', '=', 49],
], //filters for search
['author_id', 'date', 'body', 'message_type', 'channel_ids'], //fields to retrieve
0, //offset for records
2, //limit of records to pull
'date desc' //sorting
);
console.log(results);
} catch (err) {
console.log(err);
}
}
test();