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.

0

Could I inherit from a custom module in odoo?

By
Jose Antonio
on 7/4/16, 11:18 AM 317 views

I have custom module in my odoo called "x_vehicles"

Could be possible to inherit from this module to overwrite the create method??

I've this code

class extend_vehicle(models.Model):
    _inherit = 'x_vehicle'

    @api.model
    def create(self, vals):

        # Do something...

        return super(extend_vehicle, self).write(vals)

But I get this error

2016-07-04 15:05:20,488 9217 ERROR pro werkzeug: Error on request:
Traceback (most recent call last):
  File "/Users/jose/Work/odoo/env/lib/python2.7/site-packages/werkzeug/serving.py", line 177, in run_wsgi
    execute(self.server.app)
  File "/Users/jose/Work/odoo/env/lib/python2.7/site-packages/werkzeug/serving.py", line 165, in execute
    application_iter = app(environ, start_response)
  File "/Users/jose/Work/odoo/openerp/service/server.py", line 246, in app
    return self.app(e, s)
  File "/Users/jose/Work/odoo/openerp/service/wsgi_server.py", line 184, in application
    return application_unproxied(environ, start_response)
  File "/Users/jose/Work/odoo/openerp/service/wsgi_server.py", line 170, in application_unproxied
    result = handler(environ, start_response)
  File "/Users/jose/Work/odoo/openerp/http.py", line 1493, in __call__
    return self.dispatch(environ, start_response)
  File "/Users/jose/Work/odoo/openerp/http.py", line 1467, in __call__
    return self.app(environ, start_wrapped)
  File "/Users/jose/Work/odoo/env/lib/python2.7/site-packages/werkzeug/wsgi.py", line 588, in __call__
    return self.app(environ, start_response)
  File "/Users/jose/Work/odoo/openerp/http.py", line 1642, in dispatch
    ir_http = request.registry['ir.http']
  File "/Users/jose/Work/odoo/openerp/http.py", line 363, in registry
    return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None
  File "/Users/jose/Work/odoo/openerp/modules/registry.py", line 355, in get
    update_module)
  File "/Users/jose/Work/odoo/openerp/modules/registry.py", line 386, in new
    openerp.modules.load_modules(registry._db, force_demo, status, update_module)
  File "/Users/jose/Work/odoo/openerp/modules/loading.py", line 334, in load_modules
    force, status, report, loaded_modules, update_module)
  File "/Users/jose/Work/odoo/openerp/modules/loading.py", line 237, in load_marked_modules
    loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
  File "/Users/jose/Work/odoo/openerp/modules/loading.py", line 132, in load_module_graph
    models = registry.load(cr, package)
  File "/Users/jose/Work/odoo/openerp/modules/registry.py", line 169, in load
    model = cls._build_model(self, cr)
  File "/Users/jose/Work/odoo/openerp/models.py", line 591, in _build_model
    original_module = pool[name]._original_module if name in parents else cls._module
  File "/Users/jose/Work/odoo/openerp/modules/registry.py", line 84, in __getitem__
    return self.models[model_name]
KeyError: 'x_vehicle'

I don't know if I need to extend from other model or do something special...

Please, Could anyone help me??

0
Jose Antonio
On 7/4/16, 12:14 PM

Yes, That's one of the problems... Thanks a a lot.

I've added the x_vehicle in the __openerp__.py file, but now I get this other error

ERROR pro openerp.modules.graph: module extended_vehicle: Unmet dependencies: x_vehicle

this is my actual __openerp__.py file

{
...
'category': 'Automation',
'version': '1',
# any module necessary for this one to work correctly
'depends': ['base','x_vehicle'],
# always loaded
'data': [

]
}

Everything looks fine, Isn't?

Also, I've been getting this message too

You try to install module 'vehicle' that depends on module 'x_vehicle'.But the latter module is not available in your system.



describe your module/models structure to move on

Axel Mendoza
on 7/4/16, 2:48 PM

EDIT: Maybe with the name "custom module" I've made a mistake... It's a module built inside odoo, not as an external module. I don't have the code of the module. It was built with the tool that odoo provides.

http://i.stack.imgur.com/V35TZ.png

I can't extract the structure because it's a little bit complicated extract all the functionality, so, I need to try to inherit from that module

I'll hope that this could be more specific

EDIT 2: I think that here is the problem... If I try to install the module that inherit the functionality, in the tab "Technical data" I can see that the model is Unknown... but I don't know why...

http://i.stack.imgur.com/V35TZ.png

Jose Antonio
on 7/5/16, 5:25 AM
0
Juan Carrasquel
On 7/4/16, 2:54 PM

VERIFICA QUE HAYAS CARGADO EL MODULO .XML EN EL ARCHIVO __openerp__.py  VERIFICA SI TODAS LAS VARIABLES ESCRITAS EN EL .XML SE ENCUENTRAN IGUAL EN EL .PY Y VERIFICA QUE ESTE LA VARIABLE EN TODAS LAS VISTAS ARBOL ....ECT EN TU .XML ASI COMO TAMBIEN LA INDENTACION EN EL .PY

This is an english forum, please use english language.

Ermin Trevisan
on 7/5/16, 12:56 AM
0

Axel Mendoza

--Axel Mendoza--
10203
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 7/4/16, 12:01 PM

That code seems to be ok, check the __openerp__.py of that module to be sure that the other module where is defined the model x_vehicle is in the depends list of the __openerp__.py. That could be causing that Odoo is your trying to load your module without been loaded the module that define the model x_vehicle. 

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

1 follower(s)

Stats

Asked: 7/4/16, 11:18 AM
Seen: 317 times
Last updated: 7/4/16, 3:06 PM