我是Odoo v8.0的初学者 . 我想在模块"sale"中添加自定义字段 . 错误是“字段 type_customer
不存在”
所以我的代码在这里 .
__init__.py
:
from . import modify_type_quotation
__openerp__.py
:
{
'name' : "Modify report template",
'description' : """Modify report template for Quotation/Sale report""",
'author' : "Nhu Van Tran",
'category' : "Tools",
'depends' : ['sale'],
'data' : ['modify_create_quotation.xml'],
'demo' : [],
'installable' : True,
}
modify_type_quotation.py
:
# -*- coding: utf-8 -*-
from openerp import models, fields
class modify_print_content(models.Model):
_inherit = "sale.order"
_description = "Modify Print Content"
type_customer = fields.selection([
('Commercial', 'Commercial Customer'),
('Residential', 'Risidential Customer'),
], string = "Type of Customer", help = "Type of Customer", default = "Commercial", required = True)
和 modify_create_quotation.xml
:
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
<record model = "ir.ui.view" id = "modify_view_sale">
<field name ="name">sale.order.form</field>
<field name = "model">sale.order</field>
<field name = "inherit_id" ref="sale.view_order_form"></field>
<field name="arch" type="xml">
<xpath expr="/form/sheet/group/group[2]/field[@name='client_order_ref']" position="after">
<field name="type_customer">Type customer</field>
</xpath>
</field>
</record>
</data>
</openerp>
2 回答
我认为错误是
fields.selection
,你用's'小写,这可能是错误 .确保重新启动odoo服务器,以使这些事情生效 .
您在xpath中的字段可能更短:
我不知道是否是问题,但在选择域声明中添加了一个aditional参数:
我认为解决方案可能是这样的:这会将字段添加到sale.order而不是仅继承已有的字段