我想在 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”属性也不起作用。
有没有人知道这种奇怪行为的解决方案?
更新:图片 Update2:正常工作需要外部ID吗?
Update3: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'
提前致谢。
答案 0 :(得分: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,要么在_inherit存在的情况下不指定_name。如果不起作用,请重新启动服务器和升级模块。
<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>