Odoo Help

Welcome!

This community 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.

1

Why do I get a unexisting parent class error when I inherit a model?

By
Yenthe
on 4/2/15, 3:31 AM 1,070 views

Hi guys,

I would like to inherit the model 'account.analytic.account' but when I do so I get the following error:

TypeError: The model "account.analytic.account" specifies an unexisting parent class "fleet.vehicle"
You may need to add a dependency on the parent class' module. 
I've created a custom module named 'aa_auto_maatwerk' with the following code.
__init__.py:
 # -*- coding: utf-8 -*-
import controllers
import models

__openerp__.py

 # -*- coding: utf-8 -*-
{
    'name': "aa_auto_maatwerk",

    'summary': """Extending fleet""",

    'description': """
        Extending some features """,

    'author': "Your Company",
    'website': "http://www.yourcompany.com",
    'category': 'Uncategorized',
    'version': '0.1',

    # any module necessary for this one to work correctly
    'depends': ['base', 'fleet', 'analytic'],

    # always loaded
    'data': [
        # 'security/ir.model.access.csv',
        'templates.xml',
    ],
    # only loaded in demonstration mode
    'demo': [
        'demo.xml',
    ],
}

models.py:

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

from openerp.osv import osv, fields, orm

class aa_auto_maatwerk(orm.Model):
    _name = 'account.analytic.account'
    _inherit = ['account.analytic.account']
    _columns = {
        'car_ids': fields.many2many('fleet.vehicle', 'fleet_to_contract', 'car_id1', 'car_id2', 'Cars'),
    }

Why am I getting this and what is wrong with this? The model exists in the database. I want this to lay a link to car.vehicle with a one2many.

2

Baiju

--Baiju--
3154
| 5 4 8
Kochi, India
--Baiju--
ODOO technical and functional

        I like learning new thing, especially technical thing. I am a quick learner, I can learn technical things very fast. I have good logical skill,  I have immense interest in programming.

e-mail id : baijuks@hotmail.com

Baiju
On 4/2/15, 3:42 AM

Hi ,,

First of all:-

Please check that you included  the inherited object Module name in your module __openerp__.py -> "depends"

Normally if you don't it will give this kind of error.

If that doesn’t solves the problem,  Please try:-

_name = 'your_object_name'
_inherit = ['account.analytic.account']

or if you want to Inherit the same object and add additional field you can use like:-

_inherit = 'account.analytic.account' 

Hope this solves the problem...

Thanks for the quick reply Baiju! This keeps throwing me the KeyError though.. :s

Yenthe
on 4/2/15, 4:11 AM

Hi Yenthe , i updated the answer, please that about this....

Baiju
on 4/2/15, 4:18 AM

Hi Baiju, turns out the .pyc file was still having the old version and ment that the other module wasn't loaded in the __openerp__.py. However I now have a dependency error. Any clue on this? I've updated my whole question with all the new code, error etc. I'll upvote your answer for now, thanks :)

Yenthe
on 4/2/15, 4:28 AM

Fixed this. In the __openerp__.py of the analytic module I also had to add a dependency for fleet, since I also use this in my custom module.

Yenthe
on 4/2/15, 4:36 AM

Hi Yenthe,did this solved the problem??

Baiju
on 4/2/15, 5:33 AM

Yes it did! I just needed to add depends on the other module that I inherited from too.

Yenthe
on 4/2/15, 7:36 AM
1

Temur

--Temur--
2894
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 4/2/15, 4:48 AM

you do not need to have 'base' in dependency list... when you add new module in dependency list and that module has some dependency already listed in your list, then you should remove from dependency list such entries. module 'fleet' depends on 'base', so 'base' should be removed after adding the 'fleet'

Good catch Temur! I've removed it from my module, thanks. Upvoted ;)

Yenthe
on 4/2/15, 4:57 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

2 follower(s)

Stats

Asked: 4/2/15, 3:31 AM
Seen: 1070 times
Last updated: 8/14/15, 1:59 AM