在向OpenERP中的用户组授予权限时发生错误

时间:2013-05-20 04:55:32

标签: openerp

我在OpenERP中创建了一个新模块。我创建了两个用户组,管理员和用户。接下来我想给经理一个权限,他只需要访问自己项目的详细信息。我在安全XML文件中添加了以下代码。

<record id="property_rule_mat_mgmt_manager" model="ir.rule">
            <field name="name">Material Manage Rule</field>
            <field model="ir.model" name="model_id" ref="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_manager')), (4,ref('group_mat_mgmt_user'))]"/>
        </record>  

但是我收到了这样的错误

  

服务器跟踪(最近一次调用最后一次):文件   “C:\ OpenErp \ openerp \ openerp-web \ addons \ web \ session.py”,第91行,   发送       return openerp.netsvc.dispatch_rpc(service_name,method,args)文件“C:\ OpenErp \ openerp \ openobject-server \ openerp \ netsvc.py”,line   361,在dispatch_rpc中       result = ExportService.getService(service_name).dispatch(method,params)File   “C:\ OpenERP的\ OpenERP的\ openobject服务器\ OpenERP的\服务\ web_services.py”   第582行,在发送中       security.check(db,uid,passwd)文件“C:\ OpenErp \ openerp \ openobject-server \ openerp \ service \ security.py”,   第40行,检查       pool = pooler.get_pool(db)文件“C:\ OpenErp \ openerp \ openobject-server \ openerp \ pooler.py”,第50行,in   get_pool       return get_db_and_pool(db_name,force_demo,status,update_module)[1]文件   “C:\ OpenErp \ openerp \ openobject-server \ openerp \ pooler.py”,第33行,in   get_db_and_pool       registry = RegistryManager.get(db_name,force_demo,status,update_module,pooljobs)文件   “C:\ OpenERP的\ OpenERP的\ openobject服务器\ OpenERP的\模块\ registry.py”,   第154行,在得到       update_module,pooljobs)文件“C:\ OpenErp \ openerp \ openobject-server \ openerp \ modules \ registry.py”,   第176行,新的       openerp.modules.load_modules(registry.db,force_demo,status,update_module)文件   “C:\ OpenERP的\ OpenERP的\ openobject服务器\ OpenERP的\模块\ loading.py”,   第329行,在load_modules中       processed = load_marked_modules(cr,graph,states_to_load,force,status,report,loaded_modules)文件   “C:\ OpenERP的\ OpenERP的\ openobject服务器\ OpenERP的\模块\ loading.py”,   第244行,在load_marked_modules中       loaded,processed = load_module_graph(cr,graph,progressdict,report = report,skip_modules = loaded_modules)文件   “C:\ OpenERP的\ OpenERP的\ openobject服务器\ OpenERP的\模块\ loading.py”,   第180行,在load_module_graph中       load_data(module_name,idref,mode)文件“C:\ OpenErp \ openerp \ openobject-server \ openerp \ modules \ loading.py”,   第78行       load_data = lambda * args:_load_data(cr,* args,kind ='data')文件   “C:\ OpenERP的\ OpenERP的\ openobject服务器\ OpenERP的\模块\ loading.py”,   第125行,在_load_data中       tools.convert_xml_import(cr,module_name,fp,idref,mode,noupdate,report)文件   “C:\ OpenErp \ openerp \ openobject-server \ openerp \ tools \ convert.py”,line   955,在convert_xml_import中       obj.parse(doc.getroot())文件“C:\ OpenErp \ openerp \ openobject-server \ openerp \ tools \ convert.py”,行   848,解析       self._tags [rec.tag](self.cr,rec,n)文件“C:\ OpenErp \ openerp \ openobject-server \ openerp \ tools \ convert.py”,line   806,在_tag_record中       f_val = self.id_get(cr,f_ref)文件“C:\ OpenErp \ openerp \ openobject-server \ openerp \ tools \ convert.py”,line   825,在id_get中       res = self.model_id_get(cr,id_str)文件“C:\ OpenErp \ openerp \ openobject-server \ openerp \ tools \ convert.py”,line   834,在model_id_get中       return model_data_obj.get_object_reference(cr,self.uid,mod,id_str)File   “C:\ OpenErp \ openerp \ openobject-server \ openerp \ tools \ cache.py”,line   18,在查找中       r = self.lookup(self2,cr,* args)文件“C:\ OpenErp \ openerp \ openobject-server \ openerp \ tools \ cache.py”,line   46,在查找中       value = d [key] = self.method(self2,cr,* args)文件“C:\ OpenErp \ openerp \ openobject-server \ openerp \ addons \ base \ ir \ ir_model.py”,   第857行,在get_object_reference中       data_id = self._get_id(cr,uid,module,xml_id)文件“C:\ OpenErp \ openerp \ openobject-server \ openerp \ tools \ cache.py”,line   18,在查找中       r = self.lookup(self2,cr,* args)文件“C:\ OpenErp \ openerp \ openobject-server \ openerp \ tools \ cache.py”,line   46,在查找中       value = d [key] = self.method(self2,cr,* args)文件“C:\ OpenErp \ openerp \ openobject-server \ openerp \ addons \ base \ ir \ ir_model.py”,   第108行,在_get_id中       提出ValueError('系统中当前没有定义此类外部ID:%s。%s'%(module,xml_id))ValueError:没有这样的外部ID   当前在系统中定义:mat_mgmt.model_project_project

2 个答案:

答案 0 :(得分:0)

替换此行

<field model="ir.model" name="model_id" ref="model_project_project"/>

<field model="ir.model" name="model_id" ref="project.model_project_project"/>

答案 1 :(得分:0)

如果其他人发现很难找到正确的型号ID,您可以执行以下操作。

  • 激活开发者模式
  • 转到“设置”|技术|数据库结构|模型
  • 查找并选择您想要的模型
  • 在顶部的下拉列表中显示&#34; Debug view#&#34;,选择&#34;查看日志(perm read)&#34;

您将在那里看到XML ID