我的odoo中有自定义模块,名为" x_vehicles"
是否可以从此模块继承以覆盖create方法??
我有这段代码
class extend_vehicle(models.Model):
_inherit = 'x_vehicle'
@api.model
def create(self, vals):
# Do something...
return super(extend_vehicle, self).write(vals)
但是我收到了这个错误
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'
我不知道我是否需要从其他模特扩展或做一些特别的事情......
拜托,有人可以帮助我吗?
编辑:可能使用名称"自定义模块"我犯了一个错误...... 它是在odoo内部构建的模块,而不是外部模块。我没有模块的代码。它是用odoo提供的工具构建的。
我无法提取结构,因为它有点复杂提取所有功能,因此,我需要尝试从该模块继承
我希望这可能更具体
编辑2:我认为这是问题所在...... 如果我尝试安装继承该功能的模块,请在选项卡"技术数据"我可以看到模型是未知的......但我不知道为什么......
此外,这是我的实际 openerp .py文件
{
...
'category': 'Automation',
'version': '1',
# any module necessary for this one to work correctly
'depends': ['base','x_vehicle'],
# always loaded
'data': [
]
}
答案 0 :(得分:1)
是的,这是可能的。
打开__openerp__.py
文件并使用以下密钥进行更新
"depends" : [
'base', 'list_of_core_module', 'your_custom_module_name'
],
其中
list_of_core_module 如销售,购买,帐户等......,
your_custom_module_name 您已声明 x_vehicles 类
在您处理时重新启动服务器并升级当前模块。