ir.actions.act_window浅谈
-
看到页面想了解view详情,打开开发者模式,选择 管理视图 查看视图外部标志
-
通过外部标志,查看数据库中的ir_action_view
3.重点是view_id来跳转282 view界面,打开数据库ir_ui_view
4.product_view 中找到action 其中product_template_tree_view对应的就是view_id 282<record id="product_template_action" model="ir.actions.act_window"> <field name="name">Products</field> <field name="type">ir.actions.act_window</field> <field name="res_model">product.template</field> <field name="view_mode">tree,form,kanban</field> <field name="view_type">form</field> <field name="view_id" ref="product_template_tree_view"/> <field name="context">{"search_default_filter_to_sell":1}</field> <menuitem action="product_template_action" id="menu_product_template_action" parent="base.menu_product" sequence="1" />
-
product_view 中找到 product_template_tree_view
<record id="product_template_tree_view" model="ir.ui.view"> <field name="name">product.template.product.tree</field> <field name="model">product.template</field> <field name="arch" type="xml"> <tree string="Product"> <field name="name"/> <field name="categ_id"/> <field name="type"/> <field name="state"/> <field name="uom_id" invisible="1"/> </tree> </field> </record>
6.相关的view视图
id name inherit_id
product_template_tree_view – product.template.product.tree
product_template_search_view – product.template.search
product_template_form_view – product.template.common.form
product_template_kanban_view-- Product.template.product.kanban
product_template_only_form_view-- product.template.product.form product.product_template_form_view
7.其他视图继承
<record id="product_template_action" model="ir.actions.act_window">
<field name="name">Products</field>
<field name="res_model">product.template</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{}</field>
</record>
<menuitem name="Products"
id="menu_mrp_product_form"
action="product_template_action"
parent="menu_mrp_bom"/>
8.主要连接
其中action连接主要靠modle product.template而不是id
比如把id名字改掉如下图 依旧有效连接