Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
10272 Zobrazení

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()?

 

Avatar
Zrušit
Nejlepší odpověď

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.

Avatar
Zrušit
Autor

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.

Nejlepší odpověď

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?

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
srp 22
6344
2
pro 19
5509
4
led 24
13187
0
čvc 17
2414
0
srp 23
194