Skip to Content
Menu
This question has been flagged
1 Reply
2010 Views

Hi, I need to show one or other tree view by menuitem to the same model (product.template), when I use the XML below it shows all columns (model, origin) using menuitem1 or menuitem2 and I want to show a tree with colum 'model' by menuitem1 and by menuitem2 columm 'origin'.


record id="extra_tree1" model="ir.ui.view">
field
name="name">product.extra.tree
field
name="model">product.template
field
name="inherit_id" ref="product.product_template_tree_view"/>
field
name="arch" type="xml">
tree>
field
name="model"/>
/tree>
/field>
/record>

record
id="extra_tree2" model="ir.ui.view">
field
name="name">product.extra.tree
field
name="model">product.template
field
name="inherit_id" ref="product.product_template_tree_view"/>
field
name="arch" type="xml">
tree>
field
name="origin"/>
/tree>
/field>
/record>

record
id="action1" model="ir.actions.act_window">
field
name="name">Test action 1
field
name="type">ir.actions.act_window
field
name="res_model">product.template
field
name="view_type">form
field
name="view_mode">form,tree
field
name="view_ids" eval="[
(5, 0, 0),
(0, 0, {'view_mode': 'tree', 'view_id': ref('inventory_extras.extra_tree1')})]"
/>
field
name="context">{}
/record>

record
id="action2" model="ir.actions.act_window">
field
name="name">Test action 2
field
name="type">ir.actions.act_window
field
name="res_model">product.template
field
name="view_type">tree
field
name="view_mode">form,tree
field
name="view_ids" eval="[
(5, 0, 0),
(0, 0, {'view_mode': 'tree', 'view_id': ref('inventory_extras.extra_tree2')})]"
/>
field
name="context">{}/field>
/record>

menuitem
id="test_model_menu_action1" action="action1"/>

menuitem
id="test_model_menu_action2" action="action2"/>

Avatar
Discard
Best Answer

Please try below code with context. you can have separate view by managing context.


id="extra_tree1" model="ir.ui.view">
name="name">product.extra.tree
name="model">product.template
name="inherit_id" ref="product.product_template_tree_view"/>
name="arch" type="xml">

name="model" invisible="context.get('model')"/>
name="origin" invisible="context.get('origin')"/>


id="action1" model="ir.actions.act_window">
name="name">Test action 1
name="type">ir.actions.act_window
name="res_model">product.template
name="view_mode">tree
name="context">{"model":True}

id="action2" model="ir.actions.act_window">
name="name">Test action 2
name="type">ir.actions.act_window
name="res_model">product.template
name="view_mode">tree
name="context">{"origin":True}


id="test_model_menu_action1" action="action1" parent="stock.menu_stock_root"/>
id="test_model_menu_action2" action="action2" parent="stock.menu_stock_root"/>



Avatar
Discard
Related Posts Replies Views Activity
1
Jul 22
1882
3
May 23
1755
1
Apr 23
3225
2
May 25
30584
1
Sep 18
10311