콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
2 답글
14819 화면

hello, i wanted to know how in my many2one field to get the logged user i have found a lot of solution by putting in default value lambda self,cr,uid, context: self.pool.get('res.users').browse(cr, uid, uid, context).id, something like this but in fact it's not what i want to.

for example if the user X has create a record it will be by defaut X in my many2one but i want that if another user Y click on that record(-that X have created) my many2one field will change with Y that means i want the current user no the user when the record has been created 

thanks a lot

아바타
취소
베스트 답변

Hi brami,

You can using compute field:

ex:

@api.multi

def _get_current_user(self):

     self.user_id = self.env.uid

user_id = fields.Many2one('res.users', 'Current User', compute='_get_current_user')


But I don't understand why do you do it?

아바타
취소
베스트 답변

Use domain if you don't want it to be computed.

Example:

user_id = fields.Many2one(
'res.users', 'Responsible',
domain=lambda self: [('res_id', 'in', self.env.user.id)])
아바타
취소
관련 게시물 답글 화면 활동
5
5월 23
13460
1
2월 16
5136
1
3월 15
5767
1
3월 15
8250
1
3월 15
5103