Odoo中文社区可以通过以下三个域名访问:shine-it.net , odoocn.org,odoo.net.cn

原论坛用户的基本信息和发帖这里都予以保留,请注意:原论坛用户无需重新注册新用户,但是您的密码需要重置

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

请问下用代码如何设置自己的模块访问权限??



  • 我是模仿hr模块中的XML文件(hr_security.xml),可是有的地方看不懂啊,以下是文件的内容:<br /><openerp><br /><data noupdate="0"><br /><br />    <record model="res.groups" id="base.group_user"><br />        <field name="comment">user will be able to manage his own human resources stuff (leave request, timesheets, ...), if he is linked to an employee in the system.</field><br />    </record><br /><br />    <record id="base.group_hr_user" model="res.groups"><br />        <field name="name">Officer</field><br />        <field name="category_id" ref="base.module_category_human_resources"/><br />        <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/><br />        <field name="comment">the user will be able to approve document created by employees.</field><br />    </record><br />    <record id="base.group_hr_manager" model="res.groups"><br />        <field name="name">Manager</field><br />        <field name="comment">the user will have an access to the human resources configuration as well as statistic reports.</field><br />        <field name="category_id" ref="base.module_category_human_resources"/><br />        <field name="implied_ids" eval="[(4, ref('base.group_hr_user'))]"/><br />        <field name="users" eval="[(4, ref('base.user_root'))]"/><br />    </record><br /><br /></data><br /><br /><data noupdate="1"><br /><br />    <record id="hr_dept_comp_rule" model="ir.rule"><br />        <field name="name">Department multi company rule</field><br />        <field model="ir.model" name="model_id" ref="model_hr_department"/><br />        <field eval="True" name="global"/><br />        <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field><br />    </record><br />    <record id="hr_job_comp_rule" model="ir.rule"><br />        <field name="name">Job multi company rule</field><br />        <field model="ir.model" name="model_id" ref="model_hr_job"/><br />        <field eval="True" name="global"/><br />        <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field><br />    </record><br /><br /></data><br /></openerp><br /><br />我看不懂ref和eval的意思,想来想去还是没想通... eval="[(4, ref('base.group_hr_user'))]"这个是感觉最诡异的..<br />有哪位高人能解释解释吗?



  • 我是模仿hr模块中的XML文件(hr_security.xml),可是有的地方看不懂啊,以下是文件的内容:<br /><openerp><br /><data noupdate="0"><br /><br />    <record model="res.groups" id="base.group_user"><br />        <field name="comment">user will be able to manage his own human resources stuff (leave request, timesheets, ...), if he is linked to an employee in the system.</field><br />    </record><br /><br />    <record id="base.group_hr_user" model="res.groups"><br />        <field name="name">Officer</field><br />        <field name="category_id" ref="base.module_category_human_resources"/><br />        <field name="implied_ids" eval="[(4, ref('base.group_user'))]"/><br />        <field name="comment">the user will be able to approve document created by employees.</field><br />    </record><br />    <record id="base.group_hr_manager" model="res.groups"><br />        <field name="name">Manager</field><br />        <field name="comment">the user will have an access to the human resources configuration as well as statistic reports.</field><br />        <field name="category_id" ref="base.module_category_human_resources"/><br />        <field name="implied_ids" eval="[(4, ref('base.group_hr_user'))]"/><br />        <field name="users" eval="[(4, ref('base.user_root'))]"/><br />    </record><br /><br /></data><br /><br /><data noupdate="1"><br /><br />    <record id="hr_dept_comp_rule" model="ir.rule"><br />        <field name="name">Department multi company rule</field><br />        <field model="ir.model" name="model_id" ref="model_hr_department"/><br />        <field eval="True" name="global"/><br />        <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field><br />    </record><br />    <record id="hr_job_comp_rule" model="ir.rule"><br />        <field name="name">Job multi company rule</field><br />        <field model="ir.model" name="model_id" ref="model_hr_job"/><br />        <field eval="True" name="global"/><br />        <field name="domain_force">['|',('company_id','=',False),('company_id','child_of',[user.company_id.id])]</field><br />    </record><br /><br /></data><br /></openerp><br /><br />我看不懂ref和eval的意思,想来想去还是没想通... eval="[(4, ref('base.group_hr_user'))]"这个是感觉最诡异的..<br />有哪位高人能解释解释吗?



  • ref 是把 xml_id 转成数据库里的 res_id,<br />eval 是把字符串转成python表达式<br />[(4, ref('base.group_hr_user'))] 这个是openerp的特殊用法,见 http://git.oschina.net/osbzr/openerp_7_osbzr/blob/master/openerp7/openerp/osv/fields.py#L1249



  • res_id是什么意思呢??<br />我可不可以这么认为 对于openerp的XML文件中的每一个<record>都是对应存储在数据库中的一条记录?<br />比如<br /><record model="res.groups" id="base.group_user"><br />        <field name="comment">user will be able to manage his own human resources stuff (leave request, timesheets, ...), if he is linked to an employee in the system.</field><br />    </record><br /><br />这个表示的是 在res.groups表中有一条记录,它的字段"comment"为user will be able to manage his own human resources stuff (leave request, timesheets, ...), if he is linked to an employee in the system.可是这么认为的话,这条记录就只有comment字段有值吗??<br />



  • 理解正确。<br /><br />xml 里面基本都是往 某个表里导入 记录


登录后回复
 

与 Odoo 中文社区 的连接断开,我们正在尝试重连,请耐心等待