继承视图并添加字段 [英] Inherit view and adding fields

查看:48
本文介绍了继承视图并添加字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在产品表单视图的价格表下添加我的2个字段的船长和加油量,但它们没有显示.我想念什么.

I want to add my 2 fields boatlenght and fuelcapacity under price list in product form view but they are not showing up. What did i miss.

    <?xml version="1.0" encoding="utf-8"?>

    <openerp>
        <data>
            <!-- Inherit Form View to Modify it -->
            <record id="product_product_template_only_form_view" model="ir.ui.view">
                <field name="model">product.product</field>
                <field name="inherit_id" ref="product.product_template_only_form_view"/>
                <field name="arch" type="xml">
                    <field name="list_price" position="after">
                       <field name="boatlenght"/>
                       <field name="fuelcapacity"/>
                </field>
                </field>
            </record>


        </data>
    </openerp>

  from openerp import models, fields, api

  class ProductProduct(models.Model):
    _inherit = 'product.product'

    boatlenght = fields.Char(string="Lenght of the Boat", required=False, )
    fuelcapacity = fields.Char(string="Fuel Capacity", required=False, )

推荐答案

尝试

<record id="product_product_template_only_form_view" model="ir.ui.view">
                <field name="model">product.product</field>
                <field name="inherit_id" ref="product.product_template_only_form_view"/>
                <field name="arch" type="xml">
                    <xpath expr="//field[@name='list_price']" position="after">
                       <field name="boatlenght"/>
                       <field name="fuelcapacity"/>
                    </xpath>
                </field>
            </record>

为了正确地插入该字段,请正确使用一个将其插入DOM的xpath表达式.

In order to insert the field properly you use an xpath expression to insert it on the DOM.

检查文档.

这篇关于继承视图并添加字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆