Odoo Help

1

How can I call python function from javascript in odoo 11?

By
Merida
on 6/12/18, 1:11 AM 981 views

rpc.query isn't working in my end.

I wanna call the function in wizard model through button inside wizard.


Thanks in advance.

2

Hilar AK

--Hilar AK--
--Hilar AK--
  Blog:-
        https://hilarlive.wordpress.com/
  StackOverflow:
        http://stackoverflow.com/users/7561347/burmese-pythis

Quora:
    

            https://www.quora.com/profile/Hilar-Ak-1

Experienced Odoo developer, Functional Consultant. Happy to help in the development and also functional consultation.



Hilar AK
On 6/12/18, 8:15 AM


var rpc = require('web.rpc')

rpc.query(

     model: //your model,

     method: //your method,

      args: [{

          'arg1': value1,

      }]

 }).then(function (result) { 

            // your code 

  });

on model.py

@api.model
def your_method(self):
     ...


Thanks Hilar Ak,

I already tried like that but I got server application error.:'(

Merida
on 6/19/18, 6:04 AM

check your code, this is a correct format.

Hilar AK
on 6/21/18, 4:55 AM
3

Aktiv software

--Aktiv software--
2508
| 5 2 7
Ahmedabad, India
--Aktiv software--

 Aktiv software

  • Skype : shah.jainesh

  • email : Sales@Aktivsoftware.com

Aktiv software
On 6/12/18, 6:30 AM

Hello Merida,

You can use "this._rpc()" method to call python function from javascript.

You can find plenty of references in base addons for the same.

Thanks.



0
Alf Olsen
On 6/26/18, 9:15 AM

@Merida: I don't know if you managed to get it working, but I had a simular problem that magically fixed itself when I restarted Odoo (or the docker container I'm running it in)

About This Community

This platform 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.

Register

Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)

Stats

Asked: 6/12/18, 1:11 AM
Seen: 981 times
Last updated: 7/21/18, 4:36 AM