跳至內容
選單
此問題已被標幟
3895 瀏覽次數

Hi, 


I'm new to Odoo Development.

I tried to follow the examples found on  https://www.odoo.com/documentation/15.0/developer/misc/api/odoo.html
and
https://www.odoo.com/documentation/15.0/developer/reference/addons/orm.html

But I am stuck when trying to receive only id's when using manytoone fields :

When trying to get information from tags (category_id's) linked to hr.employee everything works fine :

# Code used
employees = models.execute_kw(db, uid, password,'hr.employee', 'search_read',[[['name', '=', 'Anna']]],{'fields': ['display_name', 'category_ids'],'limit': 3}) 
# Output 
[{'id': 452, 'display_name': 'Anna', 'category_ids': [1, 3]}]

When trying to get employee_id's linked to skills (hr.employee.skill), things go wrong because I do not only receive the id's, but also the display_name of the employees 


# Code used 
skills = models.execute_kw(db, uid, password,'hr.employee.skill', 'search_read',[],{'fields': ['id','display_name','employee_id'],'limit': 3}) 
# Output[{'id': 7, 'display_name': 'Developer', 'employee_id': [1, 'John']}, {'id': 5, 'display_name': 'Negotiation', 'employee_id': [459, 'David B.']}, {'id': 4, 'display_name': 'Negotiation', 'employee_id': [1, 'John']}]

What should I do to only receive the ids ? 


Thx

Sven

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
2
2月 25
5883
1
12月 24
1445
1
11月 22
15939
3
8月 22
12975
2
8月 22
4450