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

Hello,


I'm having a little trouble on how to display a list of all my ecommerce users inside a tree view in my custom module.

Objectives:

  1. Add a boolean field associated with my ecommerce users that will dictate if they are 'authorized' or not.

  2. The backend user should have access to a list of all users and should be able to authorize or deauthorize them easily.

  3. I will later modify my website templates to check wether the current user has 'authorized' set to True or not.

                

I thought about inheriting the 'res_users' model and start from there, but i'm not sure it would work (or be the best solution).

An even worse solution would be to copy all users records to my custom module and display the copies in the backend control panel view (to modify the authorization boolean), and then in the templates check for the custom module boolean field instead of a res_users boolean directly.

What i think would be cleaner would be to 'link' all user records to my module through a related field and then display them all in the module form view to serve as the control pannel.

What i can't manage to do is to make the view display all the records automatically (when the user clicks in the control panel i want a full list of users to be displayed)

This is what i got so far:


class AuthorizedUsers(models.Model):
_name = "auth_users"

user_id = fields.Many2one('res.users')
login = fields.Char(related='user_id.login')
is_authorized = fields.Boolean(String="Usuário Autorizado", default=False)


and this is the tree view:

<record model="ir.ui.view" id="user_auth_panel_tree">
<field name="name">user_auth_panel.tree</field>
<field name="model">auth_users</field>
<field name="view_type">tree</field>
<field name="arch" type="xml">
<tree>
<field name="login"/>
<field name="is_authorized"/>
</tree>
</field>
</record>


How can i list every res.user's login automatically in my tree view and attach a boolean to them?

Thanks.


아바타
취소

Are you trying to hide pages for certain users? Did you consider putting them into groups and configuring certain pages to only be visible to a specific group? <t groups="xxx.yyy" ... />

작성자

Ray, thats exactly what i want to do. Using the Qweb groups tag did not worked for me tough. I wanted to use a solution like this so the backend user can manage the portal users permissions more easily and also so i can learn more about the API

작성자

Also, i'm trying to hide content within the pages, and not necessarily whole pages

작성자 베스트 답변

Still need an answer

아바타
취소
관련 게시물 답글 화면 활동
0
5월 15
6833
0
5월 24
1500
2
10월 23
2713
1
9월 21
5934
1
3월 21
2610