Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
I've set up a simple tree view, which was pretty easy, but now I want to restrict the items in that tree view based on something like a domain. More specifically, I've created a page so users can view past timesheets (from hr_timesheet_sheet), but I only want them to be able to see their own past timesheets in the tree view. The basic tree view is like this:
<record id="past_timesheet_tree" model="ir.ui.view">
<field name="arch" type="xml">
<tree string="Past Timesheets" create="false" edit="false" delete="false">
<field ... />
<field ... />
Unfortunately it looks like I can't add a domain attribute to the <tree> tag. Also, I don't want to just create a default filter, because then users would be able to remove that filter and see all the timesheets. I need this view to completely restrict users to only view items that belong to them. I can't think of any examples of where this happens in the system, so I'm hoping someone here will have an idea.
(On an unrelated meta note, I indented my code block with 4 or more spaces, but I'm not getting code formatting. Is there something else I can do to put it in a code block?)
A better solution is to add an Access Right rule to the 'Employee' group for the model.
[('user_id', '=', user.id)]
This prevents users from seeing other users timesheets, unless they are "Officers" or "Managers".
- Navigate to Settings -> Users -> Groups
- Open the Employee Group
- Navigate to the Rules tab and Click Add
- Click Create
- Fill out the rule like this (Timesheet here is hr_timesheet_sheet.sheet)
- Add the Employee group to this rule:
- Click Save and Close.
- Click Save.
About This Community
This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 7/24/14, 11:22 AM|
|Seen: 3621 times|
|Last updated: 3/16/15, 8:10 AM|