Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
10930 Zobrazení

Hi, 

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"

@api.model

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?


Avatar
Zrušit
Autor Nejlepší odpověď

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"

@api.model

def some_method(self):

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
čvn 25
3611
1
zář 19
10528
1
pro 18
12563
3
pro 23
45628
1
bře 15
7854