Search code examples
modulepermissionsupgradeodoo-12

Odoo 12. Missing required value for the field 'Object' (model_id) when I change the permission file ir.model.access.csv and upgrade the module


I have created my own module in odoo 12. And I have change the permission file- ir.model.access.csv. All the code is as below.

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

./models/models :

# -*- 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")

error message occur when I try to upgrade my module :

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)

Solution

  • Check if your model is loaded into the database, if not restart your server before upgrading to load it. If you already did that try using: module_name.model_student_student in your CSV file.