Zum Inhalt springen
Menü
Sie müssen registriert sein, um mit der Community zu interagieren.
Diese Frage wurde gekennzeichnet
1 Antworten
10831 Ansichten

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
Verwerfen
Autor Beste Antwort

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
Verwerfen
Verknüpfte Beiträge Antworten Ansichten Aktivität
1
Juni 25
3504
1
Sept. 19
10460
1
Dez. 18
12471
3
Dez. 23
45541
1
März 15
7789