Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
6399 Lượt xem

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.

Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

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.

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 1 25
2503
0
thg 7 24
5668
5
thg 6 16
7027
1
thg 12 22
8829
0
thg 1 18
4782