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

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
Zrušit
Nejlepší odpověď

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
Zrušit

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 Odpovědi Zobrazení Aktivita
0
srp 17
3255
0
bře 15
4320
1
úno 24
2860
1
srp 19
4474
3
čvn 19
7113