thanks in Advance please define it in detail...
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Contabilidad
- Inventario
- PoS
- Project
- MRP
Se marcó esta pregunta
14
Respuestas
32324
Vistas
thanks in Advance please define it in detail...
Hi,
self.env.uid will give the id of the current user
and
self.env.user will return the current user record
Example
self.env.uid - 1
self.env.user - res.users(1,)
Thanks
hi, Usman Farzand
self.env.uid will return Id of Current Login User
self.env.user will return Current User Record
Hey,
Earlier when i have checked my answer it was accepted and have green tick in it, and now it seems the green tick for you answer.
Anything new you have added in the answer ? or my answer is wrong ? was not my clear ?
* was not my answer clear ?
no you are right, but you not mentation that Current Login User. i think
What does the meaning of current user ? Didn't see that ? Are you saying current user and current login user is different ?
Look even in your answer you have used current user record.
you both are right can you please any one tell me if it's different from each other
self.env.uid - 1
self.env.user - res.users(1,)
then why condition is same for both ????
@api.multi
def do_clear_done(self):
domain = [('is_done', '=', True),'|',('user_id', '=', self.env.uid),
('user_id', '=', False)]
dones = self.search(domain)
dones.write({'active': False})
return True
@api.multi
def do_toggle_done(self):
for task in self:
if task.user_id != self.env.user:
raise ValidationError('Only the Responsible can do this!')
return super(TodoTask, self).do_toggle_done()
if condition chk and domain chk in same way can any one tell me more in detail sorry i'm beginner
('user_id', '=', self.env.uid),
if task.user_id != self.env.user:
noted point why ?
see the thing is, when You simply write 'user_id' than it will return one Object like res.users(1,)
and if you want to put condition on it than u required Object in other side also otherwise it give Error to you. so we use self.env.user.
And For the Domain case i think while You Search any Record or Applying Domain on Record then you need ID of the Record, so domain = [('is_done', '=', True),'|',('user_id', '=', self.env.uid),
@ Palkesh Baraiya if i write
if task.user_id != self.env.id:
excpt this
if task.user_id != self.env.user
is it will correct ?
thanks for answer i clear my more concept....
Look If you want to Compare only ID than u can write
if task.user_id.id != self.env.uid:
it will compare your 'user_id' with current Login User ID. like
if 'user_id' = 1 and Current Login user('self.env.uid') = 1
than Condition was fulfil.
and other case was,
if task.user_id != self.env.user
it will use 'user_id' as object like 'res.partner(1,)' and for self.env.user as 'Current Login User Object like res.users(1,)'
excellent thank you soo much @Palkesh Baraiya....thanks again...
self.env.uid will return Database table Id (ex: admin login --> 1)
self.env.user will return ORM browse object (ex: admin login --> res.user(1))
¿Le interesa esta conversación? ¡Participe en ella!
Cree una cuenta para poder utilizar funciones exclusivas e interactuar con la comunidad.
RegistrarsePublicaciones relacionadas | Respuestas | Vistas | Actividad | |
---|---|---|---|---|
|
0
may 20
|
2931 | ||
|
1
mar 15
|
6316 | ||
|
0
ago 16
|
2591 | ||
|
3
abr 25
|
11753 | ||
|
1
oct 19
|
2865 |
get logged in user id: http://learnopenerp.blogspot.com/2018/08/get-current-logged-in-user-id-in-odoo.html