Module 奥多12。缺少字段所需的值';对象';(model_id)当我更改权限文件ir.model.access.csv并升级模块时

Module 奥多12。缺少字段所需的值';对象';(model_id)当我更改权限文件ir.model.access.csv并升级模块时,module,permissions,upgrade,odoo-12,Module,Permissions,Upgrade,Odoo 12,我已经在odoo 12中创建了自己的模块。我已经更改了权限文件-ir.model.access.csv。所有代码如下所示 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,,1,1,1,0 /型号/型号: # -*-

我已经在odoo 12中创建了自己的模块。我已经更改了权限文件-ir.model.access.csv。所有代码如下所示

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,,1,1,1,0
/型号/型号:

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

from odoo import models, fields, api

class StudentStudent(models.Model):
    _name = "student.student"
    _description = "description"
    name = fields.Char(string="Name", required=True)
    age = fields.Integer(string="Age")
    photo = fields.Binary(string="Image")
    gender = fields.Selection(
        [("male", "Male"), ("female", "Female"), ("others", "Others")], string="Gender"
    )
    student_dob = fields.Date(string="Date of Birth")
    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",
    )
    nationality = fields.Many2one("res.country", string="Nationality")

尝试升级模块时出现错误消息:

Exception: Module loading assettracking failed: file assettracking\security/ir.model.access.csv could not be processed:
 No matching record found for external id 'model_student_student' in field 'Object'
Missing required value for the field 'Object' (model_id)

检查您的模型是否已加载到数据库中,如果未加载,请在升级到加载之前重新启动服务器。如果您已经这样做了,请尝试在CSV文件中使用:
module\u name.model\u student\u student

请检查您是否已经为student.student模型编写了init.py文件


如果是,请尝试以下.csv文件中的代码
访问学生,访问学生,模型学生,1,1,0

我通常做的一个技巧是添加一个模型,然后启动服务器进程,系统将警告我此模型没有权限,并向您提供要添加到ir.model.access.csv的行的示例。我从shell窗口复制它,并将其粘贴到ir.model.access.csv中,然后进行相应的编辑

对于Odoo 12,我发现您需要在ir.model.access.csv文件中指定用户组和。如果未指定用户组,则不会为我的用户显示菜单项。 我设置了具有不同权限的自定义用户组,但通常的默认设置是为base.erp\u user和base.erp\u manager指定权限。这些条目的一个例子是

id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_student_student_user,access_student_student_user,model_student_student,base.group_user,1,1,1,0
access_student_student_admin,access_student_student_admin,model_student_student,base.group_erp_manager,1,1,1,1

在上述示例中,普通用户可以创建、读取和编辑学生记录,但不能删除记录,而管理员可以删除记录。如果您指定自定义用户组,则仅当登录用户在这些组中时,才会显示学生菜单选项。

我已重新启动服务器和数据库,并卸载和重新安装模块。我在重新安装模块时收到此消息。我正在窗口上使用odoo。我在本地主机浏览器上安装了该模块。重新启动services-odoo-server-12.0后,问题似乎得到了解决。但是模块中仍然不存在我的student_视图,我无法从应用程序的左上角访问模块../views/student_view.xml:。manifest.py:模块的解决方案未显示在左上角菜单上:我忘记在student_view.xml中定义操作菜单。更新文件我得到了解决方案。解决方案是重新启动服务器-对于windows,请转到任务管理器并查找服务,然后重新启动odoo服务器-(您的odoo版本)服务。