问题
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, )
回答1:
Try
<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>
In order to insert the field properly you use an xpath expression to insert it on the DOM.
Check the documentation.
来源:https://stackoverflow.com/questions/42248731/inherit-view-and-adding-fields