我想在 OpenERP 中创建不同“种类”的采购订单表格,每个表格都有不同的字段。由于继承模型,我假设我不能继承具有不相交字段的多个子项。所以我决定创建一个超集子集,它包含来自所有类型 PO 的所有字段。
然后我创建了不同的视图,包含来自继承模型的不同字段。
但是每个视图都显示相同的超集。
请告知我是否以正确的方式执行此操作,或者除了 fields_view_get() 之外没有其他方法。谢谢
代码:
class purchase_order_hash(osv.osv):
_name = 'purchase.order'
_inherit = 'purchase.order'
_columns={
'quality_code': fields....,
'rice_quality': fields....,
'packing_code': fields....,
'packing_type': fields....,
'late_payment': fields.float('Late Payment'),
'num_bags': fields.integer('Number of Bags'),
'unit_kg': fields.integer('Unit kg'),
'rate_': fields.float('Rate', digits=(16,2), help="Rate"),
'penalty_moisture': fields.float('Moisture Penalty', digits=(16,2), help="Percentage"),
'penalty_broken': fields.float('Broken Penalty', digits=(16,2), help="Percentage"),
'num_trucks': fields.integer('Number of Trucks'),
'test1': fields.integer('Test 1')
}
purchase_order_hash()
(查看 xml:)
<record id="purchase_order_hash_form" model="ir.ui.view">
<field name="name">purchase_order_hash_form</field>
<field name="model">purchase.order</field>
<field name="priority" eval="1" />
<field name="type">form</field>
<field name="inherit_id" ref="purchase.purchase_order_form" />
<field name="arch" type="xml">
<field name="origin" select="2" position="after">
<field name="quality_code"/>
<field name="rice_quality"/>
<field name="packing_code"/>
<field name="packing_type"/>
<field name="late_payment"/>
<field name="num_bags"/>
<field name="unit_kg"/>
<field name="rate_"/>
<field name="penalty_moisture"/>
<field name="penalty_broken"/>
<field name="num_trucks"/>
</field>
</field>
</record>
<record id="purchase_order_hash_form_test" model="ir.ui.view">
<field name="name">purchase_order_hash_form_test</field>
<field name="model">purchase.order</field>
<field name="priority" eval="2" />
<field name="type">form</field>
<field name="inherit_id" ref="purchase.purchase_order_form" />
<field name="arch" type="xml">
<field name="origin" select="2" position="after">
<field name="test1"/>
</field>
<field name="num_trucks" position="replace"/>
</field>
</record>
<record model="ir.actions.act_window" id="action_PO_hash">
<field name="name">action_PO_hash</field>
<field name="res_model">purchase.order</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="purchase_order_hash_form" />
</record>
<record model="ir.actions.act_window" id="action_PO_hash_test">
<field name="name">action_PO_hash_test</field>
<field name="res_model">purchase.order</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="view_id" ref="purchase_order_hash_form_test" />
</record>
<menuitem id="menu_PO_hash" name="menu_PO_hash" action="action_PO_hash" parent="purchase.menu_procurement_management"/>
<menuitem id="menu_PO_hash_test" name="menu_PO_hash_test" action="action_PO_hash_test" parent="purchase.menu_procurement_management"/>
[2012 年 10 月 16 日更新:view.xml - 最终工作代码:]
<record model="ir.actions.act_window" id="action_PO_hash">
<field name="name">action_PO_hash</field>
<field name="res_model">purchase.order</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
</record>
<record model="ir.actions.act_window" id="action_PO_hash_test">
<field name="name">action_PO_hash_test</field>
<field name="res_model">purchase.order</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
</record>
<record model="ir.actions.act_window.view" id="action_PO_hash_2">
<field name="sequence" eval="1"/>
<field name="view_mode">form</field>
<field name="view_id" ref="purchase_order_hash_form"/>
<field name="act_window_id" ref="action_PO_hash"/>
</record>
<record model="ir.actions.act_window.view" id="action_PO_hash_test_2">
<field name="sequence" eval="1"/>
<field name="view_mode">form</field>
<field name="view_id" ref="purchase_order_hash_form_test"/>
<field name="act_window_id" ref="action_PO_hash_test"/>
</record>
<menuitem id="menu_PO_hash" name="menu_PO_hash" action="action_PO_hash" parent="purchase.menu_procurement_management"/>
<menuitem id="menu_PO_hash_test" name="menu_PO_hash_test" action="action_PO_hash_test" parent="purchase.menu_procurement_management"/>