#javascript #odoo
#javascript #odoo
Вопрос:
odoo.define('second_opinion.appointment', function(require) {
"use strict";
var ajax = require('web.ajax');
var core = require('web.core');
$(document).ready(function() {
$('#view_appointment').click(function(event){
ajax.jsonRpc("/my-appnt", 'call', {
});
})
})
})
@http.route(['/my-appnts'], type="json", auth="user",csrf=False,methods=['POST'], website=True)
def appointment_form(self, **post):
apopointment = request.env['consultation'].search([])
values=({
'appointment':apopointment,
})
return request.render("second_opinion.tmp_customer_form")
Комментарии:
1. Не могли бы вы, пожалуйста, подробнее?
Ответ №1:
Вы должны увидеть следующее сообщение об ошибке:
Ошибка атрибута: объект ‘JSONRequest’ не имеет атрибута ‘render’
Результат метода обработки запроса for JSON-RPC 2
возвращается как объект JSON-RPC и завернут в ответ JSON-RPC.
render
Атрибут доступен при использовании HttpRequest
.
Вы сделали правильный вызов, используя jsonRpc
. Проблема в обработчике запроса.
Вы можете найти аналогичный пример в website_gengo, метод cotroller объявляется следующим образом:
@http.route('/website/post_gengo_jobs', type='json', auth='user', website=True)
def post_gengo_jobs(self):
request.env['base.gengo.translations']._sync_request(limit=GENGO_DEFAULT_LIMIT)
return True
Затем вызывается с использованием следующего кода:
ajax.jsonRpc('/website/post_gengo_jobs', 'call', {});