Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
hh_ccs
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
贺阳
hh_ccs
Commits
02db7a0f
提交
02db7a0f
authored
5月 27, 2025
作者:
伍姿英
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'release/2.7.1'
上级
4d3806c3
0d9e8a71
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
75 行增加
和
13 行删除
+75
-13
cc_bill_loading.py
ccs_base/models/cc_bill_loading.py
+10
-2
order_state_change_rule.py
ccs_base/models/order_state_change_rule.py
+24
-10
__manifest__.py
ccs_connect_tiktok/__manifest__.py
+1
-0
timer.xml
ccs_connect_tiktok/data/timer.xml
+17
-0
ao_tt_api_log.py
ccs_connect_tiktok/models/ao_tt_api_log.py
+23
-1
没有找到文件。
ccs_base/models/cc_bill_loading.py
浏览文件 @
02db7a0f
...
...
@@ -105,7 +105,8 @@ class CcBigPackage(models.Model):
'type'
:
'ir.actions.act_window'
,
'res_model'
:
'cc.package.good'
,
'view_mode'
:
'tree,form'
,
'domain'
:
[(
'big_package_id'
,
'='
,
self
.
id
),
(
'is_cancel'
,
'='
,
False
)],
# 'domain': [('big_package_id', '=', self.id), ('is_cancel', '=', False)],
'domain'
:
[(
'bl_line_id'
,
'in'
,
self
.
ship_package_ids
.
ids
),
(
'is_cancel'
,
'='
,
False
)],
}
def
action_link_pallet
(
self
):
...
...
@@ -865,12 +866,19 @@ class CcBL(models.Model):
# 创建显示商品的action
def
action_show_package_good
(
self
):
# 返回一个action,显示商品
sql
=
"select id from cc_ship_package where bl_id=
%
s"
%
self
.
id
self
.
_cr
.
execute
(
sql
)
result
=
self
.
_cr
.
fetchall
()
ids
=
[]
if
result
:
ids
=
[
i
[
0
]
for
i
in
result
]
return
{
'name'
:
_
(
'Goods'
),
'type'
:
'ir.actions.act_window'
,
'res_model'
:
'cc.package.good'
,
'view_mode'
:
'tree,form'
,
'domain'
:
[(
'bl_id'
,
'='
,
self
.
id
),
(
'is_cancel'
,
'='
,
False
)],
# 'domain': [('bl_id', '=', self.id), ('is_cancel', '=', False)],
'domain'
:
[(
'bl_line_id'
,
'in'
,
ids
),
(
'is_cancel'
,
'='
,
False
)],
}
# 增加清关截止日期
...
...
ccs_base/models/order_state_change_rule.py
浏览文件 @
02db7a0f
...
...
@@ -117,9 +117,18 @@ class OrderStateChangeRule(models.Model):
def
upload_pod_attachment
(
self
,
bl_obj
,
name
,
data
):
"""尾程交接POD(待大包数量和箱号) 文件上传与同步"""
file_objs
=
self
.
env
[
'cc.clearance.file'
]
.
sudo
()
.
search
([(
'file_name'
,
'='
,
'尾程交接POD(待大包数量和箱号)'
),
(
'bl_id'
,
'in'
,
bl_obj
.
ids
)])
arr
=
[
{
'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
for
file_obj
in
file_objs
:
...
...
@@ -127,9 +136,9 @@ class OrderStateChangeRule(models.Model):
while
retries
<=
max_retries
:
try
:
# 设置文件内容
file_obj
.
file
=
base64
.
encodebytes
(
data
)
file_obj
.
attachment_name
=
name
file_obj
.
is_upload
=
False
# 确保文件状态是未上传
#
file_obj.file = base64.encodebytes(data)
#
file_obj.attachment_name = name
#
file_obj.is_upload = False # 确保文件状态是未上传
# 尝试上传操作
file_obj
.
action_sync
()
# 检查是否上传成功,假设 is_upload 为 False 表示上传失败
...
...
@@ -201,7 +210,8 @@ class OrderStateChangeRule(models.Model):
text_arr
=
self
.
find_final_email_text
(
email_body
)
logging
.
info
(
'data_arr:
%
s'
%
text_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 = []
try
:
text_arr
=
[
i
.
replace
(
'-'
,
''
)
.
replace
(
' '
,
''
)
for
i
in
text_arr
]
...
...
@@ -210,9 +220,13 @@ class OrderStateChangeRule(models.Model):
result
=
self
.
_cr
.
fetchall
()
ids
=
[
i
[
0
]
for
i
in
result
]
bl_objs
=
self
.
env
[
'cc.bl'
]
.
sudo
()
.
search
([(
'id'
,
'in'
,
ids
)])
if
result
else
False
if
bl_objs
and
attachment_tuple
:
attachment_name
,
attachment_data
=
attachment_tuple
self
.
upload_pod_attachment
(
bl_objs
,
attachment_name
,
attachment_data
)
if
bl_objs
and
attachment_tuple_arr
:
file_objs
=
self
.
env
[
'cc.clearance.file'
]
.
sudo
()
.
search
([(
'file_name'
,
'='
,
'尾程交接POD(待大包数量和箱号)'
),
(
'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()
# if redis_conn == 'no':
# raise ValidationError('未连接redis')
...
...
ccs_connect_tiktok/__manifest__.py
浏览文件 @
02db7a0f
...
...
@@ -16,6 +16,7 @@
'security/ir.model.access.csv'
,
# data
'data/data.xml'
,
'data/timer.xml'
,
# wizard
'wizard/batch_input_ship_package_statu_wizard.xml'
,
'wizard/update_bl_status_wizard.xml'
,
...
...
ccs_connect_tiktok/data/timer.xml
0 → 100644
浏览文件 @
02db7a0f
<odoo>
<data>
<record
id=
"cron_delete_log"
model=
"ir.cron"
>
<field
name=
"name"
>
定时删除历史日志
</field>
<field
name=
"model_id"
ref=
"ccs_connect_tiktok.model_ao_tt_api_log"
/>
<field
name=
"state"
>
code
</field>
<field
name=
"code"
>
model.cron_delete_log()
</field>
<field
name=
'interval_number'
>
2
</field>
<field
name=
'interval_type'
>
hours
</field>
<field
name=
"numbercall"
>
-1
</field>
<field
name=
"active"
eval=
"False"
/>
</record>
</data>
</odoo>
\ No newline at end of file
ccs_connect_tiktok/models/ao_tt_api_log.py
浏览文件 @
02db7a0f
...
...
@@ -4,6 +4,7 @@ from datetime import datetime
from
odoo
import
models
,
fields
,
api
,
_
from
odoo.exceptions
import
ValidationError
,
Warning
import
logging
from
datetime
import
timedelta
_logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -14,7 +15,7 @@ class TTErrorLog(models.Model):
_order
=
'id desc'
big_bag_no
=
fields
.
Char
(
'业务信息'
,
index
=
True
)
push_time
=
fields
.
Datetime
(
'产生时间'
,
index
=
True
)
push_time
=
fields
.
Datetime
(
'产生时间'
)
error_msg
=
fields
.
Char
(
'失败原因'
)
success_bl
=
fields
.
Boolean
(
'是否成功'
,
default
=
False
,
index
=
True
)
data_text
=
fields
.
Text
(
'传输数据'
)
...
...
@@ -42,3 +43,24 @@ class TTErrorLog(models.Model):
def
deal_tt_error_log
(
self
):
for
item
in
self
:
item
.
state
=
'已处理'
def
cron_delete_log
(
self
):
history_days
=
self
.
env
[
'ir.config_parameter'
]
.
sudo
()
.
get_param
(
'history_days'
)
or
180
history_limit_log
=
self
.
env
[
'ir.config_parameter'
]
.
sudo
()
.
get_param
(
'history_limit_log'
)
or
10000
history_limit_log
=
int
(
history_limit_log
)
history_days
=
int
(
history_days
)
current_date
=
datetime
.
utcnow
()
# 计算180天之前的日期
past_date
=
current_date
-
timedelta
(
days
=
history_days
)
sql
=
'select id from ao_tt_api_log where create_date <
%
s order by create_date asc limit
%
s;'
self
.
_cr
.
execute
(
sql
,
(
past_date
,
history_limit_log
))
result
=
self
.
_cr
.
fetchall
()
tk_log_ids
=
[]
if
result
:
tk_log_ids
=
[
i
[
0
]
for
i
in
result
]
if
tk_log_ids
:
log_ids
=
'(
%
s)'
%
str
(
tk_log_ids
)[
1
:
-
1
]
delete_api_log_sql
=
'delete from ao_tt_api_log where id in
%
s'
%
log_ids
self
.
_cr
.
execute
(
delete_api_log_sql
)
self
.
_cr
.
commit
()
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论