Files
2026-07-01 14:41:49 +07:00

24 lines
782 B
Python

import json
from odoo import http
from odoo.http import request
class SurveyDashboardController(http.Controller):
@http.route('/survey/dashboard/<int:survey_id>', type='http', auth='user', website=True)
def dashboard_view(self, survey_id, **kw):
survey = request.env['survey.survey'].sudo().browse(survey_id).exists()
if not survey:
return request.not_found()
# Get data from model
data = survey.get_dashboard_data()
# ✅ CRITICAL: Serialize to JSON string with UTF-8 support for Khmer text
data['questions_json'] = json.dumps(
data.get('questions', []),
default=str,
ensure_ascii=False
)
return request.render('dashboard_survey.dashboard_template', data)