반환 데이터 내가 odoo의 controllery.py에서 JSON 형식의 데이터를 얻을 싶어 9
예 : JSON 형식의 데이터를 얻을 방법
import openerp.http as http
from openerp.http import request
class MyController(http.Controller):
@http.route('/test_html', type="http", auth="public")
def some_html(self):
return "<h1>Test</h1>"
#Work fine when open http://localhost:8069/test.html
@http.route('/test_json', type="json", website=True, auth="public")
def some_json(self):
return [{"name": "Odoo", 'website': 'www.123.com'}]
, 내가 JSON에서 데이터를 다른 읽을 싶어 app with ajax.
열린 URL을보고 json을 (를) 볼 수 있습니까? http://localhost:8069/test_json ???
@Philip Stack Tnx 예를 들어, 다음과 같은 간단한 예제는 내 databse 테이블의 레코드가있는 json.dumps ({ "name": "Odoo", 'website': 'www.123.com'}) res.users). –
레코드에 액세스하려면 현재 사용자 인'http.request.env.user '를 사용하십시오. 다른 사용자'http.request.env [ 'res.users']. sudo(). browse ([user_id])'를 지정하려면 응답 변수에 그것을 빌드 할 수 있습니다. –
안녕하세요 Phillip, 여기 내 예제 https://postimg.org/image/sa4q1miur/입니다. 호출 후 공진 200, 어디서 문제가 있습니까? –