Odoo Help

1

Why am I getting "Invalid model name in the action definition"?

By
Shaun Dawson
on 5/30/13, 3:22 AM 6,065 views

I'm new to OpenERP, and I've been trying to create a custom module. A trivial module with a single model works fine, but as soon as I try to add a second model (with a view), I get an "Invalid model name in the action definition" error on import.

I am using OpenERP 7.0-20130524-231019, installed using apt-get on a Ubuntu server.

If I comment out the view, the model will import fine, but the second model doesn't appear in to Model list, so I'm sure that the error is legit, but why isn't the second module actually being created?

My files are as follows:

__init__.py:

# -*- coding: utf-8 -*-
import dev

__openerp__.py:

# -*- coding: utf-8 -*-

{
    "name" : "Dev module",
    "version" : "0.1",
    "author" : "Dev",
    'complexity': "easy",
    "description" : """
This is a test
==============

This is only a test.
    """,
    "website" : "[a real URL]",
    "depends" : [],
    "category" : "Dev",
    "sequence": 16,
    "init_xml" : [],
    "demo_xml" : [],
    "update_xml" : ["dev_view.xml",],
    'test': [],
    'installable': True,
    'application': True,
    'active': False,
}

Here's the .py:

class dev_person(osv.Model):
    _name = "dev.person"
    _description = "Person"
    _columns = {
        'name': fields.char('Person Name', size=128, required=True),
        'properties': fields.one2many('dev.property', 'property_id', 'Properties'
    }

dev_person()


class dev_property(osv.Model):
    _name = "dev.property"
    _description = "Property"
    _columns = {
        'name': fields.char('Property Name', size=128, required=True),
        'property_id': fields.many2one('dev.person', 'Person Name', select=True),
    }

dev_property()

And dev_view.xml:

<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>

<record model="ir.actions.act_window" id="action_dev_person_form">
<field name="name">dev_person</field>
<field name="res_model">dev.person</field>
</record>

<record model="ir.actions.act_window" id="action_dev_property_form">
<field name="name">dev_property</field>
<field name="res_model">dev.property</field>
</record>

<menuitem name="Dev" icon="terp-project" id="dev_menu" />
<menuitem name="Dev" parent="dev_menu" id="dev_menu_header" />

<menuitem name="Person" parent="dev_menu_header" id="dev_menu_person" action="action_dev_person_form" />
<menuitem name="Property" parent="dev_menu" id="dev_menu_property" action="action_dev_property_form" />

</data>
</openerp>

Any thoughts?

0
Atul Arvind
On 10/28/16, 11:19 AM

if you get the error Invalid model name in the action definition, check the followings

  1. check the model name in the model file you have defined.

  2. In __init__.py file whether the model file is imported or not. 

  3. check for the dependency (in most cases when you use <act_window )

1
Ghanshyam Prajapati
On 5/30/13, 9:28 AM

Hey Shaun,

I just install your custom module, it works fine without error, i think problem is in your __init__.py file.

have you imported your py file in __init__.py ??? for example, suppose you have py file named test.py, have you imported your py file in __init__.py???

in __init__.py,

import test

The second one problem is, i cant see any view of dev.property object,

I suggest you to make seperate form view, tree view, search view of dev.person object and dev.property object.

Thanks for your response, Ghanshyam! I've edited the question to include my __init__.py, and the rest of the files in the module as well. I definitely am including my module's .py in the import statement (and the other model, which is defined in that same module does successfully get imported).

Shaun Dawson
on 5/30/13, 12:00 PM
1
Shaun Dawson
On 5/30/13, 1:28 PM

I believe that I've solved it.

It turns out that I had a bug in my module's .py file that kept it from compiling (that bug is present in the examples I gave... there's a missing end parenthesis).

This prevented any models from working, except for one model, dev.person, and I'm not sure why.

I finally noticed the problem when I got a compile error on trying to update the openerp package using apt-get. Once I saw that, I fixed the bug, and then started using the command line to update my modules rather than the Web UI. I also made sure that the openerp python process was actually dead when I stopped the server. Serveral times, it wasn't, and the process had to be killed.

Now that I am using openerp -d <database> --update <module>, I'm getting the expected behavior.

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

2 follower(s)

Stats

Asked: 5/30/13, 3:22 AM
Seen: 6065 times
Last updated: 4/4/17, 1:26 AM