Odoo V11模块安装报错:无效模型名'kroshu.product'
I’ve run into this exact issue multiple times when building Odoo modules—let’s break down what’s happening and how to resolve it quickly.
First, let’s restate the error you’re seeing to make sure we’re on the same page:
File "C:\Program Files (x86)\Odoo 11.0\server\odoo\addons\base\ir \ir_actions.py", line 128, in check_model
raise ValidationError(('Invalid model name %r in action definition.') % action.res_model)
odoo.tools.convert.ParseError: "Invalid model name 'kroshu.product' in action definition. None" while parsing file:/c:/pro...
This error tells you that Odoo can’t locate a model with the technical name kroshu.product when it tries to process one of your module’s action definitions (like a menu item, window action, or report action). Here are the most likely fixes:
1. Double-Check Your Model’s Technical Name
First, confirm that your model’s _name attribute exactly matches kroshu.product. Odoo is case-sensitive here, so even a tiny typo will break things.
In your model file (e.g., models/product.py), you should have something like:
from odoo import models, fields class KroshuProduct(models.Model): _name = 'kroshu.product' # This must match the res_model in your action _description = 'Kroshu Inventory Product' # Your model fields go here
If you named your model something else (like kroshu.products or kroshu_product), update your action’s res_model to match the actual _name value.
2. Fix Typos in Your Action XML
Next, look through all XML files in your module’s views directory for any action that references res_model="kroshu.product". Common mistakes include:
- Misspelling the model name (e.g.,
kroshuu.productorkroshu.prod) - Using underscores instead of dots (or vice versa) if your model uses a different separator
- Accidental spaces before or after the model name
A correct window action example:
<record id="action_kroshu_product_list" model="ir.actions.act_window"> <field name="name">Kroshu Products</field> <field name="res_model">kroshu.product</field> <!-- Must match model's _name exactly --> <field name="view_mode">tree,form</field> <field name="context">{}</field> </record>
3. Ensure Your Model Is Properly Loaded
Odoo won’t recognize your model if it’s not included in your module’s initialization files:
- Check that your model file is imported in
models/__init__.py(if you have a subdirectory):# kroshu/models/__init__.py from . import product - Make sure the
modelsdirectory is imported in your module’s root__init__.py:# kroshu/__init__.py from . import models - Verify your
__openerp__.py(manifest file for Odoo 11) includes your model files and views. Your manifest should have sections like:{ 'name': 'Kroshu Inventory Management', 'version': '1.0', 'author': 'Your Name', 'depends': ['stock'], 'data': [ 'views/product_views.xml', # Add other view/action files here ], 'installable': True, 'auto_install': False, }
4. Clear Cache and Restart Odoo
Sometimes Odoo caches old model definitions, so try these steps:
- Stop the Odoo server completely
- Delete all
__pycache__folders in your module directory - Restart the server and attempt to install the module again
If you’re still stuck, share a snippet of your model code and the problematic action XML, and we can troubleshoot further!
内容的提问来源于stack exchange,提问作者Khalil Kasmi

