我创建了记录规则,只有员工才能看到odoo11的项目

时间:2018-08-03 07:24:10

标签: xml python-3.x odoo-11 record-rules

我创建了记录规则,只有员工才能看到他们必须分配的项目,但是我的代码无法正常工作。我是oodoo和oodo 11的初学者。

请帮帮我。


XML代码

<?xml version="1.0" encoding="utf-8"?>

<odoo>
<data noupdate="1">


 <record id="group_project_employee" model="res.groups">
        <field name="name">Employee</field>
        <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
        <field name="category_id" ref="base.module_category_project_management"/>
    </record>

 <record model="ir.rule" id="project_members_rule">
             <field name="name">Project: User is Member</field>
             <field name="model_id" ref="model_project_task"></field>
             <field name="groups" eval="[(4,ref('project.task.group_project_employee'))]"></field>
             <field name="domain_force">['|',('user_id','=',False),('user_id','=',user.id)]</field>
             <field eval="1" name="perm_read"></field>   
             <field eval="0" name="perm_write"></field> 
             <field eval="0" name="perm_unlink"></field>
             <field eval="0" name="perm_create"></field>
     </record>    
</data>
</odoo>

Python代码

from odoo import api, fields, models, _

class ProjectTask(models.Model):    

     _inherit = 'project.project'

     employee_user = fields.Many2many('res.users', 'project_user_rel', 'project_id',
                               'uid', 'Team', help="""Project's
                               members are users who can have an access to
                               the tasks related to this project."""
                               )

CSV

  id    name    model_id:id group_id:id perm_read   perm_write  perm_create perm_unlink

  access_project_task   project.task    model_project_task  project.group_project_employee  1   0   0   0

谢谢。

1 个答案:

答案 0 :(得分:0)

问题是您给他group_user表示雇员,并且在项目中为他编写了一些记录规则,您也必须对其进行修改。