3

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

Borealis
  • 1,059
  • 2
  • 18
  • 37

1 Answers1

2

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.

Charif DZ
  • 14,415
  • 3
  • 21
  • 40
  • Thank you. I already added a button to the tree view, but how can I use only tree view without form to force the use of the button? – Borealis Nov 13 '17 at 17:05
  • in the action definition `tree,form` just remove the form `tree` that is all – Charif DZ Nov 13 '17 at 20:05