odoo json rpc.docx

loufgxrtvct 240 views 22 slides Jul 25, 2022
Slide 1
Slide 1 of 22
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22

About This Presentation

odoo jsonrpc for integration with odoo


Slide Content

Using jsonrpc to obtain data from odoo

1-login to odoo to obtain the session id

- you will need to write this command in the terminal:


curl -H "content-type:application/json" -X POST -d
'{"jsonrpc":"2.0","params":{"db":"<DATABASE>","login":"<USER
NAME>","password":"<PASSWORD>"}}' http://<ip>:<port>/web/session/authenticate

note the following parameters in this command


<DATABASE> : is the name of the database to connect
<USER NAME>: the odoo user you will use to login
<PASSWORD>: the password of the odoo user
<ip> : the ip address or the host name of the odoo server
<port> :the configured port for odoo




example :-


curl -H "content-type:application/json" -X POST -d
'{"jsonrpc":"2.0","params":{"db":"test","login":"admin","password":"admin"}}'
http://localhost:8069/web/session/authenticate





the result is

{"jsonrpc": "2.0", "id": null, "result": {"username": "admin", "currencies": {"1": {"digits": [69, 2],
"position": "after", "symbol": "\u20ac"}, "3": {"digits": [69, 2], "position": "before", "symbol":
"$"}}, "uid": 1, "db": "test", "is_admin": true, "server_version_info": [10, 0, 0, "final", 0, ""],
"server_version": "10.0", "user_context": {"lang": "en_US", "tz": "Europe/Brussels", "uid": 1},
"web.base.url": "http://localhost:8069", "name": "Administrator", "partner_id": 3, "web_tours":
[], "company_id": 1, "session_id": "63bb2b154d4b79b3e7531351eea8e8c062c9de26",
"is_superuser": true, "user_companies": false}}






a clarified version of json payload data of the result

{u'company_id': 1,
u'currencies': {u'1': {u'digits': [69, 2],
u'position': u'after',
u'symbol': u'\u20ac'},
u'3': {u'digits': [69, 2],
u'position': u'before',
u'symbol': u'$'}},
u'db': u'test',
u'is_admin': True,
u'is_superuser': True,
u'name': u'Administrator',
u'partner_id': 3,
u'server_version': u'10.0',
u'server_version_info': [10, 0, 0, u'final', 0, u''],
u'session_id': u'63bb2b154d4b79b3e7531351eea8e8c062c9de26',
u'uid': 1,
u'user_companies': False,
u'user_context': {u'lang': u'en_US',
u'tz': u'Europe/Brussels',
u'uid': 1},
u'username': u'admin',
u'web.base.url': u'http://localhost:8069',
u'web_tours': []}}



note the session_id in the result (blue font) it is "63bb2b154d4b79b3e7531351eea8e8c062c9de26"

copy it and it will be used in all other commands


2-How to get information about product template

-the command

curl -H "content-type:application/json" -H "Cookie: session_id=<seessin_id>" -X POST -d
'{"jsonrpc":"2.0","mehtod":"call","params":{"model": "product.template", "fields": ["<fields>"],
"domain": ["<domain>"]}}' http://<ip>:<port>/web/dataset/search_read

- for clarification to the json payload data


{"jsonrpc": 2.0,
"mehtod": "call",
"params": {"domain": ["<domain>"],
"fields": ["<fields>"],
"model": "product.template"}}




note the parameter in the commnad


<seessin_id>: is the session_id you get when you login to odoo
<fields> : the fields of the model you need to get data
<domain> : the domain to specify which records you want search
<ip> : the ip address or the host name of the odoo server
<port> :the configured port for odoo
note that the "model": "product.template" that for the model product.template


example using this command:



curl -H "content-type:application/json" -H "Cookie:
session_id=63bb2b154d4b79b3e7531351eea8e8c062c9de26" -X POST -d
'{"jsonrpc":"2.0","mehtod":"call","params":{"model": "product.template", "fields":
["name","product_variant_ids"], "domain": []}}' http://localhost:8069/web/dataset/search_read

and the json payload clarified


{"jsonrpc": "2.0",
"mehtod": "call",
"params": {"domain": [],
"fields": ["name","product_variant_ids"],
"model": "product.template"}}


and the result clarified will be

{u'length': 35,
u'records': [{u'id': 14,
u'name': u'Apple In-Ear Headphones',
u'product_variant_ids': [17]},
{u'id': 16,
u'name': u'Apple Wireless Keyboard',
u'product_variant_ids': [19]},
{u'id': 28,
u'name': u'Basic Computer',
u'product_variant_ids': [32]},
{u'id': 33,
u'name': u'Basic Membership',
u'product_variant_ids': []},
{u'id': 11,
u'name': u'Bose Mini Bluetooth Speaker',
u'product_variant_ids': [14]},
{u'id': 21,
u'name': u'Computer Case',
u'product_variant_ids': [25]},
{u'id': 9,
u'name': u'Computer SC234',
u'product_variant_ids': [9]},
{u'id': 2,
u'name': u'Cost-plus Contract',
u'product_variant_ids': [2]},
{u'id': 12,
u'name': u'Custom Computer (kit)',
u'product_variant_ids': [15]},
{u'id': 5,
u'name': u'Datacard',
u'product_variant_ids': [5]},
{u'id': 3,
u'name': u'External Audit',
u'product_variant_ids': [3]},

u'name': u'GAP Analysis Service',
u'product_variant_ids': [7]},
{u'id': 31,
u'name': u'Gold Membership',
u'product_variant_ids': []},
{u'id': 25,
u'name': u'Graphics Card',
u'product_variant_ids': [29]},
{u'id': 22,
u'name': u'HDD SH-1',
u'product_variant_ids': [26]},
{u'id': 34,
u'name': u'Ice Cream',
u'product_variant_ids': [67]},
{u'id': 15,
u'name': u'iMac',
u'product_variant_ids': [18]},
{u'id': 13,
u'name': u'iPad Mini',
u'product_variant_ids': [16]},
{u'id': 10,
u'name': u'iPad Retina Display',
u'product_variant_ids': [10, 11, 12]},
{u'id': 18,
u'name': u'iPod',
u'product_variant_ids': [21, 22]},
{u'id': 27,
u'name': u'Laptop Customized',
u'product_variant_ids': [31]},
{u'id': 26,
u'name': u'Laptop E5023',
u'product_variant_ids': [30]},
{u'id': 29,
u'name': u'Little server',
u'product_variant_ids': [33]},
{u'id': 23,
u'name': u'Motherboard I9P57',
u'product_variant_ids': [27]},
{u'id': 17,
u'name': u'Mouse, Optical',
u'product_variant_ids': [20]},
{u'id': 19,
u'name': u'Mouse, Wireless',
u'product_variant_ids': [23]},
{u'id': 1,
u'name': u'Prepaid Consulting',
u'product_variant_ids': [1]},
{u'id': 24,
u'name': u'Processor Core i5 2.70 Ghz',
u'product_variant_ids': [28]},

u'name': u'RAM SR5',
u'product_variant_ids': [24]},
{u'id': 30,
u'name': u'Server',
u'product_variant_ids': [34]},
{u'id': 32,
u'name': u'Silver Membership',
u'product_variant_ids': []},
{u'id': 35,
u'name': u'Speaker',
u'product_variant_ids': [68]},
{u'id': 8,
u'name': u'Support Services',
u'product_variant_ids': [8]},
{u'id': 4,
u'name': u'Switch, 24 ports',
u'product_variant_ids': [4]},
{u'id': 6,
u'name': u'Zed+ Antivirus',
u'product_variant_ids': [6]}]}}



every line in the result is a product template and its name and the field prod_variant_ids which
refers to the available variants of this product and all of this variants are a product.product record


3- How to get information about product.product

- use this command

curl -H "content-type:application/json" -H "Cookie: session_id=<session_id>" -X
POST -d '{"jsonrpc":"2.0","mehtod":"call","params":{"model": "product.product",
"fields": ["<fields>"], "domain": ["<domain>"]}}'
http://<ip>:<port>/web/dataset/search_read


the json payload data clarified


{"jsonrpc":"2.0",
"mehtod":"call",
"params":
{"model": "product.product",
"fields": ["<fields>"],
"domain": []}}

note the parameter in the commnad

<seessin_id>: is the session_id you get when you login to odoo
<fields> : the fields of the model you need to get data
<domain> : the domain to specify which records you want search
<ip> : the ip address or the host name of the odoo server
<port> :the configured port for odoo
note that the "model": "product.product" that for the model product.product


example using this command:



curl -H "content-type:application/json" -H "Cookie:
session_id=63bb2b154d4b79b3e7531351eea8e8c062c9de26" -X POST -d
'{"jsonrpc":"2.0","mehtod":"call","params":{"model": "product.product", "fields":
["name","description","type","categ_id","price","weight","barcode","attribute_value_ids"],
"domain": []}}' http://localhost:8069/web/dataset/search_read


the result clarified for this commands


{u'length': 35,
u'records': [{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [2, u'All / Saleable'],
u'description': u'Ice cream can be mass-produced and thus is widely available in
developed parts of the world. Ice cream can be purchased in large cartons (vats and squrounds)
from supermarkets and grocery stores, in smaller quantities from ice cream shops, convenience
stores, and milk bars, and in individual servings from small carts or vans at public events.',
u'id': 67,
u'name': u'Ice Cream',
u'price': 0.0,
u'type': u'product',
u'weight': 1.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 29,
u'name': u'Graphics Card',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],

u'id': 25,
u'name': u'Computer Case',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 34,
u'name': u'Server',
u'price': 0.0,
u'type': u'consu',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 33,
u'name': u'Little server',
u'price': 0.0,
u'type': u'consu',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 32,
u'name': u'Basic Computer',
u'price': 0.0,
u'type': u'consu',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 28,
u'name': u'Processor Core i5 2.70 Ghz',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [1, 3, 5],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 10,
u'name': u'iPad Retina Display',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},

u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 11,
u'name': u'iPad Retina Display',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [3, 2, 5],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 12,
u'name': u'iPad Retina Display',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 14,
u'name': u'Bose Mini Bluetooth Speaker',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': u'Custom computer shipped in kit.',
u'id': 15,
u'name': u'Custom Computer (kit)',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 16,
u'name': u'iPad Mini',
u'price': 0.0,
u'type': u'product',
u'weight': 0.33},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 17,
u'name': u'Apple In-Ear Headphones',

u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 18,
u'name': u'iMac',
u'price': 0.0,
u'type': u'product',
u'weight': 9.54},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 19,
u'name': u'Apple Wireless Keyboard',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 20,
u'name': u'Mouse, Optical',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [1],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 21,
u'name': u'iPod',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [2],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 22,
u'name': u'iPod',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],

u'id': 26,
u'name': u'HDD SH-1',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': u"Custom Laptop based on customer's requirement.",
u'id': 31,
u'name': u'Laptop Customized',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': u'17" Monitor\n4GB RAM\nStandard-1294P Processor\nQWERTY
keyboard',
u'id': 30,
u'name': u'Laptop E5023',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 27,
u'name': u'Motherboard I9P57',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 23,
u'name': u'Mouse, Wireless',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 9,
u'name': u'Computer SC234',
u'price': 0.0,
u'type': u'product',

{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 4,
u'name': u'Switch, 24 ports',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 5,
u'name': u'Datacard',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [5, u'All / Saleable / Software'],
u'description': False,
u'id': 6,
u'name': u'Zed+ Antivirus',
u'price': 0.0,
u'type': u'consu',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 24,
u'name': u'RAM SR5',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [4, u'All / Saleable / Services'],
u'description': u'Example of products to invoice based on cost.',
u'id': 3,
u'name': u'External Audit',
u'price': 0.0,
u'type': u'service',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [6, u'All / Saleable / Physical'],
u'description': False,
u'id': 2,

u'price': 0.0,
u'type': u'service',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [4, u'All / Saleable / Services'],
u'description': u'Example of product to invoice on order.',
u'id': 1,
u'name': u'Prepaid Consulting',
u'price': 0.0,
u'type': u'service',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [1, u'All'],
u'description': False,
u'id': 68,
u'name': u'Speaker',
u'price': 0.0,
u'type': u'product',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [4, u'All / Saleable / Services'],
u'description': u'Example of products to invoice based on delivery.',
u'id': 7,
u'name': u'GAP Analysis Service',
u'price': 0.0,
u'type': u'service',
u'weight': 0.0},
{u'attribute_value_ids': [],
u'barcode': False,
u'categ_id': [4, u'All / Saleable / Services'],
u'description': u'Example of product to invoice based on delivery.',
u'id': 8,
u'name': u'Support Services',
u'price': 0.0,
u'type': u'service',
u'weight': 0.0}]}}



4- Get the relation between products and product.template

- every product.template record in the result have the field product_variants_ids this field refers to a
product.product records and every product of them have the same template but have different
attributes for example if a product.template is about T-shirt with two attributes size and color and
the size attribute has three values small ,medium and large while the color attribute has four values
red, white ,black and green so this will generate twelve different products.

- From the previous results in step number 2 for exmaple the product.template which its name is
iPad Retina Display and its id is 10 {u'id': 10 u'name': u'iPad Retina Display',u'product_variant_ids':
[10, 11, 12]} the product_variant_ids refers to three different products in product.product table its
ids are 10 ,11 and 12 .

- we will make a request for product with id 10 by set a domain that the id is 10

the command will be


curl -H "content-type:application/json" -H "Cookie:
session_id=63bb2b154d4b79b3e7531351eea8e8c062c9de26" -X POST -d
'{"jsonrpc":"2.0","mehtod":"call","params":{"model": "product.product", "fields":
["name","attribute_value_ids"], "domain": [["id","=",10]]}}'
http://localhost:8069/web/dataset/search_read


the result for the previous command will be


{"jsonrpc": "2.0",
"id": null,
"result": {"records": [{"attribute_value_ids": [1, 3, 5], "id": 10, "name": "iPad Retina Display"}],
"length": 1}}

the record contain a field attribute_value_ids which refers to product_attribute_value which is a
value for an attribute

- let’s search for every product_attribute_value and its attribute in the product_attribute_value

curl -H "content-type:application/json" -H "Cookie:
session_id=63bb2b154d4b79b3e7531351eea8e8c062c9de26" -X POST -d
'{"jsonrpc":"2.0","mehtod":"call","params":{"model": "product.attribute.value", "fields":
["name","attribute_id"], "domain": [["id","in",[1,3,5]]]}}'
http://localhost:8069/web/dataset/search_read

- the result will be

{"jsonrpc": "2.0",
"id": null,
"result":
{"records":
[{"attribute_id": [1, "Memory"],
"id": 1,
"name": "16 GB"},
{"attribute_id": [2, "Color"],
"id": 3, "name": "White"},
{"attribute_id": [3, "Wi-Fi"],
"id": 5,

"length": 3}}

- the first attribute value in the result describe the attribute value "16 GB" for the attribute
"Memory"
- the second attribute value in the result dscribe the attribute value "White" for the attribute "Color"
- the third attribute value in the result describe the attribute value "2.4 GHz" for the attribute "Wi-
Fi"

- conclusion the product in product.product which has the id 10 has attributes {color is white
,memory is 16 GB , Wi-Fi is 2.4 GHz}

- likewise for the products with ids 11 and 12

- product with id 11 has the attributes {color is black ,memory is 16 GB , Wi-Fi is 2.4 GHz}
- product with id 12 has the attributes {color is white ,memory is 32 GB , Wi-Fi is 2.4 Ghz}
- the products with ids 10,11 and 12 all have the same product.template with different attributes


5- get informations about product in a different language

-use this command to get information about a product in differnt language


- for example using the same command in step 3 but will change the language context to german to
search for products in german

curl -H "content-type:application/json" -H "Cookie:
session_id=63bb2b154d4b79b3e7531351eea8e8c062c9de26" -X POST -d
'{"jsonrpc":"2.0","mehtod":"call","params":{"model": "product.product", "fields":
["name","description","type","categ_id","price","weight","barcode","attribute_value_ids"],
"domain": [], "context":{"lang":"de_DE" }}}' http://localhost:8069/web/dataset/search_read

- another example for product.template

curl -H "content-type:application/json" -H "Cookie:
session_id=63bb2b154d4b79b3e7531351eea8e8c062c9de26" -X POST -d
'{"jsonrpc":"2.0","mehtod":"call","params":{"model": "product.template", "fields": ["name"],
"domain": [], "context":{"lang":"de_DE"
}}}' http://localhost:8069/web/dataset/search_read


6- get informations about the stock products quantities by the location

-first use this command to get the available products in stocks for all
prodcts in all stock locations

the result will be



{u'id': None,
u'jsonrpc': u'2.0',
u'result': [{u'__domain': [[u'location_id', u'=', 36]],
u'inventory_value': 9900.0,
u'location_id': [36, u'Chic/Stock'],
u'location_id_count': 1,
u'qty': 180.0},
{u'__domain': [[u'location_id', u'=', 15]],
u'inventory_value': 876.0,
u'location_id': [15, u'WH/Stock'],
u'location_id_count': 1,
u'qty': 1.0},
{u'__domain': [[u'location_id', u'=', 19]],
u'inventory_value': 699838.0,
u'location_id': [19, u'WH/Stock/Shelf 1'],
u'location_id_count': 10,
u'qty': 705.0},
{u'__domain': [[u'location_id', u'=', 18]],
u'inventory_value': 61056.0,
u'location_id': [18, u'WH/Stock/Shelf 2'],
u'location_id_count': 3,
u'qty': 40.0}]}


the result contain four different locations with ids [36,15,19,18]

to get iformations for any location for example location with id 19

use this command

http://localhost:8069/web/dataset/search_read



the result will be



{u'id': None,
u'jsonrpc': u'2.0',
u'result': {u'length': 10,
u'records': [{u'id': 1,
u'location_id': [19, u'WH/Stock/Shelf 1'],
u'product_id': [17,
u'[E-COM08] Apple In-Ear Headphones'],
u'qty': 18.0},
{u'id': 2,
u'location_id': [19, u'WH/Stock/Shelf 1'],
u'product_id': [19,
u'[E-COM10] Apple Wireless Keyboard'],
u'qty': 22.0},
{u'id': 5,
u'location_id': [19, u'WH/Stock/Shelf 1'],
u'product_id': [26, u'[HDD-SH1] HDD SH-1'],
u'qty': 39.0},
{u'id': 6,
u'location_id': [19, u'WH/Stock/Shelf 1'],
u'product_id': [16, u'[E-COM07] iPad Mini'],
u'qty': 180.0},
{u'id': 7,
u'location_id': [19, u'WH/Stock/Shelf 1'],
u'product_id': [21, u'[E-COM12] iPod (16 GB)'],
u'qty': 26.0},
{u'id': 8,
u'location_id': [19, u'WH/Stock/Shelf 1'],

u'[LAP-CUS] Laptop Customized'],
u'qty': 80.0},
{u'id': 10,
u'location_id': [19, u'WH/Stock/Shelf 1'],
u'product_id': [20, u'[E-COM11] Mouse, Optical'],
u'qty': 8.0},
{u'id': 11,
u'location_id': [19, u'WH/Stock/Shelf 1'],
u'product_id': [23, u'[M-Wir] Mouse, Wireless'],
u'qty': 10.0},
{u'id': 12,
u'location_id': [19, u'WH/Stock/Shelf 1'],
u'product_id': [24, u'[RAM-SR5] RAM SR5'],
u'qty': 2.0},
{u'id': 13,
u'location_id': [19, u'WH/Stock/Shelf 1'],
u'product_id': [16, u'[E-COM07] iPad Mini'],
u'qty': 320.0}]}}

- from the result the location with id 19 contians 10 different products
1- product '' Apple In-Ear Headphones ''with id 17 and quantity 18
2- product '' pple Wireless Keyboard ''with id 19 and quantity 22
3- product '' HDD SH-1 ''with id 26 and quantity 39
4- product '' iPad Mini ''with id 16 and quantity 180
5- product '' iPod (16 GB) '' with id 21 and quantity 26
6- product '' Laptop Customized ''with id 31 and quantity 80
7- product '' Mouse, Optical ''with id 23 and quantity 8
8- product '' Mouse, Wireless ''with id 23 and quantity 10
9- product '' RAM SR5''with id 24 and quantity 2
10- product '' iPad Mini '' with id 16 and quantity 320


7- get the stock quantity for a product in every stock locations
- use this command

the result will be








{u'id': None,
u'jsonrpc': u'2.0',
u'result': [{u'__domain': [[u'product_id', u'=', 29]],
u'product_id': [29, u'[CARD] Graphics Card'],
u'product_id_count': 2,
u'qty': 17.0},
{u'__domain': [[u'product_id', u'=', 14]],
u'product_id': [14, u'[E-COM05] Bose Mini Bluetooth Speaker'],
u'product_id_count': 1,
u'qty': 8.0},
{u'__domain': [[u'product_id', u'=', 16]],
u'product_id': [16, u'[E-COM07] iPad Mini'],
u'product_id_count': 2,
u'qty': 500.0},
{u'__domain': [[u'product_id', u'=', 17]],
u'product_id': [17, u'[E-COM08] Apple In-Ear Headphones'],
u'product_id_count': 1,
u'qty': 18.0},
{u'__domain': [[u'product_id', u'=', 19]],
u'product_id': [19, u'[E-COM10] Apple Wireless Keyboard'],
u'product_id_count': 1,
u'qty': 22.0},
{u'__domain': [[u'product_id', u'=', 20]],
u'product_id': [20, u'[E-COM11] Mouse, Optical'],
u'product_id_count': 1,
u'qty': 8.0},
{u'__domain': [[u'product_id', u'=', 21]],
u'product_id': [21, u'[E-COM12] iPod (16 GB)'],
u'product_id_count': 1,
u'qty': 26.0},
{u'__domain': [[u'product_id', u'=', 26]],
u'product_id': [26, u'[HDD-SH1] HDD SH-1'],
u'product_id_count': 1,

{u'__domain': [[u'product_id', u'=', 31]],
u'product_id': [31, u'[LAP-CUS] Laptop Customized'],
u'product_id_count': 1,
u'qty': 80.0},
{u'__domain': [[u'product_id', u'=', 30]],
u'product_id': [30, u'[LAP-E5] Laptop E5023'],
u'product_id_count': 1,
u'qty': 16.0},
{u'__domain': [[u'product_id', u'=', 23]],
u'product_id': [23, u'[M-Wir] Mouse, Wireless'],
u'product_id_count': 1,
u'qty': 10.0},
{u'__domain': [[u'product_id', u'=', 4]],
u'product_id': [4, u'[PROD_DEL] Switch, 24 ports'],
u'product_id_count': 1,
u'qty': 180.0},
{u'__domain': [[u'product_id', u'=', 24]],
u'product_id': [24, u'[RAM-SR5] RAM SR5'],
u'product_id_count': 1,
u'qty': 2.0}]}

- the result from this command is all the available products in the stock locations and their ids are
[29,14,16,17,19,20,21,26,31,30,23,4,24]


- to get the stock quantities for a product in all the locations for example a product with id 29 use
this command



curl -q -H "content-type:application/json" -H "Cookie:
session_id=a3038b0640f59d5e3d20195f5177af0d1cc465f2" -X POST -d
'{"jsonrpc":"2.0","method":"call","params":{"model":"stock.quant","fields":["product_id","location
_id","qty"],"domain":[["product_id","=",[29]]],"context":{"lang":"en_US","uid":1,"group_by":[],"p
arams":{},"active_model":"stock.quant"}}}' http://localhost:8069/web/dataset/search_read


-the result is


{u'id': None,
u'jsonrpc': u'2.0',
u'result': {u'length': 2,
u'records': [{u'id': 4,
u'location_id': [18, u'WH/Stock/Shelf 2'],
u'product_id': [29, u'[CARD] Graphics Card'],
u'qty': 16.0},
{u'id': 15,
u'location_id': [15, u'WH/Stock'],
u'product_id': [29, u'[CARD] Graphics Card'],

- the result is this product with id = 29 is exists in two locations the first location is with id 18
and the quantity is 16 and the second location is with id 15 with quantity 1