You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Odoo V11模块安装报错:无效模型名'kroshu.product'

Fixing "Invalid model name 'kroshu.product' in action definition" Error in Odoo 11

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.product or kroshu.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 models directory 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:

  1. Stop the Odoo server completely
  2. Delete all __pycache__ folders in your module directory
  3. 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 09:08:31