how to solve error 'model doesnt exist in the registry'

Jeevachaithanyan Sivanandan - Oct 24 '23 - - Dev Community

If you are new to Odoo development, you may sometimes end up in this situation when creating custom modules that inherit from existing base models.

For example, if you need to inherit the **mrp.production **model to your custom module model, you can write the following code:


class MrpProduction(models.Model):
_inherit = 'mrp.production'

and my manifest.py as below


{
'name': 'Training Addon ',
'version': '1.1',
'category': '',
'author': '',
'summary': "creating new fields in MO",
'description': """ To add 2 new fields in MO """,
'website': '',
'depends': ['base'],
'data': [],
'installable': True,
'application': True,
'auto_install': False,
}

but once you run the Odoo, you will get an error as below

TypeError: Model 'mrp.production' does not exist in registry.

This is because the manifest.py file does not mention the dependency module for this inheritance, which is the base module 'mrp'. To fix this error, add the 'mrp' module to the line:

python

depends': ['base','mrp'],

now the error will be gone!

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .