我正在继承fleet.vehicle.log.services
视图,到目前为止,我已经在表单中添加了一些行,如下所示:
<record model='ir.ui.view' id='fleet_vehicle_log_services_form_inherit'>
<field name='name'>fleet.vehicle.log.services.form</field>
<field name='model'>fleet.vehicle.log.services</field>
<field name='inherit_id' ref='fleet.fleet_vehicle_log_services_form'/>
<field name="priority">90</field>
<field name='arch' type='xml'>
<xpath expr="//form/sheet/group" position="after">
<group string="Ubicaciones de Productos" col="2">
<field name="x_location_src_id" />
<field name="x_location_dest_id" />
</group>
<group string="Products">
<field name="x_move_line" nolabel="1" widget="one2many_list" context="{'x_location_src_id':x_location_src_id, 'x_location_dest_id':x_location_dest_id}">
<tree decoration-info="state == 'draft'" decoration-muted="state in ('cancel','done')" decoration-danger="state in ('confirmed','waiting')" string="Products to Consume">
<field name="product_id"/>
<field name="product_uom_qty" string="Quantity"/>
<field name="product_uom" options="{'no_open':True,'no_create':True}" string="Unit of Measure" groups="product.group_uom"/>
<field name="state" invisible="1"/>
</tree>
</field>
</group>
</xpath>
</field>
</record>
到目前为止,非常好。
现在,我想在表单的顶部添加一个<h1>
元素,这是我做过的一个序列。
但问题是,它说它在父视图中找不到<h1>
元素,当然,它不存在,我试图从这个继承的元素中添加它,如下所示:
<record model='ir.ui.view' id='fleet_vehicle_log_services_form_inherit'>
<field name='name'>fleet.vehicle.log.services.form</field>
<field name='model'>fleet.vehicle.log.services</field>
<field name='inherit_id' ref='fleet.fleet_vehicle_log_services_form'/>
<field name="priority">90</field>
<field name='arch' type='xml'>
<h1>
<field name="name" readonly="1"/>
</h1>
<xpath expr="//form/sheet/group" position="after">
<group string="Ubicaciones de Productos" col="2">
<field name="x_location_src_id" />
<field name="x_location_dest_id" />
</group>
<group string="Products">
<field name="x_move_line" nolabel="1" widget="one2many_list" context="{'x_location_src_id':x_location_src_id, 'x_location_dest_id':x_location_dest_id}">
<tree decoration-info="state == 'draft'" decoration-muted="state in ('cancel','done')" decoration-danger="state in ('confirmed','waiting')" string="Products to Consume">
<field name="product_id"/>
<field name="product_uom_qty" string="Quantity"/>
<field name="product_uom" options="{'no_open':True,'no_create':True}" string="Unit of Measure" groups="product.group_uom"/>
<field name="state" invisible="1"/>
</tree>
</field>
</group>
</xpath>
</field>
</record>
所以,我的问题是,如何通过继承将其添加到表单之上?
原始表单代码如下:
<record model='ir.ui.view' id='fleet_vehicle_log_services_form'>
<field name="name">fleet.vehicle.log.services.form</field>
<field name="model">fleet.vehicle.log.services</field>
<field name="arch" type="xml">
<form string="Services Logs">
<sheet>
<group col="2">
<group string="Services Details">
<field name="vehicle_id" on_change="on_change_vehicle(vehicle_id)"/>
<field name="cost_subtype_id" string="Service Type" domain="['|',('category','=','service'),('category','=','both')]" required="1"/>
<field name="amount"/>
</group>
<group string="Odometer Details">
<label for="odometer"/>
<div class="o_row">
<field name="odometer"/>
<field name="odometer_unit"/>
</div>
</group>
</group>
<group col="2">
<group string="Additional Details">
<field name="date" />
<field name="purchaser_id" />
<field name="vendor_id" context="{'default_supplier': True}"/>
<field name="inv_ref" />
</group>
</group>
<group string="Included Services">
<field name="cost_ids" nolabel="1">
<tree string="Included Services" editable="bottom">
<field name="cost_subtype_id" string="Service" domain="[('category','=','service')]"/>
<field name="amount" sum="Price" string="Indicative Cost"/>
</tree>
</field>
</group>
<group string="Notes">
<field nolabel="1" name="notes" placeholder="Write here any other information related to the service completed."/>
</group>
</sheet>
</form>
</field>
</record>
问题是,我从未在form string
之前添加对象如何在此之前添加此项?
我知道我不能去<field name="field" position="before">
句。
我怎样才能做到这一点?
答案 0 :(得分:1)
如果我说得对,你想在表单中添加典型的“名称”,就像在其他Odoo表单视图中一样。
尝试以下方法:
<xpath expr="//form//sheet//group[1]" position="before">
<div class="oe_title">
<label for="name" class="oe_edit_only" />
<h1>
<field name="name" />
</h1>
</div>
</xpath