27 lines
989 B
Python
27 lines
989 B
Python
# -*- coding: utf-8 -*-
|
|
"""JSON endpoint feeding the report client action (Odoo 20 uses type=jsonrpc)."""
|
|
import logging
|
|
from odoo import http
|
|
from odoo.http import request, route
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
class DnFrController(http.Controller):
|
|
|
|
@route("/dn/fr/data", type="jsonrpc", auth="user")
|
|
def get_report_data(self, report_id=None, options=None, **kwargs):
|
|
try:
|
|
report = request.env["dn.fr"].browse(int(report_id or 0)).exists()
|
|
except (TypeError, ValueError):
|
|
report = request.env["dn.fr"]
|
|
if not report:
|
|
return {"ok": False, "error": "Report not found."}
|
|
options = dict(options or {})
|
|
options.setdefault("company_ids", request.env.company.ids)
|
|
try:
|
|
return {"ok": True, "data": report.get_report_data(options)}
|
|
except Exception as exc:
|
|
_logger.exception("DN report %s failed", report.code)
|
|
return {"ok": False, "error": str(exc)}
|