Resolving the Model not found Error in Odoo 12
Автор: vlogize
Загружено: 2025-03-30
Просмотров: 13
Описание:
Discover how to troubleshoot the 'Model not found' error in Odoo 12, including best practices for module setup and order of imports.
---
This video is based on the question https://stackoverflow.com/q/70782811/ asked by the user 'Admaja' ( https://stackoverflow.com/u/12149428/ ) and on the answer https://stackoverflow.com/a/70787131/ provided by the user 'Lenormju' ( https://stackoverflow.com/u/11384184/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions.
Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: Model not found in odoo 12
Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l...
The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license.
If anything seems off to you, please feel free to write me at vlogize [AT] gmail [DOT] com.
---
Resolving the Model not found Error in Odoo 12: A Guide for Beginners
When working with Odoo, you may occasionally run into errors that can be frustrating, especially if you’re just starting out. One common issue is when you encounter the message Model not found after upgrading your module. This error typically indicates that Odoo is unable to find the model you've defined in your custom module. If you've built a custom hospital module and received this error, you are not alone. In this guide, we will walk you through the problem and provide a clear solution.
The Problem: ‘Model not found’ Error
Here’s a brief overview of the error you might encounter when trying to upgrade your module:
[[See Video to Reveal this Text or Code Snippet]]
This message suggests that Odoo cannot find the model rumahsakit.poli, which you have likely defined in your custom module. There are a few reasons this could happen, especially if you’re new to Odoo development. The root cause often relates to how Odoo loads its modules and where your files are positioned.
Analyzing Your Code
Let’s examine the key elements of your code to better understand what to look for:
Model Definition
For the model, you might have written something like this:
[[See Video to Reveal this Text or Code Snippet]]
View Definition
You may also have defined the view in an XML file. Make sure it looks similar to this:
[[See Video to Reveal this Text or Code Snippet]]
The Solution: Properly Structuring Your Module
1. Verify Model and View Placement
One of the first things to check is the location of your model and view files. For Odoo to properly recognize them, both should reside in the same module, defined in your manifest file (__manifest__.py).
Ensure your model and its corresponding view are in the same directory and included in the manifest.
2. Check Import Order
Odoo loads modules in a specific order. If the view file is defined before the model is loaded, it will trigger the Model not found error.
To test whether your model is imported correctly, add a debug print statement at the top of your model file:
[[See Video to Reveal this Text or Code Snippet]]
This print statement will help you to confirm whether the model is being loaded when the module is initialized.
3. Update the Manifest File
Ensure that your __manifest__.py file includes both the model file and the view file in the data list:
[[See Video to Reveal this Text or Code Snippet]]
4. Testing Your Module Again
After making these adjustments, attempt to upgrade your module again:
Use the command line or Odoo UI to update the module.
[[See Video to Reveal this Text or Code Snippet]]
Conclusion
Encountering the Model not found error in Odoo 12 can be daunting, especially for newcomers. However, by following the simple steps outlined above, you can resolve this issue and continue developing your custom modules with confidence. Remember to check the placement and import order of your files, and you’ll be on the right track!
Happy Coding!
If you have any questions or further clarifications on Odoo development, feel free to leave a comment below.
Повторяем попытку...

Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: