Odoo Help


How to create a Custom Python Model an call a Method via Javascript? (Odoo 9.0)

Konrad Weinhandl
on 3/10/16, 4:55 AM 2,277 views


I'm trying to create a custom server method and call it via javascript. But it seems like i got the python class definition wrong. 

Here's the python file:

from openerp import api, field, models

class simple_class(models.Model)

_name = "wins_test.simple_class"


def some_method(self):

return {"msg" : "Message from the server"}

Here's how I try to call

new Model("wins_test.simple_class").call("some_method").then(function(result) {

console.log('The result is: ' + result["msg"]);


During App installation I get a Server Error: 

AttributeError: 'NoneType' object has no attribute 'some_method'

I think I got the model definition wrong somehow, but can't figure how to do it right, any suggestions?

Konrad Weinhandl
On 3/10/16, 5:34 AM

Seems like I had to restart the server to see a detailed error message. The problem was the import, this is what worked for me:

from openerp import api, models

class simple_class(models.Model):

_name = "wins_test.simple_class"


def some_method(self):

return {"msg" : "Message from the server"}

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.


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

2 follower(s)


Asked: 3/10/16, 4:55 AM
Seen: 2277 times
Last updated: 4/14/16, 5:00 AM