Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1 Відповісти
4890 Переглядів

How can i fetch the user id which belongs to the res.user model? I have a list of records and i am traversing them all one by one and check if a certain condition meet. In the matched case condition i need to copy all the field's value and create a new record. I'm able to fetch all the value except one, which is "assigned_to" this fields is related to "res.users"


duties = env['x_duties'].search(["&",["x_studio_automated_flag","=",True],["x_studio_reoccurred_task","=",False]])

for duty in duties:

    # some code...                          
    if duty.x_studio_on_date_or_after_days == 'on_date':
        user_id = duty.x_studio_assigned_to

        #some code....                          
        env['x_duties'].create({'x_name': '[Automated] '+ duty.x_name ,  'x_studio_details' :duty.x_name, , 'x_studio_assigned_to' : user_id 'x_studio_reoccurred_task' : True })


I want the user id as 39  but it is fetching a value like " res.users(39,)"

Аватар
Відмінити
Автор

It worked like a charm Anu. Thank you so much :)

Найкраща відповідь

Hi,

   just change  user_id = duty.x_studio_assigned_to.id

 or you can use  self.env.uid

                    

Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
1
вер. 21
10115
2
серп. 25
2147
1
лип. 25
696
1
серп. 25
1150
0
трав. 25
1244