Im new with Odoo development, I am currently setting up a Python script that takes all products from the product.product model and return them to a JSON file. (id, name, display_name, list_price, product_tmpl_id, qty_available).
I saw many names with (kopie) in, (duplicate) in english. In the UI of odoo the names are correct and dont have (duplicate) in the name.
What I analyse from this is that the names when exported using the API are not always the same than in the UI of odoo. The product.product id and product.template id point to eachother
An example:
Scraped using the API:
name: Apple (kopie)
product.product id: 1234
product.template id: 5678
In odoo UI:
Scraped using the API:
name: Orange
product.product id: 1234
product.template id: 5678
My question is how, hoe does this happen? I am currently manually fixing them with code to be the same name in the database than in the UI. I appreciate the help and couldn't really find a good answer on this.
This question has been flagged
1
Reply
1041
Views
If you have names in different languages, you need to specify in the API call which language you want the name for.
Send via Context the language {'lang': 'en_AU'} (for English, Australian) 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']
})
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up| Related Posts | Replies | Views | Activity | |
|---|---|---|---|---|
|
|
3
Feb 26
|
3247 | ||
|
|
0
Dec 25
|
1712 | ||
|
|
2
Mar 24
|
5627 | ||
|
|
0
Aug 21
|
5443 | ||
|
|
1
Feb 26
|
2044 |