场景:在做财务的时候需要对一个model(account.move) 要有多个菜单,和多个form:
一个菜单系统默认的菜单。另外一个自己定义的菜单。
(可以直接替换源码的菜单)
<record id="wg_account_move_form_inherit" model="ir.ui.view">
<field name="name">account.move.form</field>
<field name="model">account.move</field>
<field name="arch" type="xml">
<form string="Account Entry">
...
</form>
</field>
</record>
<record id="wg_account_account_move_tree" model="ir.ui.view">
<field name="name">account.move.tree</field>
<field name="model">account.move</field>
<field eval="90" name="priority"/>
<field name="arch" type="xml">
<tree>
...
</tree>
</field>
</record>
<record id="wg_account_move_inherited_action" model="ir.actions.act_window">
<field name="name">日记账分录</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">account.move</field>
<field name="view_mode">tree,form</field>
<field name="domain">[('type', '=', 'entry')]</field>
<field name="context">{'default_type': 'entry'}</field>
<field name="view_id" ref="wg_account_account_move_tree"/>
</record>
<record id="account_move_form_view2" model="ir.actions.act_window.view">
<field eval="2" name="sequence"/>
<field name="view_mode">form</field>
<field name="view_id" ref="wg_account_move_form_inherit"/>
<field name="act_window_id" ref="wg_account_move_inherited_action"/>
</record>
<record id="account_move_tree_view1" model="ir.actions.act_window.view">
<field name="sequence" eval="1"/>
<field name="view_mode">tree</field>
<field name="view_id" ref="wg_account_account_move_tree"/>
<field name="act_window_id" ref="wg_account_move_inherited_action"/>
</record>
<menuitem name="日记账分录" id="account.menu_action_move_journal_line_form"
parent="account.menu_finance_entries_accounting_miscellaneous"
action="wg_account_move_inherited_action"/>
# act_window_id:对应action视图 ir.actions.act_window
# view_id:对应form视图和tree视图
<menuitem name="日记账分录" id="account.menu_action_move_journal_line_form"
parent="account.menu_finance_entries_accounting_miscellaneous"
action="wg_account_move_inherited_action"/>
# 这里的 id="account.menu_action_move_journal_line_form" 是直接重写了源码里的菜单,相当于直接替换,