콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다

Hello, 

   I have a custom module that adds an item to the "More" button dropdown from the tree view.  The item calls a function which creates a new sales order like it's supposed to do.  The problem is, I would like to open the Sales Order form after the record is created, but for some reason it isn't doing that.

Here is my return statement 

return {
            'name': 'Sale Order',
            'view_type': 'form',
            'view_mode': 'form',
            'view_id': self.pool.get('ir.ui.view').search(cr, uid, [('name','=','sale.order.form')])[0],
            'res_model': 'sale.order',
            'res_id': new_order_id,
            'type': 'ir.actions.act_window',
        }

This block of code works for other things, but it doesn't work when opening a form from a tree view that calls a function when an item in the "More" dropdown menu is clicked.

아바타
취소
베스트 답변

You shuoldn't need view_id at all, that's only useful when you have multiple, diverging view definitions and need to pick a non-standard one.  If you really wanted to select a specific view, use the XML ID instead:

xml_id_obj = self.pool['ir.model.data']
form_id = xml_id_obj.get_object_reference(cr, uid, 'sale', 'view_order_form')[1]
return {
    'name': 'Sale Order',
    'view_type': 'form',
    'view_mode': 'form',
    'views': [(form_id,'form')],
    'res_model': 'sale.order',
    'res_id': new_order_id,
    'type': 'ir.actions.act_window',
}

아바타
취소
관련 게시물 답글 화면 활동
2
3월 15
5553
1
10월 24
2224
1
9월 24
3401
6
12월 23
17333
0
1월 16
3799