i set a keyDown from JS file call a function in Py file
but i got this error :
/some/route: Function declared as capable of handling request of type 'http' but called with a request of type 'json'
Anyone can help me fix this
this is my JS file
_onKeydown_searchText: function () {
var self = this;
var search = {};
search.Input = self.$('#text_input').val().trim();
if (event.keyCode == 13 && search.Input) {
console.log("haha");
return this._rpc({
route: '/some/route',
params: { search: search.Input }
}).then(function (data) {
console.log(data);
self._result = data;
})
}
},
and this is my Py fucntion
and this is my Py fucntion
@http.route('/some/route/', website=True, auth='public', csrf=False)
def get_data(self, **kw):
print(kw)
print("================haha")
condition = kw['search']
sql = """
select name from res_partner where phone = '%s' or email = '%s'
""" % (condition, condition)
http.request.cr.execute(sql)
result = http.request.cr.fetchall() or []
data = []
list(data)
for x in result:
temp = ''.join(x)
data.append(temp)
return http.request.render("search_vip_route.get_data", {
'data': data
})