Skip to Content
Menu
This question has been flagged
2 Replies
4980 Views

In a One2many field I added a button to navigate to a relation module. I found out how to clear the breadcrumb, but cannot get the menu_id to change.


    def open_one2many_line(self):

        context = self.env.context

        return {

            'type': 'ir.actions.act_window',

            'views': [[False, "form"]],

            'target': 'main',

            'res_model': self._name,

            'res_id': context.get('default_active_id'),

            'menu_id': "90"

        }


I tried adding menu_id into the return value of my action function. It had no effect.

Avatar
Discard
Best Answer

Hi, 
If you have a O2M with a button in each line. When you click on that buton the record's form view should be displayed, then you only have to add this exemple: 

def open_one2many_line(self):
   self.ensure_one()
   return {
        'name': _('Something'),
        'view_type': 'form',
        'view_mode': 'form',
       'view_id': xml_id of your view, 
        'res_model': self._name,
        'context': self._context,
       'type': 'ir.actions.act_window',
       'nodestroy': True,
       'target': 'current',
       'res_id': self.id,

        }

You don't need a menu as the view types are linked to the action, not to menu.


Hopethis helps. upvote if it does.

Regards.

Avatar
Discard
Related Posts Replies Views Activity
0
Oct 24
177
0
Jul 24
4696
5
Jun 16
6116
1
Dec 22
7589
0
Jan 18
4005