i send data from extJS file to my odoo controller using Ext.Ajax.request like this :
Ext.Ajax.request({
url : '/serviceAP/fun',
headers :{
'Content-Type' : 'application/json'
},
method : 'POST',
jsonData : {"params":
{"cat" : "cat4",
"date" : "02/11/2015",
"notes" : "this notes 4"}
}
})
and the controller is like this :
@http.route('/serviceAP/fun', type="json", auth='public', website=True)
def func_test(self,**args):
http.request.env['sap.orders'].create({"cat": args['cat'], "order_date": args['date'],
"notes": args['notes']})
return None
it's works fine without any problem but now i want to add many params (cat5,cat6,...,catn) so i need to use a JS array i don't know how to handle it i tried many things but without result because this method is correct just for one json tuple i want to know how to handle it in the two side odoo (odoo controller/js return )
i find it to make a make it we should create a dictionair of dictionaries like this :
val = {}
val[0]={
"cat": "cat4",
"date": "02/11/2015",
"notes": "this notes 4"
};
val[1]={
"cat": "cat5",
"date": "02/11/2015",
"notes": "this notes 5"
};
after we should insert it to jsonData with the params key
jsonData : {"params":val}
and we use it directly in the controller :
i=0
while i < len(args):
http.request.env['sap.orders'].create({"cat": args[str(i)]['cat'], "order_date": args[str(i)]['date'],"notes": args[str(i)]['notes']})
i = i+1
i hope it help ,thanks any way :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.