This question has been flagged
1 Reply
10509 Views

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

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
Discard

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.