콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
5 답글
4564 화면
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 sales

thanks in advance

아바타
취소
작성자

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)

작성자 베스트 답변

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
8월 25
7776
2
7월 24
16192
2
9월 23
9002
2
1월 23
2806
1
8월 22
5918