Skip to Content
Menu
This question has been flagged
1159 Views

I have a simple question.

I am using odoo13 and I utilize my own javascript libraries. In other words I don't rely only on the odoo libraries.

I want to add an action on a button and do simple stuff. For example: I want to click a button and open the mail composer just as it is done in "Sales Order / Send by email" button.

So I use jQuery for example and do something like this:


$('.something').on('click', function(){ var el = $(this); var myConfig = { 'name': 'Compose Email', 'type': 'ir.actions.act_window', 'res_model': 'mail.compose.message', 'views': [(false, 'form')], 'view_id': false, 'target': 'new', 'context': {} }; var action = new WhatMustIDoHere('?????'); action.run(myConfig); // the config above is supposed to be passed to the action and cause mail composer to pop-up });

It is completely outside of what it is typically associated with:


odoo.define('my_module.my_extended_action', function (require) {
'use strict';
    ...blah blah blah
});

... which requires a whole bunch of templating and what not.

The same code works as follows: You can add something like this inside a view:

... and then inside python:


@api.model
def action_myActionNameWhichIsInPython(self):
    return {
        name': 'Compose Email',
        'type': 'ir.actions.act_window',
        'res_model': 'mail.compose.message',
        'views': [(False, 'form')],
        'view_id': False,
        'target': 'new',
        'context': {}
    }

... and the whole lot works! But that is NOT what I want to do. I want to do the jQuery way because I have dynamically generated content with a whole bunch of libraries and what not which do not rely on the odoo environment.

If you look at my code and if someone can point me to the right direction to replace "WhatMustIDoHere('?????')" I would truly appreciate it.


Avatar
Discard