- 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
<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
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
<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
{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'],
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 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
- 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 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