Open a specific tree

Viewed 34

How can I open a specific tree when I select a record of another tree ?

for example if I click on Sales department instead of openning its form I need to open the sales tree (just an example)

enter image description here

1 Answers

You can do some thing like that by adding a button to the tree view. and when you show your data use only tree view without form to force the use to click on the button.

   <tree> 
        <field....>
        <field....>
        <field....>
        <button name="open_other_view" ....>
   </tree>

and in your model define a function to open another view :

  @api.mutli
  def open_other_view(self):
      ......
      ......
      ......
      tree_id = self.env.ref('module_name.tree_xml_id').id
      return {
         'type': 'ir.actions.act_window',
         'name': 'title',
         'views': [(tree_id, 'tree'), (False, 'form')],
         ....
         ....
         ....
      }

i think this technique is much simple.

Related