تخطي للذهاب إلى المحتوى
القائمة
لقد تم الإبلاغ عن هذا السؤال
2 الردود
10254 أدوات العرض

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
أغسطس 22
6326
2
ديسمبر 19
5490
4
يناير 24
13169
0
يوليو 17
2409
0
أغسطس 23
194