From 7755cc3982ef55bd80552aee50eb993ecb2ab55e Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Fri, 14 Mar 2025 15:45:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8E=A5=E5=8F=A3;=E8=B4=A8?= =?UTF-8?q?=E9=87=8F=E6=A3=80=E6=9F=A5wizard=E6=B7=BB=E5=8A=A0=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- quality_control/controllers/main.py | 18 ++++++++++++++---- quality_control/wizard/quality_check_wizard.py | 4 ++++ .../wizard/quality_check_wizard_views.xml | 3 +++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/quality_control/controllers/main.py b/quality_control/controllers/main.py index 1d72dd4f..fb5ca24c 100644 --- a/quality_control/controllers/main.py +++ b/quality_control/controllers/main.py @@ -8,8 +8,8 @@ import json class QualityController(http.Controller): - @http.route('/api/quality/report/download/', type='http', auth='public', csrf=False) - def get_quality_report(self, retrospect_ref, **kwargs): + @http.route(['/api/quality/report/download'], type='http', auth='public', csrf=False, website=False) # 移除 cors="*" + def get_quality_report(self, retrospect_ref=None, **kwargs): """获取质检报告的下载接口 Args: @@ -19,6 +19,10 @@ class QualityController(http.Controller): 直接返回文件下载响应 """ try: + # 如果retrospect_ref为None,尝试从查询参数获取 + if not retrospect_ref: + retrospect_ref = kwargs.get('retrospect_ref') + # 参数验证 if not retrospect_ref: return self._json_response({ @@ -63,7 +67,9 @@ class QualityController(http.Controller): headers=[ ('Content-Type', 'application/pdf'), ('Content-Disposition', f'attachment; filename="{filename}"'), - ('Access-Control-Allow-Origin', '*') + ('Access-Control-Allow-Origin', '*'), + ('Access-Control-Allow-Methods', 'GET, OPTIONS'), + ('Access-Control-Allow-Headers', 'Content-Type, Authorization') ] ) @@ -78,5 +84,9 @@ class QualityController(http.Controller): return Response( json.dumps(data, ensure_ascii=False), mimetype='application/json;charset=utf-8', - headers=[('Access-Control-Allow-Origin', '*')] + headers=[ + ('Access-Control-Allow-Origin', '*'), + ('Access-Control-Allow-Methods', 'GET, OPTIONS'), + ('Access-Control-Allow-Headers', 'Content-Type, Authorization') + ] ) \ No newline at end of file diff --git a/quality_control/wizard/quality_check_wizard.py b/quality_control/wizard/quality_check_wizard.py index 300faf1d..7be548c1 100644 --- a/quality_control/wizard/quality_check_wizard.py +++ b/quality_control/wizard/quality_check_wizard.py @@ -112,3 +112,7 @@ class QualityCheckWizard(models.TransientModel): default_current_check_id=self.current_check_id.id, ) return action + + # 对于成品出库的出厂检验报告,增加发布按钮 + def publish(self): + self.current_check_id._do_publish_implementation() diff --git a/quality_control/wizard/quality_check_wizard_views.xml b/quality_control/wizard/quality_check_wizard_views.xml index 1b87847e..8631b500 100644 --- a/quality_control/wizard/quality_check_wizard_views.xml +++ b/quality_control/wizard/quality_check_wizard_views.xml @@ -79,7 +79,10 @@ attrs="{'invisible': ['|', ('quality_state', '!=', 'none'), ('test_type', '!=', 'passfail')]}" data-hotkey="x"/>