Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
hh_ccs
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
贺阳
hh_ccs
Commits
ee754777
提交
ee754777
authored
12月 03, 2025
作者:
贺阳
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
点击确认,创建TEMU提单,提单号不能重复,若重复则提示:提单号xxxx已存在,请勿重新创建
若勾选了获取尾程POD信息,则跟TK提单一致,调获取尾程POD的接口,显示POD预览文件。确认,生成预览文件,涂抹文字,点击确定只将文件上传到相应的附件。
上级
3265143c
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
78 行增加
和
56 行删除
+78
-56
batch_get_pod_info_wizard.py
ccs_base/wizard/batch_get_pod_info_wizard.py
+75
-53
batch_get_pod_info_wizard_views.xml
ccs_base/wizard/batch_get_pod_info_wizard_views.xml
+3
-3
没有找到文件。
ccs_base/wizard/batch_get_pod_info_wizard.py
浏览文件 @
ee754777
...
...
@@ -46,17 +46,17 @@ class BatchGetPodInfoWizard(models.TransientModel):
(
'创建temu提单'
,
'创建temu提单'
),
],
string
=
'Action Type'
,
default
=
'获取尾程POD信息'
)
#============temu提单 批量创建操作相关字段============
#
============temu提单 批量创建操作相关字段============
# 客户:默认TEMU平台客户,任一一个,可修改
partner_id
=
fields
.
Many2one
(
'res.partner'
,
string
=
'Customer'
,
#
客户
string
=
'Customer'
,
#
客户
default
=
lambda
self
:
self
.
get_temu_partner
(),
domain
=
"[('is_customer', '=', True), ('platform_type', '=', 'temu')]"
)
# 提单号:可输入多个,一行一个
bl_number
=
fields
.
Text
(
string
=
'BL Number'
,
#
提单号
bl_number
s
=
fields
.
Text
(
string
=
'BL Number'
,
#
提单号
help
=
'Enter multiple BL numbers, one per line'
# 输入多个BL号,每行一个
)
# 获取尾程POD信息☑️(默认勾选)
...
...
@@ -112,30 +112,43 @@ class BatchGetPodInfoWizard(models.TransientModel):
pdf_filename
=
fields
.
Char
(
string
=
'PDF文件名称'
)
processed_files_data
=
fields
.
Text
(
string
=
'已处理的文件数据'
,
help
=
'存储已处理的文件信息(JSON格式)'
)
def
action_preview
(
self
):
"""
预览操作:获取PDF、处理涂抹、合并PDF并显示
"""
try
:
def
_get_bill_numbers
(
self
):
if
self
.
action_type
==
'获取尾程POD信息'
:
bl_objs
=
self
.
get_order
()
_logger
.
info
(
f
"开始预览操作,提单数量: {len(bl_objs)}"
)
bill_numbers
=
[
self
.
env
[
'common.common'
]
.
sudo
()
.
process_match_str
(
bl
.
bl_no
)
for
bl
in
bl_objs
]
else
:
bill_numbers
=
[
self
.
env
[
'common.common'
]
.
sudo
()
.
process_match_str
(
bl_no
)
for
bl_no
in
self
.
bl_numbers
.
splitlines
()]
_logger
.
info
(
f
"开始预览操作,提单数量: {len(bill_numbers)}"
)
# 调用接口获取提单pdf文件
pdf_file_arr
=
self
.
_get_pdf_file_arr
(
)
pdf_file_arr
=
self
.
_get_pdf_file_arr
(
bill_numbers
)
# 处理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_obj
s
:
if
bl
.
id
not
in
matched_bl_ids
:
error_bl
.
append
(
bl
)
matched_bl_ids
=
[
f
[
'bl_no'
]
for
f
in
processed_files
if
f
.
get
(
'bl_no
'
)]
for
bl_no
in
bill_number
s
:
if
bl_no
not
in
matched_bl_ids
:
error_bl
.
append
(
bl_no
)
if
error_bl
:
logging
.
info
(
'
%
s个提单无法找到release note文件'
%
len
(
error_bl
))
if
not
self
.
_context
.
get
(
'is_skip_raise_error'
):
self
.
show_error_message
=
_
(
'
%
s bill of loading cannot find release note file'
)
%
(
', '
.
join
([
bl
.
bl_no
for
bl
in
error_bl
]))
', '
.
join
(
error_bl
))
return
processed_files
def
action_preview
(
self
):
"""
预览操作:获取PDF、处理涂抹、合并PDF并显示
"""
action_type
=
self
.
action_type
try
:
bl_objs
=
False
if
action_type
==
'获取尾程POD信息'
:
bl_objs
=
self
.
get_order
()
# 处理PDF文件,匹配提单对象
processed_files
=
self
.
_get_bill_numbers
()
# 如果启用了涂抹文字,进行处理
if
self
.
remove_specified_text
and
processed_files
:
...
...
@@ -169,17 +182,20 @@ class BatchGetPodInfoWizard(models.TransientModel):
# 如果所有文件都成功了(没有失败的文件),自动勾选"是否同步成功涂抹的提单"
if
len
(
successful_files
)
==
len
(
processed_files
)
and
not
failed_files
and
not
self
.
show_error_message
:
if
action_type
==
'获取尾程POD信息'
:
self
.
sync_successful_processed
=
True
_logger
.
info
(
f
"所有提单都处理成功,自动勾选同步选项"
)
else
:
self
.
generate_successful_processed
=
True
else
:
# 有失败的文件,保持未勾选状态,让用户决定
# 将成功处理的提单号追加到show_error_message中
if
successful_files
:
successful_bl_nos
=
[]
for
file_info
in
successful_files
:
if
file_info
.
get
(
'bl'
):
bl
=
file_info
[
'bl
'
]
successful_bl_nos
.
append
(
bl
.
bl
_no
)
if
file_info
.
get
(
'bl
_no
'
):
bl
_no
=
file_info
[
'bl_no
'
]
successful_bl_nos
.
append
(
bl_no
)
# 在错误消息后面追加成功处理的提单号
existing_error
=
self
.
show_error_message
or
''
successful_bl_nos_str
=
'、'
.
join
(
successful_bl_nos
)
if
successful_bl_nos
else
''
...
...
@@ -187,7 +203,10 @@ class BatchGetPodInfoWizard(models.TransientModel):
self
.
show_error_message
=
f
"{existing_error}{success_msg}"
_logger
.
info
(
f
"部分提单处理失败(成功:{len(successful_files)},失败:{len(failed_files)}),成功处理的提单号已显示"
)
if
action_type
==
'获取尾程POD信息'
:
self
.
sync_successful_processed
=
False
else
:
self
.
generate_successful_processed
=
False
# 序列化并存储处理后的文件数据(包括成功和失败的,但只有成功的才会合并PDF)
if
processed_files
:
...
...
@@ -200,18 +219,23 @@ class BatchGetPodInfoWizard(models.TransientModel):
self
.
processed_files_data
=
self
.
_serialize_processed_files
(
processed_files
)
successful_bl_data
=
[]
for
file_info
in
processed_files
:
if
file_info
.
get
(
'bl'
):
bl
=
file_info
[
'bl
'
]
if
file_info
.
get
(
'bl
_no
'
):
bl
_no
=
file_info
[
'bl_no
'
]
successful_bl_data
.
append
({
'bl_id'
:
bl
.
id
,
'bl_no'
:
bl
.
bl_no
'bl_no'
:
bl_no
})
# 没有涂抹文字,所有文件都成功,自动勾选
if
action_type
==
'获取尾程POD信息'
:
self
.
sync_successful_processed
=
True
_logger
.
info
(
f
"未启用涂抹文字,所有提单都成功,自动勾选同步选项"
)
else
:
self
.
generate_successful_processed
=
True
else
:
self
.
processed_files_data
=
''
if
action_type
==
'获取尾程POD信息'
:
self
.
sync_successful_processed
=
False
else
:
self
.
generate_successful_processed
=
False
# 返回表单视图
return
{
...
...
@@ -221,14 +245,15 @@ class BatchGetPodInfoWizard(models.TransientModel):
'view_mode'
:
'form'
,
'res_id'
:
self
.
id
,
'target'
:
'new'
,
'context'
:
{
'active_id'
:
bl_objs
.
ids
}
'context'
:
{
'active_id'
:
bl_objs
.
ids
if
bl_objs
else
False
}
}
except
Exception
as
e
:
_logger
.
error
(
f
"预览操作失败: {str(e)}"
)
self
.
show_error_message
=
_
(
'预览操作失败:
%
s'
)
%
str
(
e
)
return
{
'type'
:
'ir.actions.act_window'
,
'name'
:
_
(
'Batch Get POD Info'
),
'name'
:
_
(
'Batch Get POD Info'
)
if
action_type
==
'获取尾程POD信息'
else
_
(
'Create TEMU Bill of Loading'
),
'res_model'
:
'batch.get.pod.info.wizard'
,
'view_mode'
:
'form'
,
'res_id'
:
self
.
id
,
...
...
@@ -243,7 +268,17 @@ class BatchGetPodInfoWizard(models.TransientModel):
# 计算整个过程的耗时
start_time
=
time
.
time
()
self
.
show_error_message
=
False
action_type
=
self
.
action_type
bl_objs
=
False
if
action_type
==
'获取尾程POD信息'
:
bl_objs
=
self
.
get_order
()
else
:
# 根据提单号和客户生成temu提单
bl_objs
=
self
.
env
[
'cc.bl'
]
.
create
([{
'customer_id'
:
self
.
partner_id
.
id
,
'bl_type'
:
'temu'
,
'bl_no'
:
bl_no
}
for
bl_no
in
self
.
bl_numbers
.
splitlines
()])
_logger
.
info
(
f
"
%
s提单开始执行批量获取POD信息操作"
%
len
(
bl_objs
))
# 优先使用已处理的文件数据(预览时已处理)
...
...
@@ -264,23 +299,8 @@ class BatchGetPodInfoWizard(models.TransientModel):
# 如果没有已处理的数据,则执行处理流程
if
not
processed_files
:
# 调用接口获取提单pdf文件
pdf_file_arr
=
self
.
_get_pdf_file_arr
()
# 处理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
bl
.
id
not
in
matched_bl_ids
:
error_bl
.
append
(
bl
)
if
error_bl
:
logging
.
info
(
'
%
s个提单无法找到release note文件'
%
len
(
error_bl
))
# 英文提示
if
not
self
.
_context
.
get
(
'is_skip_raise_error'
):
self
.
show_error_message
=
_
(
'
%
s bill of loading cannot find release note file'
)
%
(
', '
.
join
([
bl
.
bl_no
for
bl
in
error_bl
]))
processed_files
=
self
.
_get_bill_numbers
()
# 如果启用了涂抹文字,进行处理
if
self
.
remove_specified_text
and
processed_files
:
processed_files
=
self
.
_remove_specified_text
(
processed_files
,
debug_mode
=
False
)
...
...
@@ -293,7 +313,8 @@ class BatchGetPodInfoWizard(models.TransientModel):
return
{
'type'
:
'ir.actions.act_window'
,
'res_model'
:
'batch.get.pod.info.wizard'
,
'name'
:
_
(
'Batch Get POD Info'
),
'name'
:
_
(
'Batch Get POD Info'
)
if
action_type
==
'获取尾程POD信息'
else
_
(
'Create TEMU Bill of Loading'
),
'view_mode'
:
'form'
,
'res_id'
:
self
.
id
,
'target'
:
'new'
,
...
...
@@ -307,11 +328,13 @@ class BatchGetPodInfoWizard(models.TransientModel):
return
{
'type'
:
'ir.actions.act_window'
,
'res_model'
:
'batch.get.pod.info.wizard'
,
'name'
:
_
(
'Batch Get POD Info'
),
'name'
:
_
(
'Batch Get POD Info'
)
if
action_type
==
'获取尾程POD信息'
else
_
(
'Create TEMU Bill of Loading'
),
'view_mode'
:
'form'
,
'res_id'
:
self
.
id
,
'target'
:
'new'
,
'context'
:
{
'default_show_error_message'
:
self
.
show_error_message
,
'active_id'
:
bl_objs
.
ids
}
'context'
:
{
'default_show_error_message'
:
self
.
show_error_message
,
'active_id'
:
bl_objs
.
ids
if
bl_objs
else
False
}
}
# 只处理成功涂抹的提单
...
...
@@ -334,11 +357,12 @@ class BatchGetPodInfoWizard(models.TransientModel):
_logger
.
warning
(
"没有找到已处理的文件数据"
)
# 回写到附件信息
if
successful_processed_files
and
(
self
.
sync_last_mile_pod
or
self
.
sync_match_node
):
if
successful_processed_files
and
(
(
self
.
sync_last_mile_pod
or
self
.
sync_match_node
)
or
self
.
get_last_mile_pod
):
# 回写PDF文件到清关文件
self
.
_write_pdf_file
(
successful_processed_files
)
# 再同步和回写
if
action_type
==
'获取尾程POD信息'
:
if
self
.
sync_last_mile_pod
and
successful_processed_files
:
self
.
_sync_last_mile_pod
(
successful_processed_files
)
...
...
@@ -363,11 +387,13 @@ class BatchGetPodInfoWizard(models.TransientModel):
return
{
'type'
:
'ir.actions.act_window'
,
'res_model'
:
'batch.get.pod.info.wizard'
,
'name'
:
_
(
'Batch Get POD Info'
),
'name'
:
_
(
'Batch Get POD Info'
)
if
action_type
==
'获取尾程POD信息'
else
_
(
'Create TEMU Bill of Loading'
),
'view_mode'
:
'form'
,
'res_id'
:
self
.
id
,
'target'
:
'new'
,
'context'
:
{
'default_show_error_message'
:
self
.
show_error_message
,
'active_id'
:
bl_objs
.
ids
}
'context'
:
{
'default_show_error_message'
:
self
.
show_error_message
,
'active_id'
:
bl_objs
.
ids
if
bl_objs
else
False
}
}
def
_validate_node_push_conditions
(
self
,
processed_files
):
...
...
@@ -379,14 +405,10 @@ class BatchGetPodInfoWizard(models.TransientModel):
return
processed_files
# 写一个方法调接口获取提单pdf文件
def
_get_pdf_file_arr
(
self
):
def
_get_pdf_file_arr
(
self
,
bill_numbers
):
"""
从API获取PDF文件
"""
# 获取当前选中的提单对象
bl_objs
=
self
.
get_order
()
bill_numbers
=
[
self
.
env
[
'common.common'
]
.
sudo
()
.
process_match_str
(
bl
.
bl_no
)
for
bl
in
bl_objs
]
# 调用API获取PDF文件
api_url
=
self
.
env
[
'ir.config_parameter'
]
.
sudo
()
.
get_param
(
'last_mile_pod_api_url'
,
'http://172.104.52.150:7002'
)
...
...
ccs_base/wizard/batch_get_pod_info_wizard_views.xml
浏览文件 @
ee754777
...
...
@@ -84,9 +84,9 @@
<field
name=
"partner_id"
attrs=
"{'invisible': [('action_type', '!=', '创建temu提单')]}"
/>
<!-- 请输入提单号,可输入多个,一行一个 -->
<field
name=
"bl_number"
<field
name=
"bl_number
s
"
placeholder=
"Please enter the bill of lading numbers. Multiple entries are allowed, one per line"
attrs=
"{'invisible': [('action_type', '!=', '创建temu提单')]}"
/>
attrs=
"{'
required': [('action_type', '=', '创建temu提单')],'
invisible': [('action_type', '!=', '创建temu提单')]}"
/>
</group>
<group>
<field
name=
"get_last_mile_pod"
...
...
@@ -131,7 +131,7 @@
<!-- 确认按钮:使用已处理的文件数据进行回写 -->
<!-- 如果有失败的文件(show_error_message不为空),需要勾选generate_successful_processed才显示;如果全部成功,直接显示 -->
<button
string=
"Confirm"
type=
"object"
name=
"confirm"
class=
"btn-primary"
attrs=
"{'invisible': ['|', ('get_last_mile_pod','=',
False),('|', ('pdf_file', '=', False), '&', ('show_error_message', '!=', False), ('generate_successful_processed', '=', False)
)]}"
/>
attrs=
"{'invisible': ['|', ('get_last_mile_pod','=',
True), '|', '|', ('pdf_file', '=', False), ('show_error_message', '!=', False), ('generate_successful_processed', '=', False
)]}"
/>
<button
string=
"Close"
special=
"cancel"
/>
</footer>
</sheet>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论