Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
1 Vastaa
2831 Näkymät

Here is my code:


models = xmlrpc.client.ServerProxy('{}/xmlrpc/2/object'.format(url))
product_id = models.execute_kw(db, uid, password, 'product.template', 'search',
[[['default_code', '=', 'X8591']]])


print("Product Id is: ", product_id)

record = models.execute_kw(db, uid, password,
'product.template', 'read', [product_id], {'fields':
['id', 'name', 'default_code', 'display_name', 'description']})

print("Record Details are: ",record)

# search the another project
print("Trying to get details of X-Ray position poster - Canine")
new_id = models.execute_kw(db, uid, password,
'product.template', 'search',[[['name', 'ilike', 'X-Ray position poster - Canine']]])

print("New Id: ", new_id)

record = models.execute_kw(db, uid, password,
'product.template', 'read',[new_id], {'fields': ['id', 'name', 'default_code',
'display_name', 'description']})

print("Details:", record)


Here is the output:



Here is the record in Odoo:



Avatar
Hylkää
Tekijä

I have verified that the ID of the record shown in Odoo is in fact ID 5927 and that it is a product.template record, not a product.product record.

Paras vastaus

It appears your problem is related to translations of the name.

Please send via Context the language {'lang': 'en_AU'} during all API calls to get what you expect when using the translation framework. 



record = models.execute_kw(db, uid, password,'product.template', 'read',[product_id],
{'context': {'lang': 'en_AU'},
'fields': ['id', 'name', 'default_code', 'display_name', 'description']
})



Avatar
Hylkää
Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
2
jouluk. 24
2958
1
helmik. 22
4521
1
helmik. 22
7585
0
marrask. 21
5059
3
helmik. 16
5187