Skip to Content
Menu
This question has been flagged

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.


Avatar
Discard

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" ... />

Author

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

Author

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

Author Best Answer

Still need an answer

Avatar
Discard
Related Posts Replies Views Activity
0
May 15
5241
0
May 24
214
2
Oct 23
1009
1
Sep 21
4724
1
Mar 21
1674