Odoo-视图中的多级继承

问题描述

我正在尝试使用具有多级继承的视图,但是子视图中的字段未显示。我目前正在使用Odoo 11(社区版)。

请在下面查看详细信息:

尝试为将来的向导提供一些基本模型。这是定义模型的方式(始终使用 inherit = 进行模型之间的继承)

Model definition

由于我只想定义一次视图,因此我按照相同的方法为每个模型创建了一个表单视图:始终从“上面”继承。以下是(第一个)基本视图的定义,模型为 handleprocess.quick.action

<record model="ir.ui.view" id="handleprocess_qact_abstract_wz_form_view">
        <field name="name">handleprocess_qact_abstract_wz.form</field>
        <field name="model">handleprocess.quick.action</field>
        <field name="arch" type="xml">
            <form string="Quick Action">
                <group class="bg-info" col="4" id="security_check_group">
                    <h6 colspan="4" style="color: red">Are you sure you want to execute this Quick Action?</h6>
                    <h6 colspan="4">Check to confirm you know what you are doing: <field name="security_check" nolabel="1" /></h6>
                </group>
                <group id="basic_fields">
                    <field name="environment" />
                    <field name="data_center" attrs="{'invisible': [('environment','!=','prod')],'required': [('environment','=','prod')]}" />
                </group>
                <footer class="pull-right">
                    <button name="execute_qact" type="object" string="Execute" class="oe_highlight" attrs="{'invisible': [('security_check',False)]}" />
                    <button special="cancel" string="Cancel" />
                </footer>
            </form>
        </field>
    </record>

然后,接下来的3个视图中的每个视图都使用 xpath 并添加自己的字段从“上”继承。

这是第二个视图,模型为 handleprocess.quick.action.update.file

<record model="ir.ui.view" id="handleprocess_qact_abstract_wz_form_view">
        <field name="name">handleprocess_qact_abstract_wz.form</field>
        <field name="model">handleprocess.quick.action</field>
        <field name="arch" type="xml">
            <form string="Quick Action">
                <group class="bg-info" col="4" id="security_check_group">
                    <h6 colspan="4" style="color: red">Are you sure you want to execute this Quick Action?</h6>
                    <h6 colspan="4">Check to confirm you know what you are doing: <field name="security_check" nolabel="1" /></h6>
                </group>
                <group id="basic_fields">
                    <field name="environment" />
                    <field name="data_center" attrs="{'invisible': [('environment',False)]}" />
                    <button special="cancel" string="Cancel" />
                </footer>
            </form>
        </field>
    </record>

如果此时显示该模型的表单视图,则所有字段均正确显示。在第二级继承后,即在我定义此视图之后(对于模型 handleprocess.quick.action.update.file.intergate ),字段消失了:

<record model="ir.ui.view" id="handleprocess_qact_abstract_ig_wz_form_view">
        <field name="name">handleprocess_qact_abstract_ig_wz.form</field>
        <field name="model">handleprocess.quick.action.update.file.intergate</field>
        <field name="inherit_id" ref="handleprocess.handleprocess_qact_update_file_wz_form_view"/>
        <field name="arch" type="xml">
            <data>
                <xpath expr="//field[@name='create_backup']" position="before">
                    <field name="carrier_id" options="{'no_create': True}" />
                </xpath>
            </data>
        </field>
    </record>

并且在向导的表单视图下方,存在相同的问题:未显示任何字段。

<record model="ir.ui.view" id="handleprocess_qact_ig_template_wz_form_view">
        <field name="name">handleprocess_qact_ig_template_wz.form</field>
        <field name="model">handleprocess.qact.ig.template.wz</field>
        <field name="inherit_id" ref="handleprocess_qact_abstract_ig_wz_form_view"/>
        <field name="priority">70</field>
        <field name="arch" type="xml">
            <xpath expr="//group[@id='security_check_group']/h6" position="before">
                <div>This Quick Action updates the template files in carrier boxes,in the environment specified below.</div>
            </xpath>
            <xpath expr="//field[@name='carrier_id']" position="after">
                <field name="template_file_id" options="{'no_create': True}" />
            </xpath>
        </field>
    </record>

请注意,我正在使用不同的模型,因为我需要根据字段将它们分开,因为计划在将来创建其他一些向导,并且并非所有字段都与其他向导相同(以上向导定义)只是第一个,还应该有更多)。

打开向导的操作( TransientModel )的定义如下,直接调用向导模型的表单视图:

<record model="ir.actions.act_window" id="handleprocess_qact_ig_template_wz_action">
        <field name="name">Update Template</field>
        <field name="type">ir.actions.act_window</field>
        <field name="res_model">handleprocess.qact.ig.template.wz</field>
        <field name="view_mode">form</field>
        <field name="view_id" ref="handleprocess.handleprocess_qact_ig_template_wz_form_view" />
        <field name="target">new</field>
    </record>

我在视图定义中缺少什么吗?

谢谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)