i want to create PRODUCT I want to show 'categ_id' How can it be accomplished 'categ_id' . fields many2one with XML RPC
In the following example, we retrieve the record id of the saleable category from the database to create a new product:
import xmlrpc.client
url =
db =
username =
password =
common = xmlrpc.client.ServerProxy('{}/xmlrpc/2/common'.format(url))
models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
uid = common.authenticate(db, username, password, {})
models.execute_kw(db, uid, password, 'product.template', 'create',
[{'name': 'Test Product', 'categ_id': 1}])
For One2many
and Many2many
fields, Odoo uses a special command to manipulate the relation they implement which can be used from XMLRPC:
Via RPC, it is impossible nor to use the functions nor the command constant names. It is required to instead write the literal 3-elements tuple where the first element is the integer identifier of the command.
Example: (create a product template with vendor pricelists)
models.execute_kw(db, uid, password, 'product.template', 'create',
[{'name': 'Test Product',
'categ_id': 1,
'seller_ids': [(0, 0, {'name': 1,
'min_qty': 1000,
'price': 258.5,
'delay': 5
}
)]
}])
The triplet format may change for other operations, for example for update
, you will need to specify the record id in the following format: (1, id, values)