优化接口;质量检查wizard添加发布按钮
This commit is contained in:
@@ -8,8 +8,8 @@ import json
|
||||
|
||||
class QualityController(http.Controller):
|
||||
|
||||
@http.route('/api/quality/report/download/<string:retrospect_ref>', 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')
|
||||
]
|
||||
)
|
||||
@@ -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()
|
||||
|
||||
@@ -79,7 +79,10 @@
|
||||
attrs="{'invisible': ['|', ('quality_state', '!=', 'none'), ('test_type', '!=', 'passfail')]}" data-hotkey="x"/>
|
||||
<button name="action_generate_previous_window" type="object" class="btn-secondary" string="Previous" attrs="{'invisible': [('position_current_check', '=', 1)]}"/>
|
||||
<button name="action_generate_next_window" type="object" class="btn-secondary" string="Next" attrs="{'invisible': [('is_last_check', '=', True)]}"/>
|
||||
<button string="发布" name="publish" type="object" class="btn-primary"
|
||||
attrs="{'invisible': ['|', ('quality_state', '!=', 'none'), ('test_type', '!=', 'factory_inspection')]}" data-hotkey="p"/>
|
||||
<button string="Cancel" class="btn btn-secondary" special="cancel" data-hotkey="z" />
|
||||
|
||||
</footer>
|
||||
</form>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user