0

我想在Odoo v8中从另一个视图继承一个视图。第一个视图的 id 为:form_authority_information,继承的视图的 id 为:form_authority_information_construction_law

这是form_authority_information的代码

<record model="ir.ui.view" id="form_authority_information">
        <field name="name">view.name</field>
        <field name="model">company.authority_information</field>
        <field name="arch" type="xml">
            <form>
                <sheet>
                    <group colspan="4" id="content">
                        <group colspan="2" col="2" id="general">
                            <separator string="General" colspan="2"/>
                            <field name="related_field"/>
                            <field name="information_date"/>
                            <field name="information_medium" attrs="{'invisible':[('is_finished', '=', True)]}" />
                            <field name="is_finished"/>
                        </group>
                    </group>
                </sheet>
            </form>
        </field>
    </record>

主视图中的正确格式

对于form_authority_information_construction_law

<record model="ir.ui.view" id="form_authority_information_construction_law">
        <field name="name">Construction Law</field>
        <field name="model">company.authority_information.construction_law</field>
        <field name="inherit_id" ref="form_authority_information"/>
        <field name="arch" type="xml">
            <data>
                <group id="general" position="after">
                    <separator string="Construction Law" colspan="2"/>
                    <field name="construction_law_type"/>
                    <field name="building_area_type"/>
                    <field name="zoning_name" attrs="{'invisible':[('construction_law_type', '=', 'qualified')]}"/>

                </group>
            </data>
        </field>
    </record>

继承视图中的格式错误

数据继承工作正常。我有我想在继承视图中看到的所有字段。问题是,它没有设置继承视图的样式。对于主视图,所有内容都显示在“工作表”环境中,但对于继承的视图,顺序是另一个,工作表不显示。“attr”属性也不起作用。

有谁知道这种奇怪行为的解决方案?

更新:图像更新 2:是否需要外部 id 才能正常工作?

更新3:Python代码 models.py

class company_authority_information(models.Model):
    _name = 'company.authority_information'
    # other fields...

class company_authority_information_report_committee(models.Model):
    _name = 'company.authority_information.report_committee'
    _inherit = 'company.authority_information'

提前致谢。

4

1 回答 1

1

尝试跟随,

class company_authority_information(models.Model):
    _name = 'company.authority_information'
    # other fields...

class gut8_authority_information_report_committee(models.Model):
    _inherit = 'company.authority_information'

如果您提供_name,那么它将为此创建表,因此当您继承任何模型时,您要么保持与_inherit 相同的_name,要么不指定_name,以防_inherit 存在。如果不起作用,请重新启动服务器和升级模块。

<record model="ir.ui.view" id="form_authority_information_construction_law">
        <field name="name">Construction Law</field>
        <field name="model">company.authority_information</field>
        <field name="priority" eval="50" />
        <field name="inherit_id" ref="form_authority_information"/>
        <field name="arch" type="xml">
                <group id="general" position="after">
                    <separator string="Construction Law" colspan="2"/>
                    <field name="construction_law_type"/>
                    <field name="building_area_type"/>
                    <field name="zoning_name" attrs="{'invisible':[('construction_law_type', '=', 'qualified')]}"/>
                </group>
        </field>
    </record>
于 2015-03-30T10:08:50.693 回答