我正在尝试像这样扩展产品模型
import logging
from openerp.osv import fields, osv
import time
import openerp.addons.decimal_precision as dp
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
from openerp.tools.translate import _
from openerp import netsvc
from datetime import datetime, date
_logger = logging.getLogger(__name__)
class product_override(osv.osv):
_name = 'product.prdouct'
_inherit = 'product.product'
_columns = {
'overheads' :fields.float('Overheads'),
'basic_cost': fields.float('Basic Cost'),
'min_charge' : fields.float('Min.Charge'),
}
和它的观点一样
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record id="product_view" model="ir.ui.view">
<field name="name">product.normal.form</field>
<field name="model">product.product</field>
<field eval="1" name="priority"/>
<field name="type">form</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='list_price']" position="after">
<field name="min_charge"/>
</xpath>
</field>
</record>
</data>
</openerp>
但我在安装自定义模块时遇到这些错误
2014-10-09 17:59:32,484 10020 ERROR OZB1 openerp.osv.orm: Can't find field 'min_charge' in the following view parts composing the view of object model 'product.product':
* product.normal.form
* product.normal.form
您错误地自定义了此视图,或者某些带有这些视图的模块与您当前的数据模型不兼容
2014-10-09 17:59:32,489 10020 ERROR OZB1 openerp.addons.base.ir.ir_ui_view: Can't render view itk_sales_extra_ozb.product_view for model: product.product
答案 0 :(得分:1)
我案中的解决方案:
由于某些原因,如果没有重新启动,OpenERP不允许将新创建的字段添加到视图中,即使有问题的字段是在正在安装的模块中定义的。