提交 b127cb4b authored 作者: 贺阳's avatar 贺阳

获取优化

上级 df7602c3
......@@ -1152,6 +1152,7 @@ class CcBL(models.Model):
'type': 'ir.actions.act_window',
'view_mode': 'form',
'res_model': 'batch.get.pod.info.wizard',
'context': {'active_id': self.ids},
'target': 'new',
}
......
......@@ -44,14 +44,13 @@ class BatchGetPodInfoWizard(models.TransientModel):
bl_objs = self.get_order()
# 调用接口获取提单pdf文件
pdf_file_arr = self._get_pdf_file_arr()
if not pdf_file_arr:
raise ValidationError(_('No PDF files found'))#提示:没有获取到PDF文件
# 处理PDF文件,匹配提单对象
processed_files = self._match_bl_by_file_name(pdf_file_arr)
# 把没有匹配到文件的进行提示
error_bl = []
matched_bl_ids = [f['bl'].id for f in processed_files if f.get('bl')]
for bl in bl_objs:
if not bl in [f['bl'] for f in processed_files]:
if bl.id not in matched_bl_ids:
error_bl.append(bl)
if error_bl:
# 英文提示
......@@ -87,7 +86,6 @@ class BatchGetPodInfoWizard(models.TransientModel):
request_data = {
"bill_numbers": bill_numbers
}
try:
response = requests.post(
f"{api_url}/api/release-notes/pdfs",
......@@ -107,6 +105,7 @@ class BatchGetPodInfoWizard(models.TransientModel):
# 处理结果数据
results = result.get('results', [])
if not results:
raise ValidationError(_('No PDF files found in API response'))#提示:API调用成功,但没有PDF文件
# 构建PDF文件数组
......@@ -137,11 +136,7 @@ class BatchGetPodInfoWizard(models.TransientModel):
except Exception as e:
_logger.warning(f"API PDF文件验证失败,提单号: {bill_number}, 错误: {str(e)}")
continue
if not pdf_file_arr:
_logger.error("所有API PDF文件验证都失败")
raise ValidationError(_('All API PDF files failed validation'))#提示:所有API PDF文件验证都失败
logging.info('len(pdf_file_arr): %s' % len(pdf_file_arr))
return pdf_file_arr
else:
raise ValidationError(_('Failed to get PDF file from API: %s') % response.text)
......@@ -194,6 +189,7 @@ class BatchGetPodInfoWizard(models.TransientModel):
}
processed_files.append(processed_file)
break
logging.info("继续下一个提单")
_logger.info(f"匹配完成,成功匹配{len(processed_files)}个文件")
return processed_files
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论