Ir al contenido
Menú
Se marcó esta pregunta
1 Responder
3241 Vistas

I have created a new module for consumption.That is consumption details about a project will save here.I have created two roles users and managers(members of the projects).Users will create consumption details they can see their own consumption.In case of manager he want to see all consumption details of his project.We will set one user as manager it may be project memeber or project manager.Anyway he need to see all consumption details related to his projects.How to write the record rule for this scenario. (Example Project 'A' has three members a1,a2,a3 a3 is set as the manager of our module(he may or maynot be the project manager of this project) a1 and a2 will prepare consumption chart related to this project, a3 wants to all consumption chart created by a1 and a2 related to the project 'A') I have tried this

<record id="property_rule_mat_mgmt_officer" model="ir.rule">
            <field name="name">Material Manage Rule1</field>
            <field model="ir.model" name="model_id" ref="project.model_project_project"/>
            <field name="domain_force">['|',('project_id.members','=',user.id),('project_id.user_id','=',user.id)]</field>
            <field name="groups" eval="[(4,ref('group_mat_mgmt_officer')), (4,ref('group_mat_mgmt_manager'))]"/>
        </record>

But got an error

ValueError: Invalid field 'project_id.members' in domain expression

Avatar
Descartar

is there any members field defined in relation to project_id? and what is the defenition given for project_id. The domain is not getting any field named members thats why its giving error

Mejor respuesta

Hy,

I think the you're working directly on project so my experience would be this :

  1. Create a new many2many field in res.users and call it projects_ids then simply try :
    ['|',('project_id.user_id','=',user.id),('id','in',[p.id from p in user.projects_ids])]

Hope it could help

Avatar
Descartar