This question has been flagged

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
Discard
Best Answer

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
Discard
Author

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.

Best Answer

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
Discard