mirror of
https://github.com/bringout/oca-ocb-report.git
synced 2026-04-21 22:22:09 +02:00
19.0 vanilla
This commit is contained in:
parent
62d197ac8b
commit
184bb0e321
667 changed files with 691406 additions and 239886 deletions
|
|
@ -0,0 +1,63 @@
|
|||
from odoo import http, _
|
||||
from odoo.http import request
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
class DashboardShareRoute(http.Controller):
|
||||
@http.route(['/dashboard/share/<int:share_id>/<token>'], type='http', auth='public')
|
||||
def share_portal(self, share_id=None, token=None):
|
||||
share = request.env["spreadsheet.dashboard.share"].sudo().browse(share_id).exists()
|
||||
if not share:
|
||||
raise request.not_found()
|
||||
share._check_dashboard_access(token)
|
||||
download_url = ""
|
||||
if request.env.user.has_group('base.group_allow_export'):
|
||||
download_url = f"/dashboard/download/{share.id}/{token}"
|
||||
return request.render(
|
||||
"spreadsheet.public_spreadsheet_layout",
|
||||
{
|
||||
"spreadsheet_name": share.dashboard_id.name,
|
||||
"share": share,
|
||||
"is_frozen": True,
|
||||
"session_info": request.env["ir.http"].session_info(),
|
||||
"props": {
|
||||
"dataUrl": f"/dashboard/data/{share.id}/{token}",
|
||||
"downloadExcelUrl": download_url,
|
||||
"mode": "dashboard",
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
@http.route(["/dashboard/download/<int:share_id>/<token>"],
|
||||
type='http', auth='user', readonly=True)
|
||||
def download(self, token=None, share_id=None):
|
||||
share = request.env["spreadsheet.dashboard.share"].sudo().browse(share_id)
|
||||
share._check_dashboard_access(token)
|
||||
if not request.env.user.has_group('base.group_allow_export'):
|
||||
raise UserError(_("You don't have the rights to export data. Please contact an Administrator."))
|
||||
stream = request.env["ir.binary"]._get_stream_from(
|
||||
share, "excel_export", filename=share.name
|
||||
)
|
||||
return stream.get_response()
|
||||
|
||||
@http.route(
|
||||
["/dashboard/data/<int:share_id>/<token>"],
|
||||
type="http",
|
||||
auth="public",
|
||||
methods=["GET"],
|
||||
readonly=True,
|
||||
)
|
||||
def get_shared_dashboard_data(self, share_id, token):
|
||||
share = (
|
||||
request.env["spreadsheet.dashboard.share"]
|
||||
.sudo()
|
||||
.browse(share_id)
|
||||
.exists()
|
||||
)
|
||||
if not share:
|
||||
raise request.not_found()
|
||||
|
||||
share._check_dashboard_access(token)
|
||||
stream = request.env["ir.binary"]._get_stream_from(
|
||||
share, "spreadsheet_binary_data"
|
||||
)
|
||||
return stream.get_response()
|
||||
Loading…
Add table
Add a link
Reference in a new issue