1.model B为model A的子字段
2.model B的formview中, 系统自动生成 parent字段=model
<!--子视图 form-->
<record model="ir.ui.view" id="project_info_form">
<field name="name">项目信息</field>
<field name="model">dms_repair.project.info</field>
<field name="arch" type="xml">
<form>
<sheet>
<group>
<field name="company_id" invisible="0" default="parent.company_id"/>
<field name="parent_state" invisible="1"/>
<field name="repair_project_id" attrs="{'readonly': [('parent_state', '!=', 'draft')]}"/>
<field name="repair_code" attrs="{'readonly': [('parent_state', '!=', 'draft')]}"/>
<field name="error_code" attrs="{'readonly': [('parent_state', '!=', 'draft')]}"/>
<field name="error_describe" attrs="{'readonly': [('parent_state', '!=', 'draft')]}"/>
<field name="repair_reason" attrs="{'readonly': [('parent_state', '!=', 'draft')]}"/>
<field name="account_time" attrs="{'readonly': [('parent_state', '!=', 'draft')]}"/>
<field name="account_cost" attrs="{'readonly': [('parent_state', '!=', 'draft')]}"/>
<field name="remark" attrs="{'readonly': [('parent_state', '!=', 'draft')]}"/>
<field name="account_id" groups="account.group_account_user"
domain="[('company_id', '=', parent.company_id), ('internal_type', '=', 'other')]"
attrs="{'readonly': [('parent_state', '!=', 'draft')]}"/>
<field name="invoice_line_tax_ids" widget="many2many_tags" context="{'type':parent.type}"
domain="[('type_tax_use','=','sale'),('company_id', '=', parent.company_id)]" options="{'no_create': True}"
attrs="{'readonly': [('parent_state', '!=', 'draft')]}"/>
</group>
<group>
<field name="pay_date"
attrs="{'readonly': [('parent_state', '!=', 'compensation')],
'required': [('parent_state', '==', 'compensation')]}"/>
<field name="pay_cost"
attrs="{'readonly': [('parent_state', '!=', 'compensation')],
'required': [('parent_state', '==', 'compensation')]}"/>
<field name="back_suggestion" attrs="{'readonly': [('parent_state', '!=', 'compensation')]}"/>
<field name="partner_pay" attrs="{'readonly': [('parent_state', '!=', 'compensation')]}"/>
</group>
</sheet>
</form>
</field>
</record>
屏幕快照 2018-01-11 下午5.21.02.png
网友评论