Skip to Content
Menu
This question has been flagged
1 Reply
1751 Views

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
Discard
Author

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.

Best Answer

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
Discard
Related Posts Replies Views Activity
1
Feb 22
2619
1
Feb 22
4809
0
Nov 21
2753
3
Feb 16
4299
2
Jul 15
12326