How to update create_uid field using ORM objects
we can do using sql query , i need without using query.
I have tried
browse_obj.write({'create_uid': my_custom_id}) --> not working
browse_obj.create_uid = my_custom_uid --> not working
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
How to update create_uid field using ORM objects
we can do using sql query , i need without using query.
I have tried
browse_obj.write({'create_uid': my_custom_id}) --> not working
browse_obj.create_uid = my_custom_uid --> not working
Hi,
For this, you need to change the user of the environment at the time of the creation of the record.
Eg:
self.env['your.model'].with_env(self.env(user=needed_user_id)).create(your_data)
here for changing the user, i use this code -> with_env(self.env(user=needed_user_id))
I don't know, it is the right way or it has some bad effects.
Thanks & Regards
|
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Sep 23
|
496 | ||
|
0
Sep 23
|
450 | ||
|
2
Feb 23
|
9252 | ||
|
6
Oct 23
|
19265 | ||
|
3
Mar 24
|
7685 |
What's the need to update the created user
we have multi-level approvals
Ex: Invoice having 2 level approvals
level 1 --> User1
level 2 --> User2
While doing level2 Journal Entry will create with create_uid=User2 here i want to show User1 against the user2