Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

1

call python method from javascript ?

By
abdelwahed chiheb
on 11/17/13, 6:29 AM 4,130 views

Hello,

i'm in openerp v7, and i want to call a python method from a javascript code. this is the javascript code (web\static\src\js\view_list_editable.js):

    do_delete: function (ids) {
        alert('hello test'); /*--my test msg--*/
        /// Call python method here ?

        var nonfalse = _.compact(ids);
        var _super = this._super.bind(this);
        var next = this.editor.is_editing()
                ? this.cancel_edition(true)
                : $.when();
        return next.then(function () {
            return _super(nonfalse);
        });
    },

image description

i want to delete some data when choosing this button !! any idea ?

Thanks !!

1

Thierry Godin

--Thierry Godin--
1516
| 8 7 8
Collegien, France
--Thierry Godin--

..

Thierry Godin
On 11/17/13, 8:28 AM

Hello,

You can use get_func from JS to call py function :

new instance.web.Model("<model>").get_func("<py function>")(<args>)

This is a sample code from module.PosWidget (point_of_sales/static/src/js/widget.js) :

new instance.web.Model("ir.model.data").get_func("search_read")([['name', '=', 'action_pos_session_opening']], ['res_id'])

Regards

    do_delete: function (ids) {
        func = new instance.web.Model("stock.reservation").get_func("test_chiheb");
        this.alive(func(this.session.uid)).then(function(res) {
            alert('hello test 22222222222');
        });
        var nonfalse = _.compact(ids);
        var _super = this._super.bind(this);
        var next = this.editor.is_editing()
                ? this.cancel_edition(true)
                : $.when();
        return next.then(function () {
            return _super(nonf
abdelwahed chiheb
on 11/17/13, 4:30 PM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

3 follower(s)

Stats

Asked: 11/17/13, 6:29 AM
Seen: 4130 times
Last updated: 3/16/15, 8:10 AM