Hi guys,
Usually I would work with groups and rules for limiting different things to users but this one is different. I want to be able to influence who can view which project tasks without record rules but depending on what is filled in on a new model. To give you some insight:
I've first created a new model which has a many2one to 'res.users' and a many2many to 'project.task.type'. The code:
class TaskStateRights(models.Model): _name = 'project.task.rights' name = fields.Char( String='Description' ) username_ids = fields.Many2one( 'res.users', 'User' ) project_task_fases = fields.Many2many('project.task.type','project_optional_rel','pr_src_id','pr_dest_id',string='Fases allowed to view', help="All the project task fases you choose here will be viewable by this user.")
I've then created a form and tree view for this new model:
<!--Apply rights on tasktages --> <record id="project_task_rights_tree_view" model="ir.ui.view"> <field name="name">project.task.rights.tree.view</field> <field name="model">project.task.rights</field> <field name="type">tree</field> <field name="priority" eval="1"/> <field name="arch" type="xml"> <tree string="Taskstage rights"> <field name="username_ids"/> </tree> </field> </record> <record id="project_task_rights_form_view" model="ir.ui.view"> <field name="name">project.task.rights.form.view</field> <field name="model">project.task.rights</field> <field name="type">form</field> <field name="priority" eval="1"/> <field name="arch" type="xml"> <form string="Taskstage rights"> <group col="2"> <field name="username_ids"/> <field name="project_task_fases"/> </group> </form> </field> </record> <record model="ir.actions.act_window" id="open_view_project_task_rights"> <field name="name">Project task stage rights</field> <field name="res_model">project.task.rights</field> <field name="view_type">form</field> <field name='view_mode'>tree,form</field> <field name='view_id' ref='project_task_rights_tree_view'/> </record> <menuitem action="open_view_project_task_rights" id="menu_projects_task_rights" name="Project stage rights" parent="project.menu_project_management" sequence="10"/>
So on this new view you can choose an user and then choose project task stages. Depending on what is filled in for this user on the model 'project.task.rights' I want to show/hide different types. For example when we've added a record 'User1' and added the statusses 'Development', 'Testing' then the 'User1' should only be able to see the types 'Development' and 'Testing' on the project task view.
So, what is the best way to handle this?
Thanks,
Yenthe
I would like to know the record rule domain [('stage_id','in',(user.stages_ids.ids))] how to make work in Windows Action or Search filter. stages_ids is many2many field contain stage_id and user_id column. Thanks in advance