【问题标题】:Odoo 13.0 Can't see my installed module on the menuOdoo 13.0 在菜单上看不到我安装的模块
【发布时间】:2020-04-20 22:46:03
【问题描述】:

我是 Odoo 13.0(和任何 Odoo 版本)的新手。我刚刚构建了我的第一个模块,并成功安装了它。问题是我在菜单上看不到我安装的模块。我已经尝试重新启动服务器,并且我已经研究了这些来源,但似乎任何东西都对我有用:

来源

  1. Odoo Official Docs
  2. Custom module doesn't show up in the list of apps
  3. My module is installed but i cannot see it in the menu

这是我的文件,希望有人能指出正确的方向。

__manifest__.py

# -*- coding: utf-8 -*-
{
    'name': "sample_app",

    'summary': """
        Short (1 phrase/line) summary of the module's purpose, used as
        subtitle on modules listing or apps.openerp.com""",

    'description': """
        Long description of module's purpose
    """,

    'author': "My Company",
    'website': "http://www.yourcompany.com",

    # Categories can be used to filter modules in modules listing
    # Check https://github.com/odoo/odoo/blob/13.0/odoo/addons/base/data/ir_module_category_data.xml
    # for the full list
    'category': 'Uncategorized',
    'version': '0.1',

    # any module necessary for this one to work correctly
    'depends': ['base'],

    # always loaded
    'data': [
        # 'security/ir.model.access.csv',
        'views/views.xml',
        'views/templates.xml',
    ],
    # only loaded in demonstration mode
    'demo': [
        'demo/demo.xml',
    ],
    'installable':True,
    'auto_install':False,
    'application':True
}

__init__.py

# -*- coding: utf-8 -*-

from . import controllers
from . import models

models/models.py

# -*- coding: utf-8 -*-

from odoo import models, fields, api

class StudentRecord(models.Model):
    _name = "student.student"
    name = fields.Char(string="Name", required=True)
    middle_name = fields.Char(string="Middle Name", required=True)
    last_name = fields.Char(srtring="Last Name", required=True)
    photo = fields.Binary(string="Photo")
    student_age = fields.Integer(string="Age")
    student_dob = fields.Date(string="Date of Birth")
    student_gender = fields.Selection([("m","Male"),("f","Female"),("o","Other")], string="Gender")
    student_blood_group = fields.Selection(
            [
                ("A+","A+ve"),
                ("B+","B+ve"),
                ("O+","O+ve"),
                ("AB+","AB+ve"),
                ("A-","A-ve"),
                ("B+","B-ve"),
                ("O-","O-ve"),
                ("AB-","AB-ve"),
                ], string = "Blood Group")

views/views.xml

<?xml version="1.0" encoding="UTF-8"?>
<odoo>

  <record id="view_student_form" model="ir.ui.view">
    <field name="name">student.student.form</field>
    <field name="model">student.student</field>
    <field name="priority" eval="8" />
    <field name="arch" type="xml">
        <form string="Student">
            <sheet>
                <field name="photo" widget="image" class="oe_left oe_avatar" />
                <div class="oe_title">
                    <h1>
                        <table>
                            <tr>
                                <td style="padding-right:10px;"><field name="name" required="1" placeholder="First Name" /></td>
                                <td style="padding-right:10px;"><field name="middle_name" placeholder="Middle Name" /></td>
                                <td style="padding-right:10px;"><field name="last_name" placeholder="Last Name" /></td>
                            </tr>
                        </table>
                    </h1>
                </div>
                <notebook colspan="4">
                    <page name="personal_information"
                        string="Personal Information">
                        <group col="4" colspan="4"
                            name="personal_detail">
                            <field name="student_gender" />
                            <field name="student_age" />
                            <field name="student_dob" />
                            <field name="student_gender" />
                            <field name="student_blood_group" />
                        </group>
                    </page>
                </notebook>
            </sheet>
        </form>
    </field>
  </record>

  <record model="ir.actions.act_window" id="action_view_students">
    <field name="name">Students</field>
    <field name="res_model">student.student</field>
    <field name="view_mode">tree,form</field>
    <field name="domain">[]</field>
  </record>

  <menuitem id="menu_school" name="School"/>
  <menuitem id="school_student" name="Students" parent="menu_school" action="action_view_students"/>

</odoo>

编辑: 这是菜单的图像,我希望在安装后看到我的 sample_test 应用程序。

此外,Odoo 会在此处显示我安装的应用:

感谢您在这件事上的宝贵时间和帮助。谢谢!!

【问题讨论】:

    标签: python odoo odoo-13


    【解决方案1】:

    发生这种情况是因为 security file。因为您没有为该模型设置安全性。

    让我更详细地解释一下:您正在使用菜单和所有这些东西创建自定义模型和视图,但您没有分配任何可以阅读这些东西的人,谁可以,谁可以删除等等,这就是为什么您会遇到这个问题,您的视图已创建并且您的带有自定义字段的模型已在后端成功创建,但是不可见

    为此,我们将使用我们的安全文件来授予对我们所需的访问权限 组/用户

    security/ir.model.access.csv

    id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink access_student_student,access.student.student,model_student_student,base.group_user,1,1,1,1

    在这里您可以看到我正在授予对 base.group_user 的访问权限以及我授予的访问权限是什么?在这里你可以看到 1s 表示是,我正在授予读取权限(prem_read),写入权限(prem_write),创建权限(prem_create) 和最后一个删除权限(prem_unlink)。

    读取权限将使您能够以图形形式读取(查看)您的模型。

    注意:不要忘记在数据列表的清单文件中添加安全文件

    【讨论】:

      【解决方案2】:

      我刚刚找到了方法。这些是我解决问题所遵循的步骤:

      1. 如图所示,我的菜单上没有学校模块。

      1. 所以,我去了设置并激活了开发者模式(第一个)

      1. 然后在页面重新加载后,我的主栏(不确定它的实际名称)变成了这样:

      1. 我注意到我的主栏中出现了一个错误

      1. 然后出于好奇,我点击了bug并选择了成为超级用户选项

      1. 我注意到我的主栏变成了这样:

      1. 最后,打开菜单后,我的模块出现了!! (万岁!)

      而且,故事到此结束(目前)我仍然需要弄清楚如何将这些更改部署到生产中,但我的朋友们是另一回事!

      谢谢!

      【讨论】:

      • 超级用户绕过安全规则。您需要为您的模型添加security rules 并指定哪些组可以访问菜单项(转到设置/技术/用户界面/菜单项,然后在访问权限选项卡中配置组)。
      • 谢谢,@Kenly。所以我必须首先添加组,我想我的应用程序将有两个组:用户和管理员,用户将只有读取权限,管理员将具有读/写权限。那是对的吗?所以我还必须在 Odoo 13.0 UI 管理员和用户中创建两个组。
      • 是的。您还可以使用现有的组和用户。例如base.user_admin (admin) 是人类管理员用户,base.user_root 是技术管理员用户,您可以将普通用户添加到base.group_user(用户类型/内部用户)。
      • 好的,非常感谢!我会试一试并更新这个答案,看看效果如何!
      【解决方案3】:

      这通常发生在我们没有在清单中添加我们的安全文件时,我在代码中看到它被注释掉了

      【讨论】:

        【解决方案4】:

        另一个提示,将您的用户设置为正确的组:

        设置/管理用户/您的用户(编辑)/其他/
        勾选 [ ] 适当的组 - 例如您的模块:管理员

        【讨论】:

          猜你喜欢
          • 2020-10-22
          • 2014-12-19
          • 2017-06-14
          • 1970-01-01
          • 2019-07-21
          • 1970-01-01
          • 1970-01-01
          • 2021-08-01
          • 2017-09-04
          相关资源
          最近更新 更多