![](/img/trans.png)
[英]This given text is in json format.As i am new to python so tell me how can i get id from user only
[英]How can i get the user id value from a given record
我需要重新創建一條記錄。 我能夠從記錄中提取所有字段,但是在提取屬於res.user的用戶ID時遇到了麻煩
我有一個計划的操作,該操作將遍歷所有記錄,並根據某些條件重新創建一條記錄。 為了重新創建記錄,我需要復制所有字段的值。 有一個名為“ assigned_to”的字段,其中包含來自res.user的值。 創建新記錄時,如何獲取其ID並將其寫入? 我正在嘗試:
for duty in duties:
if duty.x_studio_on_date_or_after_days == 'on_date':
user_id = env['x_duties'].search([('x_studio_assigned_to', '=', duty.x_studio_assigned_to)]).id
#user_id =39
current_date = datetime.datetime.now().date().strftime('%d')
if duty.x_studio_date_of_every_month_1 == current_date:
env['x_duties'].create({'x_name': '[Automated] '+ duty.x_name , 'x_studio_details' : duty.x_studio_details, 'x_studio_assigned_to' : user_id , 'x_studio_reoccurred_task' : True })
我收到這個錯誤
Invalid value res.users(39,) in domain term ('x_studio_assigned_to', '=', res.users(39,))
弄清楚了 :)
我只需要將user_id = duty.x_studio_assigned_to.id代替user_id = duty.x_studio_assigned_to
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.