Skip to Content
Menu
Dette spørgsmål er blevet anmeldt
1 Svar
12612 Visninger

I want to pass context to a wizard that is called on a button click action from JS, I tried the following code but it didn't work.


on_click_new_message: function () {
        this.do_action({
            type: 'ir.actions.act_window',
            res_model: 'mail.compose.message',
            view_mode: 'form',
            view_type: 'form',
            views: [[false, 'form']],
            target: 'new',
            context: {'default_no_auto_thread': False, 'active_model': 'mail.message','subject':message.subject,'body':message.body}
        });
    },


The wizard appears but the values are not set.


Please let me know if any one knows

Avatar
Kassér
Bedste svar

try:

on_click_new_message: function () {
        this.do_action({
            type: 'ir.actions.act_window',
            res_model: 'mail.compose.message',
            view_mode: 'form',
            view_type: 'form',
            views: [[false, 'form']],
            target: 'new',
            context: {'default_no_auto_thread': False, 'active_model': 'mail.message','
default_subject':message.subject,'default_body':message.body}
        });
    },


Avatar
Kassér

Hello Hillar,

Can we make this wizard read-only when open through do_action() method?

That depends on logic. You can make a field readonly using attrs, or direct read-only flag. So while doing an action you can set a fields value through contexts. This can be useful for using attrs in field. 

On Mon, 15 Jul 2019, 4:41 pm Pawan Kumar Sharma, <pawan.sharma@sunarctechnologies.com> wrote:

Hello Hillar,

Can we make this wizard read-only when open through do_action() method?

Sent by Odoo S.A. using Odoo.

Related Posts Besvarelser Visninger Aktivitet
0
aug. 17
3043
0
mar. 15
4153
1
feb. 24
2508
1
aug. 19
4284
3
jun. 19
6918