dep = fields.Many2one('hr.department', string='Administrative unit',)
ex. if user is ahmed who created a record in sales department so the field dep in this record returns salesthanks in advance
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
dep = fields.Many2one('hr.department', string='Administrative unit',)
ex. if user is ahmed who created a record in sales department so the field dep in this record returns salesthanks in advance
Hi Paresh
trying
default=lambda self: self.env.user.department_id <-- or with .id -->
says department_id doesnot exist in res.users cause it does not
i tried
default=lambda self: self.env.user.employee_ids.department_id
no errors but no reseult :)
i will try what muhammad send but i will appreciate if you have solution :)
thanks
https://www.odoo.com/fr_FR/forum/aide-1/question/how-to-get-current-user-name-into-field-problem-solved-129261
https://www.odoo.com/fr_FR/forum/aide-1/question/get-current-user-s-company-id-94026
https://www.odoo.com/fr_FR/forum/aide-1/question/how-to-get-current-user-name-into-field-problem-solved-129261
https://www.odoo.com/fr_FR/forum/aide-1/question/get-current-user-s-company-id-94026
Hi Ahmed:
The following should return the department id of the current user.
self.env.user.department_id.id
أنشئ حساباً اليوم لتستمتع بالخصائص الحصرية، وتفاعل مع مجتمعنا الرائع!
تسجيل| المنشورات ذات الصلة | الردود | أدوات العرض | النشاط | |
|---|---|---|---|---|
|
2
أغسطس 25
|
8293 | |||
|
2
يوليو 24
|
16887 | |||
|
2
سبتمبر 23
|
9694 | |||
|
2
يناير 23
|
3436 | |||
|
1
أغسطس 22
|
6928 |
1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.
this code is worked but users other than admin :) so solved thanks all
dep = fields.Many2one('hr.department', string='Administrative unit', default=lambda self: self.env.user.employee_ids.department_id.id, readonly=True)