Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
3 Vastaukset
14590 Näkymät

Hi,
I want to call a python function from my JavaScript code. This is my code,

rpc.query({
    model: 'my_model',
   method: 'my_method',
   args: ['']
});            

It works perfectly when I'm signed in. But the problem is, the function is not getting called when I'm not signed in. I do want to call the function from the website without signing in. Is there any solutions to achieve this ?


Thanks in advance.

Avatar
Hylkää
Paras vastaus

try this instead of RPC call

this.trigger_up('button_clicked', {

name: 'my_method',
type: 'object',
record: this.record,
});
Avatar
Hylkää
Paras vastaus

Hi,

For example custom model.

class custom(models.Model):

_name = "custom.model"

def get_values(self):

    return 'python method'

From the javascript file you can call like:

new Model("custom.model").call("get_values",[args]).then(function(result){

console.log(result);//show result in console

});


Avatar
Hylkää
Tekijä

Thanks Sushma, but this method works only for odoo 10 and I'm dealing with odoo 11.

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
syysk. 20
3276
0
huhtik. 18
2425
0
maalisk. 15
5389
1
syysk. 24
1937
2
huhtik. 21
25955