Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
hh_ccs
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
贺阳
hh_ccs
Commits
6d65fdd8
提交
6d65fdd8
authored
12月 10, 2024
作者:
刘擎阳
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1.优化时区计算
上级
d7256abe
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
13 行增加
和
3 行删除
+13
-3
common_common.py
ccs_base/models/common_common.py
+11
-2
order_state_change_rule.py
ccs_base/models/order_state_change_rule.py
+2
-1
没有找到文件。
ccs_base/models/common_common.py
浏览文件 @
6d65fdd8
# -*- coding: utf-8 -*-
import
datetime
import
re
import
pytz
from
odoo
import
fields
,
models
,
exceptions
,
api
,
tools
import
logging
from
.redis_connection
import
redis_connection
...
...
@@ -624,4 +625,13 @@ class CommonCommon(models.Model):
timezone_data
[
'Etc/UTC'
]
=
0
timezone_data
[
'Etc/Universal'
]
=
0
timezone_data
[
'Etc/Zulu'
]
=
0
return
'+
%
s'
%
timezone_data
[
name
]
if
timezone_data
[
name
]
>
0
else
str
(
timezone_data
[
name
])
\ No newline at end of file
return
'+
%
s'
%
timezone_data
[
name
]
if
timezone_data
[
name
]
>
0
else
str
(
timezone_data
[
name
])
def
get_time_zone
(
self
,
tz
):
london_tz
=
pytz
.
timezone
(
tz
)
# 获取当前时间
london_time
=
datetime
.
datetime
.
now
(
london_tz
)
# 获取时区偏移(单位是小时)
timezone_offset
=
london_time
.
utcoffset
()
.
total_seconds
()
/
3600
offset_str
=
f
"{int(timezone_offset):+d}"
return
offset_str
ccs_base/models/order_state_change_rule.py
浏览文件 @
6d65fdd8
...
...
@@ -124,7 +124,8 @@ class OrderStateChangeRule(models.Model):
# 调整时区
users_obj
=
self
.
env
[
'res.users'
]
.
search
([(
'name'
,
'='
,
'邮件接收'
)],
limit
=
1
)
tz
=
users_obj
.
tz
or
'UTC'
timezone_offset
=
self
.
env
[
'common.common'
]
.
sudo
()
.
init_timezone_data
(
tz
)
timezone_offset
=
self
.
env
[
'common.common'
]
.
sudo
()
.
get_time_zone
(
tz
)
# print(timezone_offset)
utc_time
=
local_time
-
timedelta
(
hours
=
int
(
timezone_offset
))
sql
=
"select id from cc_bl where UPPER(REPLACE(REPLACE(REPLACE(bl_no, ' ', ''), '-', ''), '/', '')) = '{0}' order by create_date desc limit 1"
.
format
(
order_no
.
replace
(
' '
,
''
)
.
replace
(
'-'
,
''
)
.
replace
(
'/'
,
''
))
self
.
_cr
.
execute
(
sql
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论