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

Hello all,

I want to calculate number of users in openerp. here is my code. Please let me know this code is correct or not.

Thanks in advance....

 

        user_ids = self.pool.get('res.users').search_count(cr, uid, ids, context=context)        
        use_user_count = len(user_ids)

아바타
취소
베스트 답변

You cannot pass 'ids' here, you need to pass the domain i.e. the search criteria and search_count will directly return the 'count', so no need to use 'len' function.

It should be like

domain=[]

u_count = self.pool.get('res.users').search_count(cr,uid,domain,context=context)

Here it will not count inactive users, for that you can do the following:

domain=[]

my_context=dict(self._context)

my_context.update({'active_test':False})

u_count = self.env['res.users'].with_context(my_context).search_count(domain)

Hope this helps

아바타
취소
작성자

Thanks....

작성자

i tried 2nd method but i get this error NotImplementedError: 'update' not supported on frozendict

I have updated the post. Check it and let me know if that worked

작성자

I got this error "AttributeError: 'test.model' object has no attribute 'env'"

베스트 답변

            rec=self.env['res.users'].search([('active','=','TRUE')])
            print len(rec)

아바타
취소
관련 게시물 답글 화면 활동
2
7월 25
4393
2
8월 25
5976
3
7월 25
7101
1
5월 25
1190
2
1월 25
1969