Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
hh_ccs
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
贺阳
hh_ccs
Commits
0d9e8a71
提交
0d9e8a71
authored
5月 26, 2025
作者:
刘擎阳
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.pod文件获取优化
上级
3b209303
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
24 行增加
和
10 行删除
+24
-10
order_state_change_rule.py
ccs_base/models/order_state_change_rule.py
+24
-10
没有找到文件。
ccs_base/models/order_state_change_rule.py
浏览文件 @
0d9e8a71
...
@@ -117,9 +117,18 @@ class OrderStateChangeRule(models.Model):
...
@@ -117,9 +117,18 @@ class OrderStateChangeRule(models.Model):
def
upload_pod_attachment
(
self
,
bl_obj
,
name
,
data
):
def
upload_pod_attachment
(
self
,
bl_obj
,
name
,
data
):
"""尾程交接POD(待大包数量和箱号) 文件上传与同步"""
"""尾程交接POD(待大包数量和箱号) 文件上传与同步"""
file_objs
=
self
.
env
[
'cc.clearance.file'
]
.
sudo
()
.
search
([(
'file_name'
,
'='
,
'尾程交接POD(待大包数量和箱号)'
),
arr
=
[
(
'bl_id'
,
'in'
,
bl_obj
.
ids
)])
{
'file_name'
:
'尾程交接POD(待大包数量和箱号)'
,
'file'
:
base64
.
encodebytes
(
data
),
'attachment_name'
:
name
,
'is_upload'
:
False
,
'bl_id'
:
bl
.
id
}
for
bl
in
bl_obj
]
# file_objs = self.env['cc.clearance.file'].sudo().search([('file_name', '=', '尾程交接POD(待大包数量和箱号)'),
# ('bl_id', 'in', bl_obj.ids)])
file_objs
=
self
.
env
[
'cc.clearance.file'
]
.
sudo
()
.
create
(
arr
)
# 最大重试次数
# 最大重试次数
max_retries
=
2
max_retries
=
2
for
file_obj
in
file_objs
:
for
file_obj
in
file_objs
:
...
@@ -127,9 +136,9 @@ class OrderStateChangeRule(models.Model):
...
@@ -127,9 +136,9 @@ class OrderStateChangeRule(models.Model):
while
retries
<=
max_retries
:
while
retries
<=
max_retries
:
try
:
try
:
# 设置文件内容
# 设置文件内容
file_obj
.
file
=
base64
.
encodebytes
(
data
)
#
file_obj.file = base64.encodebytes(data)
file_obj
.
attachment_name
=
name
#
file_obj.attachment_name = name
file_obj
.
is_upload
=
False
# 确保文件状态是未上传
#
file_obj.is_upload = False # 确保文件状态是未上传
# 尝试上传操作
# 尝试上传操作
file_obj
.
action_sync
()
file_obj
.
action_sync
()
# 检查是否上传成功,假设 is_upload 为 False 表示上传失败
# 检查是否上传成功,假设 is_upload 为 False 表示上传失败
...
@@ -201,7 +210,8 @@ class OrderStateChangeRule(models.Model):
...
@@ -201,7 +210,8 @@ class OrderStateChangeRule(models.Model):
text_arr
=
self
.
find_final_email_text
(
email_body
)
text_arr
=
self
.
find_final_email_text
(
email_body
)
logging
.
info
(
'data_arr:
%
s'
%
text_arr
)
logging
.
info
(
'data_arr:
%
s'
%
text_arr
)
attachment_arr
=
kwargs
[
'attachment_arr'
]
attachment_arr
=
kwargs
[
'attachment_arr'
]
attachment_tuple
=
attachment_arr
[
0
]
if
attachment_arr
else
[]
# attachment_tuple = attachment_arr[0] if attachment_arr else []
attachment_tuple_arr
=
attachment_arr
if
attachment_arr
else
[]
# order_obj_arr = []
# order_obj_arr = []
try
:
try
:
text_arr
=
[
i
.
replace
(
'-'
,
''
)
.
replace
(
' '
,
''
)
for
i
in
text_arr
]
text_arr
=
[
i
.
replace
(
'-'
,
''
)
.
replace
(
' '
,
''
)
for
i
in
text_arr
]
...
@@ -210,9 +220,13 @@ class OrderStateChangeRule(models.Model):
...
@@ -210,9 +220,13 @@ class OrderStateChangeRule(models.Model):
result
=
self
.
_cr
.
fetchall
()
result
=
self
.
_cr
.
fetchall
()
ids
=
[
i
[
0
]
for
i
in
result
]
ids
=
[
i
[
0
]
for
i
in
result
]
bl_objs
=
self
.
env
[
'cc.bl'
]
.
sudo
()
.
search
([(
'id'
,
'in'
,
ids
)])
if
result
else
False
bl_objs
=
self
.
env
[
'cc.bl'
]
.
sudo
()
.
search
([(
'id'
,
'in'
,
ids
)])
if
result
else
False
if
bl_objs
and
attachment_tuple
:
if
bl_objs
and
attachment_tuple_arr
:
attachment_name
,
attachment_data
=
attachment_tuple
file_objs
=
self
.
env
[
'cc.clearance.file'
]
.
sudo
()
.
search
([(
'file_name'
,
'='
,
'尾程交接POD(待大包数量和箱号)'
),
self
.
upload_pod_attachment
(
bl_objs
,
attachment_name
,
attachment_data
)
(
'bl_id'
,
'in'
,
bl_objs
.
ids
)])
file_objs
.
unlink
()
for
attachment_tuple
in
attachment_tuple_arr
:
attachment_name
,
attachment_data
=
attachment_tuple
self
.
upload_pod_attachment
(
bl_objs
,
attachment_name
,
attachment_data
)
# redis_conn = self.env['common.common'].sudo().get_redis()
# redis_conn = self.env['common.common'].sudo().get_redis()
# if redis_conn == 'no':
# if redis_conn == 'no':
# raise ValidationError('未连接redis')
# raise ValidationError('未连接redis')
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论