Pular para o conteúdo
Menu
Esta pergunta foi sinalizada
2 Respostas
6397 Visualizações

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
Cancelar
Melhor resposta

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
Cancelar
Publicações relacionadas Respostas Visualizações Atividade
1
jan. 25
2500
0
jul. 24
5667
5
jun. 16
7024
1
dez. 22
8828
0
jan. 18
4782