Hello Openerp开发人员。我今天创建了一个自定义模块,当通过管理员访问时工作正常,但是当其他用户访问时,模块菜单不会显示在顶部菜单栏上。我在安全文件夹中创建了访问权限,我认为我在 security.xml 或 csv文件中做错了,有人可以帮助我摆脱这个问题。
我在下面列出了我的模块文件和代码。检查一下让我做错了什么或我错过了什么。
forum_view.xml,
forum.py,
__init__.py,
__openerp__.py
security/forum_nyros_security.xml
security/ir.model.access.csv
_ 初始化 _。PY
# -*- coding: utf-8 -*-
import forum
_ OpenERP的 _。PY
# -*- coding: utf-8 -*-
{
'name' : "Nyros Discussion Forum",
'category' : "Test",
'version' : "1.0",
'depends' : ['base','mail'],
'author' : "Me",
'description' : """\
Open Academy modsule for managing trainings:
- training courses
- training sessions
- attendees registration""",
'data' : ['forum_view.xml',
'security/forum_nyros_security.xml',
'security/ir.model.access.csv'
],
}
forum.py
import datetime
import time
import openerp
from openerp.osv import osv, fields
class Course(osv.osv):
_name = "forum.course"
_inherit = ['mail.thread', 'ir.needaction_mixin']
_columns = {
'name' : fields.char(string="Question Title", size=256, required=True),
'description' : fields.text(string="Question Description", required=True),
'date_of_q_created': fields.datetime('Date of Created'),
'category_question': fields.many2one('forum.categ', 'Question Category'),
'create_uid': fields.many2one('res.users', 'Question Created By', readonly=True),
}
Course()
class question_categ(osv.osv):
_name='forum.categ'
_description='category of Question'
_columns={
'name':fields.char('Create a Category type',size=100)
}
question_categ()
forum_view.xml
<openerp>
<data>
<!-- search view -->
<record id="forum_search" model="ir.ui.view">
<field name="name">forum.search</field>
<field name="model">forum.course</field>
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Question Answer Discussion Forum">
<field name="name"/>
<field name="description"/>
<field name="date_of_q_created"/>
</search>
</field>
</record>
<!-- Tree View -->
<record model="ir.ui.view" id="course_tree_view">
<field name="name">forum.course.tree</field>
<field name="model">forum.course</field>
<field name="arch" type="xml">
<tree string="Questions">
<field name="name"/>
<!-- <field name="description"/>-->
<field name="date_of_q_created" />
<field name="category_question"/>
<field name="create_uid"/>
</tree>
</field>
</record>
<!-- Form View -->
<record model="ir.ui.view" id="course_form_view">
<field name="name">forum.course.form</field>
<field name="model">forum.course</field>
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Question and Answer" version = "v7">
<sheet>
<group string="Question">
<field name="name"/>
<field name="description"/>
<field name="date_of_q_created" />
<field name="category_question"/>
<field name="create_uid"/>
</group>
<group string="Answers and Comments">
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers" groups="base.group_user"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</group>
</sheet>
</form>
</field>
</record>
<!-- Action View -->
<record model="ir.actions.act_window" id="course_list_action">
<field name="name">Questions form</field>
<field name="res_model">forum.course</field>
<field name="target">current</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>
<!-- Menu Items -->
<menuitem id="main_forum_menu" name="Manage forum" />
<menuitem id="forum_menu" name="Discussion Forum" parent="main_forum_menu" />
<menuitem id="courses_menu" name="Questions sidemenu" parent="forum_menu" action="course_list_action" />
</data>
</openerp>
安全/ forum_nyros_security.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<record id="group_forum_manager" model="res.groups">
<field name="name">Forum Management/ Manager</field>
</record>
<record id="group_forum_user" model="res.groups">
<field name="name">Forum Management / User</field>
</record>
</data>
</openerp>
安全/ ir.model.access.csv
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_forum_course,forum.course,model_forum_course,forum_nyros.group_forum_user,1,1,1,1
access_forum_categ,forum.categ,model_forum_categ,forum_nyros.group_forum_user,1,1,1,1
答案 0 :(得分:1)
在 _ openerp _ .py文件中尝试以下行
'installable': True,
'auto_install': False,
您的 security / forum_nyros_security.xml
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="0">
<record model="ir.module.category" id="module_category_forum">
<field name="name">Forum Management</field>
<field name="sequence">7</field>
</record>
<record id="group_forum_user" model="res.groups">
<field name="name">User</field>
<field name="category_id" ref="module_category_forum"/>
<field name="implied_ids" eval="[(4, ref('base.group_user'))]"/>
</record>
<record id="group_forum_manager" model="res.groups">
<field name="name">Manager</field>
<field name="category_id" ref="module_category_forum"/>
<field name="implied_ids" eval="[(4, ref('group_forum_user'))]"/>
<field name="users" eval="[(4, ref('base.user_root'))]"/>
</record>
</data>
</openerp>
您的 security / ir.model.access.csv
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_forum_course,forum.course,model_forum_course,group_forum_user,1,1,1,1
access_forum_categ,forum.categ,model_forum_categ,group_forum_user,1,1,1,1
现在执行以下步骤。
注意:作为管理员,您可以授予用户权限。如果用户对论坛管理没有任何访问权限(保持为空),则用户不会显示模块。
在此之后,您可以显示您的模块。
答案 1 :(得分:0)
代码似乎对我很好。
您的非管理员用户怎么样?它在新组中吗?如果没有,请把它放在那里: - )
答案 2 :(得分:0)
在您的openerp客户端中,转到设置/技术/安全/访问权限。检查您的访问权限是否存在访问权限。