<h1> 为继承形式添加标题 - Odoo v9 社区



我继承了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">句子。

我怎样才能做到这一点?

如果我没猜错,您想将典型的"名称"添加到表单中,就像在其他 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

最新更新