我是Odoo开发的新手。我想为产品添加产品品牌和国家。我刚刚在仓库的产品菜单下创建了品牌的表单视图和菜单。现在我想在产品视图中为品牌添加一个字段。我正在尝试为它扩展product.product模型,但发现模型未找到错误。我不知道发生了什么。
错误详情:
2016-03-09 09:18:15,609 2562 INFO hat_dev openerp.modules.loading:
loading 1 modules...
2016-03-09 09:18:15,620 2562 INFO hat_dev openerp.modules.loading: 1 modules loaded in 0.01s, 0 queries
2016-03-09 09:18:15,648 2562 INFO hat_dev openerp.modules.loading: loading 55 modules...
2016-03-09 09:18:15,807 2562 INFO hat_dev openerp.modules.module: module openautoparts_erp: creating or updating database tables
2016-03-09 09:18:15,838 2562 INFO hat_dev openerp.modules.loading: loading openautoparts_erp/product_brand/product_brand_views.xml
2016-03-09 09:18:15,893 2562 INFO hat_dev openerp.modules.loading: loading openautoparts_erp/product_brand/partner.xml
2016-03-09 09:18:15,919 2562 ERROR hat_dev openerp.addons.base.ir.ir_ui_view: Model not found: product.product
Error context:
View `partner.brand`
[view_id: 2112, xml_id: n/a, model: product.product, parent_id: 262]
2016-03-09 09:18:15,926 2562 INFO hat_dev werkzeug: 127.0.0.1 - - [09/Mar/2016 09:18:15] "POST /longpolling/poll HTTP/1.1" 500 -
2016-03-09 09:18:15,952 2562 ERROR hat_dev werkzeug: Error on request:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 177, in run_wsgi
execute(self.server.app)
File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 165, in execute
application_iter = app(environ, start_response)
File "/opt/odoo/odoo/openerp/service/server.py", line 290, in app
return self.app(e, s)
File "/opt/odoo/odoo/openerp/service/wsgi_server.py", line 216, in application
return application_unproxied(environ, start_response)
File "/opt/odoo/odoo/openerp/service/wsgi_server.py", line 202, in application_unproxied
result = handler(environ, start_response)
File "/opt/odoo/odoo/openerp/http.py", line 1290, in __call__
return self.dispatch(environ, start_response)
File "/opt/odoo/odoo/openerp/http.py", line 1264, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/openerp/http.py", line 1264, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/openerp/http.py", line 1264, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/openerp/http.py", line 1264, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/openerp/http.py", line 1264, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/openerp/http.py", line 1264, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/openerp/http.py", line 1264, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/openerp/http.py", line 1264, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/openerp/http.py", line 1264, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/openerp/http.py", line 1264, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/openerp/http.py", line 1264, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/openerp/http.py", line 1264, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/openerp/http.py", line 1264, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/openerp/http.py", line 1264, in __call__
return self.app(environ, start_wrapped)
File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 579, in __call__
return self.app(environ, start_response)
File "/opt/odoo/odoo/openerp/http.py", line 1428, in dispatch
ir_http = request.registry['ir.http']
File "/opt/odoo/odoo/openerp/http.py", line 346, in registry
return openerp.modules.registry.RegistryManager.get(self.db) if self.db else None
File "/opt/odoo/odoo/openerp/modules/registry.py", line 339, in get
update_module)
File "/opt/odoo/odoo/openerp/modules/registry.py", line 370, in new
openerp.modules.load_modules(registry._db, force_demo, status, update_module)
File "/opt/odoo/odoo/openerp/modules/loading.py", line 351, in load_modules
force, status, report, loaded_modules, update_module)
File "/opt/odoo/odoo/openerp/modules/loading.py", line 255, in load_marked_modules
loaded, processed = load_module_graph(cr, graph, progressdict, report=report, skip_modules=loaded_modules, perform_checks=perform_checks)
File "/opt/odoo/odoo/openerp/modules/loading.py", line 176, in load_module_graph
_load_data(cr, module_name, idref, mode, kind='data')
File "/opt/odoo/odoo/openerp/modules/loading.py", line 118, in _load_data
tools.convert_file(cr, module_name, filename, idref, mode, noupdate, kind, report)
File "/opt/odoo/odoo/openerp/tools/convert.py", line 901, in convert_file
convert_xml_import(cr, module, fp, idref, mode, noupdate, report)
File "/opt/odoo/odoo/openerp/tools/convert.py", line 987, in convert_xml_import
obj.parse(doc.getroot(), mode=mode)
File "/opt/odoo/odoo/openerp/tools/convert.py", line 853, in parse
self._tags[rec.tag](self.cr, rec, n, mode=mode)
File "/opt/odoo/odoo/openerp/tools/convert.py", line 763, in _tag_record
id = self.pool['ir.model.data']._update(cr, self.uid, rec_model, self.module, res, rec_id or False, not self.isnoupdate(data_node), noupdate=self.isnoupdate(data_node), mode=self.mode, context=rec_context )
File "/opt/odoo/odoo/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/odoo/openerp/addons/base/ir/ir_model.py", line 1064, in _update
res_id = model_obj.create(cr, uid, values, context=context)
File "/opt/odoo/odoo/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/odoo/openerp/addons/base/ir/ir_ui_view.py", line 255, in create
context=context)
File "/opt/odoo/odoo/openerp/api.py", line 268, in wrapper
return old_api(self, *args, **kwargs)
File "/opt/odoo/odoo/openerp/api.py", line 372, in old_api
result = method(recs, *args, **kwargs)
File "/opt/odoo/odoo/openerp/models.py", line 4094, in create
record = self.browse(self._create(old_vals))
File "/opt/odoo/odoo/openerp/api.py", line 266, in wrapper
return new_api(self, *args, **kwargs)
File "/opt/odoo/odoo/openerp/api.py", line 508, in new_api
result = method(self._model, cr, uid, *args, **old_kwargs)
File "/opt/odoo/odoo/openerp/models.py", line 4285, in _create
recs._validate_fields(vals)
File "/opt/odoo/odoo/openerp/api.py", line 266, in wrapper
return new_api(self, *args, **kwargs)
File "/opt/odoo/odoo/openerp/models.py", line 1272, in _validate_fields
raise ValidationError('\n'.join(errors))
ParseError: "ValidateError
Field(s) `arch` failed against a constraint: Invalid view definition
错误详情: 未找到型号:product.product
Error context:
View `partner.brand`
[view_id: 2112, xml_id: n/a, model: product.product, parent_id: 262]" while parsing /opt/odoo/custom/openautoparts_erp/product_brand/partner.xml:5, near
<record model="ir.ui.view" id="product_brand_form_view">
<field name="name">partner.brand</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Brands">
<group>
<field name="brand"/>
<field name="brand_ids"/>
</group>
</page>
</notebook>
</field>
</record>
我的模特是:
# -*- coding: utf-8 -*-
from openerp import fields, models
class Product(models.Model):
_inherit = 'product.product'
# Add a new column to the product.product model
brand = fields.Char("brand", required=True)
brand_ids = fields.One2many(
'product.brand', string='Brand Name', readonly=True)
我的观点文件是:
<?xml version="1.0" encoding="UTF-8"?>
<openerp>
<data>
<!-- Add brand field to existing view -->
<record model="ir.ui.view" id="product_brand_form_view">
<field name="name">partner.brand</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<notebook position="inside">
<page string="Brands">
<group>
<field name="brand"/>
<field name="brand_ids"/>
</group>
</page>
</notebook>
</field>
</record>
</data>
</openerp>
答案 0 :(得分:0)
检查 __ openerp __。py 文件中的依赖关系并添加 &#34;取决于&#34; :[&#34;产品&#34;] 模块,如果没有这样添加。
{
"name" : "product_brand",
"version" : "1.1",
"author" : "Open",
"category" : "Product Brands",
"depends" : ["base", "product"],
"installable": True,
}
答案 1 :(得分:0)
您的课程配置不正确
brand_ids = fields.One2many('product.brand', string='Brand Name', readonly=True)
应该是这样:
brand_ids = fields.One2many('product.brand', 'product_id', string='Brand Name', readonly=True)