diff --git a/excel_report_designer/controllers/excel_report_designer.py b/excel_report_designer/controllers/excel_report_designer.py index e1baaa048..26f4f218a 100644 --- a/excel_report_designer/controllers/excel_report_designer.py +++ b/excel_report_designer/controllers/excel_report_designer.py @@ -29,8 +29,7 @@ from odoo.tools import html_escape class XLSXReportController(http.Controller): """This is used to call the xlsx report function""" - @http.route('/xlsx_reports', type='http', auth='user', - methods=['POST'], csrf=False) + @http.route('/xlsx_reports', type='http', auth='user', methods=['POST'], csrf=False) def get_report_xlsx(self, model, options, output_format, report_name, **kw): """this is used to call the function""" uid = request.session.uid diff --git a/yuthon_notice/__manifest__.py b/yuthon_notice/__manifest__.py index e2cab36a4..8a636fc37 100644 --- a/yuthon_notice/__manifest__.py +++ b/yuthon_notice/__manifest__.py @@ -18,6 +18,7 @@ 'data/notice_cron_data.xml', 'data/notice_type_data.xml', 'views/yuthon_notice_views.xml', + 'views/yuthon_cs_report_views.xml', 'views/yuthon_notice_type_views.xml', 'views/yuthon_cs_tree_views.xml', 'views/yuthon_confirm_users_views.xml', diff --git a/yuthon_notice/controllers/__init__.py b/yuthon_notice/controllers/__init__.py new file mode 100644 index 000000000..de2224d4a --- /dev/null +++ b/yuthon_notice/controllers/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies (). +# Author: Cybrosys Techno Solutions () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################ +from . import excel_report_designer diff --git a/yuthon_notice/controllers/excel_report_designer.py b/yuthon_notice/controllers/excel_report_designer.py new file mode 100644 index 000000000..6ae719f16 --- /dev/null +++ b/yuthon_notice/controllers/excel_report_designer.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +################################################################################ +# +# Cybrosys Technologies Pvt. Ltd. +# +# Copyright (C) 2024-TODAY Cybrosys Technologies (). +# Author: Cybrosys Techno Solutions () +# +# This program is free software: you can modify +# it under the terms of the GNU Affero General Public License (AGPL) as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +################################################################################ +import json +from odoo import http +from odoo.http import content_disposition, request +from odoo.tools import html_escape + + +class ReportPrintController(http.Controller): + + @http.route('/print_notice_report', type='http', auth='user') + def print_notice_report(self): + """ + 控制器方法,用于触发打印通知公告报表 + """ + # 获取 report.generator 模型的对象(假设存在该模型) + report_generator = request.env['report.generator'].sudo().create({}) + # 调用 print_fixed_report 方法 + action = report_generator.print_fixed_report() + # 提取报表数据 + report_data = action.get('data', {}) + options = json.loads(report_data.get('options', '{}')) + report_model_name = report_data.get('model') + output_format = report_data.get('output_format') + report_name = report_data.get('report_name') + + # 获取报表模型 + report_model = request.env[report_model_name] + # 创建响应对象 + response = request.make_response( + None, + headers=[ + ('Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' if output_format == 'xlsx' else 'application/pdf'), + ('Content-Disposition', f'attachment; filename="{report_name}.{output_format}"') + ] + ) + # 调用报表模型的生成报表方法 + if hasattr(report_model, 'get_xlsx_report'): + report_model.get_xlsx_report(options, response) + return response \ No newline at end of file diff --git a/yuthon_notice/models/__init__.py b/yuthon_notice/models/__init__.py index 346255b54..399b479b1 100644 --- a/yuthon_notice/models/__init__.py +++ b/yuthon_notice/models/__init__.py @@ -4,4 +4,5 @@ from . import yuthon_notice from . import yuthon_notice_type from . import yuthon_confirm_users from . import yuthon_cs_tree +from . import yuthon_cs_report diff --git a/yuthon_notice/security/ir.model.access.csv b/yuthon_notice/security/ir.model.access.csv index fd6f27cf3..17b0f1248 100644 --- a/yuthon_notice/security/ir.model.access.csv +++ b/yuthon_notice/security/ir.model.access.csv @@ -3,4 +3,5 @@ access_yuthon_notice,yuthon_notice,model_yuthon_notice,,1,1,1,1 access_yuthon_notice_type,yuthon_notice_type,model_yuthon_notice_type,base.group_user,1,1,1,1 access_yuthon_confirm_users,yuthon_confirm_users,model_yuthon_confirm_users,base.group_user,1,1,1,1 access_yuthon_cs_tree,yuthon_cs_tree,model_yuthon_cs_tree,base.group_user,1,1,1,1 +access_yuthon_cs_report,yuthon_cs_report,model_yuthon_cs_report,base.group_user,1,1,1,1