Overslaan naar inhoud
Menu
Je moet geregistreerd zijn om te kunnen communiceren met de community.
Deze vraag is gerapporteerd
1 Beantwoorden
12241 Weergaven

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 !!

Avatar
Annuleer
Beste antwoord

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

Avatar
Annuleer
Auteur
    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
Gerelateerde posts Antwoorden Weergaven Activiteit
1
jun. 25
4194
2
mrt. 24
28081
1
sep. 19
11002
3
dec. 23
46297
1
jun. 15
4985