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

I have a button opening a window from javascript:

var self=this;
            this.$(".oe_write_full").click(function (event) {
                event.stopPropagation();
                var action = {
                    type: 'ir.actions.act_window',
                    res_model: 'mail.compose.message',
                    view_mode: 'form',
                    view_type: 'form',
                    action_from: 'mail.ThreadComposeMessage',
                    views: [[false, 'form']],
                    target: 'new',
                    context: {

                    },
                };
                session.client.action_manager.do_action(action);
            });

I have two ir.actions.act_window for the same res_model (mail.compose.message).

How can I choose which window open? Can I do it using do_action()?

 

아바타
취소
베스트 답변

Daniele, I do not have experience in coding the javascript part yet.  But AFAIK, you don't need to know which action to trigger, what you need is actually the view that you intend to show, which you can specify in the views attribute.

아바타
취소
작성자

Thanks Jon Doe, I really appreciate your help, it works! var self=this; this.$(".oe_write_full").click(function (event) { event.stopPropagation(); var action = { type: 'ir.actions.act_window', res_model: 'mail.compose.message', view_mode: 'form', view_type: 'form', action_from: 'mail.ThreadComposeMessage', views: [['590', 'form']], target: 'new', context: { }, }; session.client.action_manager.do_action(action); });

Daniele, you might want to tweak your code a bit. The ID 590 of your view will not be the same in other databases, so you need to either translate it from XML ID or search it by other means.

베스트 답변

Hi Daniele. I am interested in your approach to run an action. 

I tried your line:  session.client.action_manager.do_action(action); but it says:  Cannot read property 'action_manager' of undefined.


I am using odoo13. Is it different in this version?

아바타
취소
관련 게시물 답글 화면 활동
1
8월 22
6317
2
12월 19
5484
4
1월 24
13167
0
7월 17
2406
0
8월 23
194