Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
hh_ccs
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
贺阳
hh_ccs
Commits
c6df2e31
提交
c6df2e31
authored
6月 10, 2025
作者:
刘擎阳
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of
https://e.coding.net/yizuo/hh_ccs/hh_ccs
into develop
上级
915f4c62
8c92b179
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
300 行增加
和
16 行删除
+300
-16
zh_CN.po
ccs_base/i18n/zh_CN.po
+0
-0
cc_last_mile_provider.py
ccs_base/models/cc_last_mile_provider.py
+37
-1
common_common.py
ccs_base/models/common_common.py
+18
-4
res_config_setting.py
ccs_base/models/res_config_setting.py
+5
-3
cc_last_mile_provider_views.xml
ccs_base/views/cc_last_mile_provider_views.xml
+4
-0
res_config_setting.xml
ccs_base/views/res_config_setting.xml
+5
-0
__init__.py
ccs_connect_tiktok/controllers/__init__.py
+1
-0
binary.py
ccs_connect_tiktok/controllers/binary.py
+118
-0
order_controller.py
ccs_connect_tiktok/controllers/order_controller.py
+0
-0
__init__.py
ccs_connect_tiktok/models/__init__.py
+2
-0
http.py
ccs_connect_tiktok/models/http.py
+53
-0
ir_attachment.py
ccs_connect_tiktok/models/ir_attachment.py
+56
-0
config.py
consumers/config.py
+1
-8
没有找到文件。
ccs_base/i18n/zh_CN.po
浏览文件 @
c6df2e31
差异被折叠。
点击展开。
ccs_base/models/cc_last_mile_provider.py
浏览文件 @
c6df2e31
...
@@ -11,15 +11,32 @@ class CCLastMileProvider(models.Model):
...
@@ -11,15 +11,32 @@ class CCLastMileProvider(models.Model):
for
record
in
self
:
for
record
in
self
:
if
record
.
matching_value
:
if
record
.
matching_value
:
values
=
record
.
matching_value
.
split
(
'
\n
'
)
values
=
record
.
matching_value
.
split
(
'
\n
'
)
existing_values
=
'
\n
'
.
join
(
self
.
search
([(
'id'
,
'!='
,
record
.
id
)])
.
mapped
(
'matching_value'
))
.
split
(
'
\n
'
)
existing_values
=
'
\n
'
.
join
(
self
.
search
(
[(
'id'
,
'!='
,
record
.
id
)])
.
mapped
(
'matching_value'
))
.
split
(
'
\n
'
)
if
len
(
values
)
!=
len
(
set
(
values
))
or
any
(
value
in
existing_values
for
value
in
values
):
if
len
(
values
)
!=
len
(
set
(
values
))
or
any
(
value
in
existing_values
for
value
in
values
):
raise
ValidationError
(
_
(
"Matching values must be unique!"
))
raise
ValidationError
(
_
(
"Matching values must be unique!"
))
@api.constrains
(
'placement_area'
)
def
_check_placement_area_unique
(
self
):
for
record
in
self
:
if
record
.
placement_area
:
placement_area
=
self
.
env
[
'common.common'
]
.
process_match_str
(
record
.
placement_area
)
# 检查所有记录的处理后值是否有重复
pro_map
=
self
.
get_all_placement_area
(
[(
'id'
,
'!='
,
record
.
id
),
(
'placement_area'
,
'!='
,
False
)])
pro_id
=
pro_map
.
get
(
placement_area
)
if
pro_id
:
raise
ValidationError
(
_
(
"Placement Area must be unique !"
))
logo
=
fields
.
Binary
(
'Courier Logo'
)
# 快递logo,英文
name
=
fields
.
Char
(
string
=
'Courier Name'
,
required
=
True
)
# 快递名称
name
=
fields
.
Char
(
string
=
'Courier Name'
,
required
=
True
)
# 快递名称
abbreviation
=
fields
.
Char
(
string
=
'Abbreviation'
,
required
=
True
)
# 简称
abbreviation
=
fields
.
Char
(
string
=
'Abbreviation'
,
required
=
True
)
# 简称
tape_color_value
=
fields
.
Char
(
string
=
'Tape Color Value'
)
# 胶带色值
tape_color_value
=
fields
.
Char
(
string
=
'Tape Color Value'
)
# 胶带色值
active
=
fields
.
Boolean
(
'Active'
,
default
=
True
)
# 有效☑️
active
=
fields
.
Boolean
(
'Active'
,
default
=
True
)
# 有效☑️
matching_value
=
fields
.
Text
(
string
=
'Matching Value'
)
# 尾程服务商匹配值
matching_value
=
fields
.
Text
(
string
=
'Matching Value'
)
# 尾程服务商匹配值
placement_area
=
fields
.
Char
(
'Placement Area'
)
# 摆放区域,英文
def
match_provider
(
self
,
provider_name
):
def
match_provider
(
self
,
provider_name
):
"""Check if the provider name exists in matching values and return the record."""
"""Check if the provider name exists in matching values and return the record."""
...
@@ -30,3 +47,22 @@ class CCLastMileProvider(models.Model):
...
@@ -30,3 +47,22 @@ class CCLastMileProvider(models.Model):
if
provider_name
in
record
.
matching_value
.
split
(
'
\n
'
):
if
provider_name
in
record
.
matching_value
.
split
(
'
\n
'
):
return
record
# 返回找到的记录
return
record
# 返回找到的记录
return
False
# 如果没有找到,返回 None
return
False
# 如果没有找到,返回 None
def
get_all_placement_area
(
self
,
domain
=
[]):
"""
获取所有摆放区域,英文
"""
all_providers
=
self
.
sudo
()
.
search
(
domain
or
[])
provider_map
=
{
self
.
env
[
'common.common'
]
.
process_match_str
(
provider
.
placement_area
):
provider
.
id
for
provider
in
all_providers
}
return
provider_map
def
search_pro_info
(
self
):
base_url
=
self
.
env
[
'ir.config_parameter'
]
.
sudo
()
.
get_param
(
'web.base.url'
)
return
{
'provider_name'
:
self
.
name
,
# 尾程快递名称
'placement_area'
:
self
.
placement_area
or
''
,
# 摆放区域
'logo'
:
"
%
s/web/image/
%
s/
%
s/logo"
%
(
base_url
,
self
.
_name
,
self
.
id
)
if
self
.
logo
else
''
,
# 快递logo
}
ccs_base/models/common_common.py
浏览文件 @
c6df2e31
...
@@ -16,6 +16,16 @@ class CommonCommon(models.Model):
...
@@ -16,6 +16,16 @@ class CommonCommon(models.Model):
_name
=
'common.common'
_name
=
'common.common'
_description
=
u'公用基础类'
_description
=
u'公用基础类'
# 去杠去空格转大写
def
process_match_str
(
self
,
input_str
):
"""
处理匹配的字符串,去除杠和空格,并转换为大写
"""
if
input_str
:
return
input_str
.
replace
(
'-'
,
''
)
.
replace
(
'/'
,
''
)
.
replace
(
' '
,
''
)
.
upper
()
return
input_str
def
get_local_time
(
self
,
local_time
=
None
,
user_obj
=
False
):
def
get_local_time
(
self
,
local_time
=
None
,
user_obj
=
False
):
"""获取Odoo时区的时间
"""获取Odoo时区的时间
Args:
Args:
...
@@ -30,8 +40,10 @@ class CommonCommon(models.Model):
...
@@ -30,8 +40,10 @@ class CommonCommon(models.Model):
if
not
user_obj
:
if
not
user_obj
:
user_obj
=
self
.
env
.
user
user_obj
=
self
.
env
.
user
user_tz
=
user_obj
.
tz
or
'UTC'
user_tz
=
user_obj
.
tz
or
'UTC'
timezone_offset
=
self
.
env
[
'common.common'
]
.
sudo
()
.
get_time_zone
(
user_tz
)
timezone_offset
=
self
.
env
[
'common.common'
]
.
sudo
(
local_time
=
local_time
+
datetime
.
timedelta
(
hours
=
int
(
timezone_offset
))
)
.
get_time_zone
(
user_tz
)
local_time
=
local_time
+
\
datetime
.
timedelta
(
hours
=
int
(
timezone_offset
))
return
local_time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
),
timezone_offset
return
local_time
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
),
timezone_offset
except
Exception
as
e
:
except
Exception
as
e
:
# 如果出现任何错误,返回UTC时间
# 如果出现任何错误,返回UTC时间
...
@@ -51,8 +63,10 @@ class CommonCommon(models.Model):
...
@@ -51,8 +63,10 @@ class CommonCommon(models.Model):
if
not
user_obj
:
if
not
user_obj
:
user_obj
=
self
.
env
.
user
user_obj
=
self
.
env
.
user
user_tz
=
user_obj
.
tz
or
'UTC'
user_tz
=
user_obj
.
tz
or
'UTC'
timezone_offset
=
self
.
env
[
'common.common'
]
.
sudo
()
.
get_time_zone
(
user_tz
)
timezone_offset
=
self
.
env
[
'common.common'
]
.
sudo
(
local_time
=
local_time
+
datetime
.
timedelta
(
hours
=
int
(
timezone_offset
))
)
.
get_time_zone
(
user_tz
)
local_time
=
local_time
+
\
datetime
.
timedelta
(
hours
=
int
(
timezone_offset
))
local_tz
=
pytz
.
timezone
(
user_tz
)
local_tz
=
pytz
.
timezone
(
user_tz
)
# 确保时间是本地时区
# 确保时间是本地时区
if
local_time
.
tzinfo
is
None
:
if
local_time
.
tzinfo
is
None
:
...
...
ccs_base/models/res_config_setting.py
浏览文件 @
c6df2e31
...
@@ -12,7 +12,10 @@ class ResConfigSettings(models.TransientModel):
...
@@ -12,7 +12,10 @@ class ResConfigSettings(models.TransientModel):
_inherit
=
'res.config.settings'
_inherit
=
'res.config.settings'
before_min
=
fields
.
Integer
(
'清关时间取值(早于清关结束)'
)
before_min
=
fields
.
Integer
(
'清关时间取值(早于清关结束)'
)
package_scan_min
=
fields
.
Integer
(
'一键全扫完成时间(min)'
,
help
=
'输入示范:10,即表示在10分钟内大包时间随机分配,并不能重复'
)
package_scan_min
=
fields
.
Integer
(
'一键全扫完成时间(min)'
,
help
=
'输入示范:10,即表示在10分钟内大包时间随机分配,并不能重复'
)
is_package_scan
=
fields
.
Boolean
(
'一键全扫开关'
,
default
=
False
,
config_parameter
=
'is_package_scan'
)
@api.model
@api.model
def
get_values
(
self
):
def
get_values
(
self
):
...
@@ -24,10 +27,9 @@ class ResConfigSettings(models.TransientModel):
...
@@ -24,10 +27,9 @@ class ResConfigSettings(models.TransientModel):
config
=
self
.
env
[
'ir.config_parameter'
]
.
sudo
()
config
=
self
.
env
[
'ir.config_parameter'
]
.
sudo
()
before_min
=
config
.
get_param
(
'before_min'
,
default
=
10
)
before_min
=
config
.
get_param
(
'before_min'
,
default
=
10
)
package_scan_min
=
config
.
get_param
(
'package_scan_min'
,
default
=
10
)
package_scan_min
=
config
.
get_param
(
'package_scan_min'
,
default
=
10
)
values
.
update
(
values
.
update
(
before_min
=
before_min
,
before_min
=
before_min
,
package_scan_min
=
package_scan_min
,
package_scan_min
=
package_scan_min
)
)
return
values
return
values
...
...
ccs_base/views/cc_last_mile_provider_views.xml
浏览文件 @
c6df2e31
...
@@ -7,11 +7,13 @@
...
@@ -7,11 +7,13 @@
<sheet>
<sheet>
<group>
<group>
<group>
<group>
<field
name=
"logo"
widget=
"image"
class=
"oe_avatar"
/>
<field
name=
"name"
/>
<!-- 快递名称 -->
<field
name=
"name"
/>
<!-- 快递名称 -->
<field
name=
"abbreviation"
/>
<!-- 简称 -->
<field
name=
"abbreviation"
/>
<!-- 简称 -->
<field
name=
"tape_color_value"
widget=
"color"
required=
"1"
/>
<!-- 胶带色值 -->
<field
name=
"tape_color_value"
widget=
"color"
required=
"1"
/>
<!-- 胶带色值 -->
<field
name=
"matching_value"
<field
name=
"matching_value"
placeholder=
"Multiple entries can be made, one matching value per line"
/>
<!-- 尾程服务商匹配值 -->
placeholder=
"Multiple entries can be made, one matching value per line"
/>
<!-- 尾程服务商匹配值 -->
<field
name=
"placement_area"
/>
</group>
</group>
<group>
<group>
<field
name=
"active"
/>
<!-- 有效☑️ -->
<field
name=
"active"
/>
<!-- 有效☑️ -->
...
@@ -31,6 +33,7 @@
...
@@ -31,6 +33,7 @@
<field
name=
"abbreviation"
/>
<!-- 简称 -->
<field
name=
"abbreviation"
/>
<!-- 简称 -->
<field
name=
"tape_color_value"
/>
<!-- 胶带色值 -->
<field
name=
"tape_color_value"
/>
<!-- 胶带色值 -->
<field
name=
"matching_value"
/>
<!-- 尾程服务商匹配值 -->
<field
name=
"matching_value"
/>
<!-- 尾程服务商匹配值 -->
<field
name=
"placement_area"
/>
<!-- 摆放区域 -->
<field
name=
"active"
/>
<!-- 有效☑️ -->
<field
name=
"active"
/>
<!-- 有效☑️ -->
</tree>
</tree>
</field>
</field>
...
@@ -43,6 +46,7 @@
...
@@ -43,6 +46,7 @@
<search
string=
"Last Mile Provider"
>
<search
string=
"Last Mile Provider"
>
<field
name=
"name"
/>
<field
name=
"name"
/>
<field
name=
"abbreviation"
/>
<field
name=
"abbreviation"
/>
<field
name=
"placement_area"
/>
</search>
</search>
</field>
</field>
</record>
</record>
...
...
ccs_base/views/res_config_setting.xml
浏览文件 @
c6df2e31
...
@@ -27,6 +27,11 @@
...
@@ -27,6 +27,11 @@
<div
class=
"col-12 col-lg-6 o_setting_box"
>
<div
class=
"col-12 col-lg-6 o_setting_box"
>
<div
class=
"o_setting_left_pane"
/>
<div
class=
"o_setting_left_pane"
/>
<div
class=
"o_setting_right_pane"
>
<div
class=
"o_setting_right_pane"
>
<div
class=
"text-muted"
>
<label
for=
"is_package_scan"
/>
<field
name=
"is_package_scan"
/>
</div>
<div
class=
"text-muted"
>
<div
class=
"text-muted"
>
<label
for=
"package_scan_min"
/>
<label
for=
"package_scan_min"
/>
<field
name=
"package_scan_min"
/>
<field
name=
"package_scan_min"
/>
...
...
ccs_connect_tiktok/controllers/__init__.py
浏览文件 @
c6df2e31
from
.
import
tt_controllers
from
.
import
tt_controllers
from
.
import
order_controller
from
.
import
order_controller
from
.
import
binary
ccs_connect_tiktok/controllers/binary.py
0 → 100644
浏览文件 @
c6df2e31
# Part of Odoo. See LICENSE file for full copyright and licensing details.
import
logging
from
odoo.addons.web.controllers.binary
import
Binary
try
:
from
werkzeug.utils
import
send_file
except
ImportError
:
from
odoo.tools._vendor.send_file
import
send_file
from
odoo
import
http
from
odoo.exceptions
import
UserError
from
odoo.http
import
request
from
odoo.tools
import
replace_exceptions
,
str2bool
from
odoo.tools.image
import
image_guess_size_from_field_name
_logger
=
logging
.
getLogger
(
__name__
)
BAD_X_SENDFILE_ERROR
=
"""
\
Odoo is running with --x-sendfile but is receiving /web/filestore requests.
With --x-sendfile enabled, NGINX should be serving the
/web/filestore route, however Odoo is receiving the
request.
This usually indicates that NGINX is badly configured,
please make sure the /web/filestore location block exists
in your configuration file and that it is similar to:
location /web/filestore {{
internal;
alias {data_dir}/filestore;
}}
"""
def
clean
(
name
):
return
name
.
replace
(
'
\x3c
'
,
''
)
class
AttachmentBinary
(
Binary
):
@http.route
([
'/web/image'
,
'/web/image/<string:xmlid>'
,
'/web/image/<string:xmlid>/<string:filename>'
,
'/web/image/<string:xmlid>/<int:width>x<int:height>'
,
'/web/image/<string:xmlid>/<int:width>x<int:height>/<string:filename>'
,
'/web/image/<string:model>/<int:id>/<string:field>'
,
'/web/image/<string:model>/<int:id>/<string:field>/<string:filename>'
,
'/web/image/<string:model>/<int:id>/<string:field>/<int:width>x<int:height>'
,
'/web/image/<string:model>/<int:id>/<string:field>/<int:width>x<int:height>/<string:filename>'
,
'/web/image/<int:id>'
,
'/web/image/<int:id>/<string:filename>'
,
'/web/image/<int:id>/<int:width>x<int:height>'
,
'/web/image/<int:id>/<int:width>x<int:height>/<string:filename>'
,
'/web/image/<int:id>-<string:unique>'
,
'/web/image/<int:id>-<string:unique>/<string:filename>'
,
'/web/image/<int:id>-<string:unique>/<int:width>x<int:height>'
,
'/web/image/<int:id>-<string:unique>/<int:width>x<int:height>/<string:filename>'
],
type
=
'http'
,
auth
=
"public"
,
cors
=
"*"
)
# pylint: disable=redefined-builtin,invalid-name
def
content_image
(
self
,
xmlid
=
None
,
model
=
'ir.attachment'
,
id
=
None
,
field
=
'raw'
,
filename_field
=
'name'
,
filename
=
None
,
mimetype
=
None
,
unique
=
False
,
download
=
False
,
width
=
0
,
height
=
0
,
crop
=
False
,
access_token
=
None
,
nocache
=
False
):
try
:
record
=
request
.
env
[
'ir.binary'
]
.
sudo
()
.
_find_record
(
xmlid
,
model
,
id
and
int
(
id
),
access_token
)
stream
=
request
.
env
[
'ir.binary'
]
.
sudo
()
.
_get_image_stream_from
(
record
,
field
,
filename
=
filename
,
filename_field
=
filename_field
,
mimetype
=
mimetype
,
width
=
int
(
width
),
height
=
int
(
height
),
crop
=
crop
,
)
except
UserError
as
exc
:
if
download
:
raise
request
.
not_found
()
from
exc
# Use the ratio of the requested field_name instead of "raw"
if
(
int
(
width
),
int
(
height
))
==
(
0
,
0
):
width
,
height
=
image_guess_size_from_field_name
(
field
)
record
=
request
.
env
.
ref
(
'web.image_placeholder'
)
.
sudo
()
stream
=
request
.
env
[
'ir.binary'
]
.
_get_image_stream_from
(
record
,
'raw'
,
width
=
int
(
width
),
height
=
int
(
height
),
crop
=
crop
,
)
send_file_kwargs
=
{
'as_attachment'
:
download
}
if
unique
:
send_file_kwargs
[
'immutable'
]
=
True
send_file_kwargs
[
'max_age'
]
=
http
.
STATIC_CACHE_LONG
if
nocache
:
send_file_kwargs
[
'max_age'
]
=
None
return
stream
.
get_response
(
**
send_file_kwargs
)
@http.route
([
'/web/content'
,
'/web/content/<string:xmlid>'
,
'/web/content/<string:xmlid>/<string:filename>'
,
'/web/content/<int:id>'
,
'/web/content/<int:id>/<string:filename>'
,
'/web/content/<string:model>/<int:id>/<string:field>'
,
'/web/content/<string:model>/<int:id>/<string:field>/<string:filename>'
],
type
=
'http'
,
auth
=
"public"
,
cors
=
"*"
)
# pylint: disable=redefined-builtin,invalid-name
def
content_common
(
self
,
xmlid
=
None
,
model
=
'ir.attachment'
,
id
=
None
,
field
=
'raw'
,
filename
=
None
,
filename_field
=
'name'
,
mimetype
=
None
,
unique
=
False
,
download
=
False
,
access_token
=
None
,
nocache
=
False
):
with
replace_exceptions
(
UserError
,
by
=
request
.
not_found
()):
record
=
request
.
env
[
'ir.binary'
]
.
sudo
()
.
_find_record
(
xmlid
,
model
,
id
and
int
(
id
),
access_token
)
stream
=
request
.
env
[
'ir.binary'
]
.
sudo
()
.
_get_stream_from
(
record
,
field
,
filename
,
filename_field
,
mimetype
)
if
request
.
httprequest
.
args
.
get
(
'access_token'
):
stream
.
public
=
True
send_file_kwargs
=
{
'as_attachment'
:
str2bool
(
download
)}
if
unique
:
send_file_kwargs
[
'immutable'
]
=
True
send_file_kwargs
[
'max_age'
]
=
http
.
STATIC_CACHE_LONG
if
nocache
:
send_file_kwargs
[
'max_age'
]
=
None
return
stream
.
get_response
(
**
send_file_kwargs
)
ccs_connect_tiktok/controllers/order_controller.py
浏览文件 @
c6df2e31
差异被折叠。
点击展开。
ccs_connect_tiktok/models/__init__.py
浏览文件 @
c6df2e31
...
@@ -6,6 +6,8 @@ from . import res_config_setting
...
@@ -6,6 +6,8 @@ from . import res_config_setting
from
.
import
ao_tt_api_log
from
.
import
ao_tt_api_log
from
.
import
cc_node
from
.
import
cc_node
from
.
import
cc_bill_loading
from
.
import
cc_bill_loading
from
.
import
ir_attachment
from
.
import
http
ccs_connect_tiktok/models/http.py
0 → 100644
浏览文件 @
c6df2e31
# -*- coding: utf-8 -*-
import
logging
from
datetime
import
datetime
,
timedelta
import
time
import
hashlib
from
odoo
import
models
from
odoo.http
import
request
__author__
=
'yubo.peng'
_logger
=
logging
.
getLogger
(
__name__
)
class
AuthenticationError
(
Exception
):
pass
class
Http
(
models
.
AbstractModel
):
_inherit
=
'ir.http'
@classmethod
def
_auth_method_erp_token
(
cls
):
# 从headers.environ中获取对方传过来的token,timestamp,加密的校验字符串
datas
=
request
.
httprequest
.
headers
.
environ
if
'HTTP_TOKEN'
in
datas
and
'HTTP_TIMESTAMP'
in
datas
and
'HTTP_CHECKSTR'
in
datas
:
# 从系统参数中获取TOKEt和密钥
factory_secret
=
request
.
env
[
'ir.config_parameter'
]
.
sudo
()
.
get_param
(
'erp_token'
)
erp_secret_key
=
request
.
env
[
'ir.config_parameter'
]
.
sudo
()
.
get_param
(
'erp_secret_key'
)
# 从系统参数获取是否时间校验,-1为不校验,其他为校验
check_timeout
=
int
(
request
.
env
[
'ir.config_parameter'
]
.
sudo
()
.
get_param
(
'check_timeout'
)
or
5
)
if
not
factory_secret
:
raise
AuthenticationError
(
'系统中未设置ERP TOKEN'
)
if
datas
[
'HTTP_TOKEN'
]
!=
factory_secret
:
raise
AuthenticationError
(
'无效的token'
)
if
check_timeout
>
0
:
post_time
=
int
(
datas
[
'HTTP_TIMESTAMP'
])
datetime_post
=
datetime
.
fromtimestamp
(
post_time
)
datetime_now
=
datetime
.
now
()
.
replace
(
microsecond
=
0
)
datetime_del
=
datetime_now
+
timedelta
(
seconds
=
check_timeout
)
if
datetime_post
>
datetime_del
:
raise
AuthenticationError
(
'请求已过期'
)
# 获得sha1_str加密字符串
check_str
=
'
%
s
%
s
%
s'
%
(
datas
[
'HTTP_TOKEN'
],
datas
[
'HTTP_TIMESTAMP'
],
erp_secret_key
)
check_crm_str
=
hashlib
.
sha1
(
check_str
.
encode
(
'utf-8'
))
.
hexdigest
()
if
check_crm_str
.
upper
()
!=
datas
[
'HTTP_CHECKSTR'
]
.
upper
():
raise
AuthenticationError
(
'数据校验不通过'
)
else
:
raise
AuthenticationError
(
'请求参数中无token'
)
ccs_connect_tiktok/models/ir_attachment.py
0 → 100644
浏览文件 @
c6df2e31
# -*- coding: utf-8 -*-
from
odoo
import
models
,
api
,
_
from
collections
import
defaultdict
from
odoo.exceptions
import
AccessError
class
IrAttachment
(
models
.
Model
):
_inherit
=
"ir.attachment"
# override
@api.model
def
check
(
self
,
mode
,
values
=
None
):
""" Restricts the access to an ir.attachment, according to referred mode """
if
self
.
env
.
is_superuser
():
return
True
# Always require an internal user (aka, employee) to access to a attachment
if
not
(
self
.
env
.
is_admin
()
or
self
.
env
.
user
.
has_group
(
'base.group_user'
)):
raise
AccessError
(
_
(
"Sorry, you are not allowed to access this document."
))
# collect the records to check (by model)
model_ids
=
defaultdict
(
set
)
# {model_name: set(ids)}
if
self
:
# DLE P173: `test_01_portal_attachment`
self
.
env
[
'ir.attachment'
]
.
flush
([
'res_model'
,
'res_id'
,
'create_uid'
,
'public'
,
'res_field'
])
self
.
_cr
.
execute
(
'SELECT res_model, res_id, create_uid, public, res_field FROM ir_attachment WHERE id IN
%
s'
,
[
tuple
(
self
.
ids
)])
for
res_model
,
res_id
,
create_uid
,
public
,
res_field
in
self
.
_cr
.
fetchall
():
if
public
and
mode
==
'read'
:
continue
if
not
(
res_model
and
res_id
):
continue
model_ids
[
res_model
]
.
add
(
res_id
)
if
values
and
values
.
get
(
'res_model'
)
and
values
.
get
(
'res_id'
):
model_ids
[
values
[
'res_model'
]]
.
add
(
values
[
'res_id'
])
# check access rights on the records
for
res_model
,
res_ids
in
model_ids
.
items
():
# ignore attachments that are not attached to a resource anymore
# when checking access rights (resource was deleted but attachment
# was not)
if
res_model
not
in
self
.
env
:
continue
if
res_model
==
'res.users'
and
len
(
res_ids
)
==
1
and
self
.
env
.
uid
==
list
(
res_ids
)[
0
]:
# by default a user cannot write on itself, despite the list of writeable fields
# e.g. in the case of a user inserting an image into his image signature
# we need to bypass this check which would needlessly throw us away
continue
records
=
self
.
env
[
res_model
]
.
browse
(
res_ids
)
.
exists
()
# For related models, check if we can write to the model, as unlinking
# and creating attachments can be seen as an update to the model
access_mode
=
'write'
if
mode
in
(
'create'
,
'unlink'
)
else
mode
records
.
check_access_rights
(
access_mode
)
records
.
check_access_rule
(
access_mode
)
@api.model
def
read_as_sudo
(
self
,
domain
=
None
,
fields
=
None
):
return
self
.
sudo
()
.
search_read
(
domain
,
fields
)
consumers/config.py
浏览文件 @
c6df2e31
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
# 本地
# 本地
db_ip
=
"127.0.0.1"
db_ip
=
"127.0.0.1"
db_port
=
"8069"
db_port
=
"8069"
db_name
=
"hhccs
_test
"
db_name
=
"hhccs
324
"
db_user
=
"admin"
db_user
=
"admin"
db_password
=
"admin"
db_password
=
"admin"
...
@@ -13,13 +13,6 @@ redis_options = dict(
...
@@ -13,13 +13,6 @@ redis_options = dict(
db
=
0
db
=
0
)
)
postgresql_options
=
dict
(
host
=
"127.0.0.1"
,
port
=
5431
,
database
=
"hh_ccs_test"
,
user
=
"odoo14"
,
password
=
"qq166349"
,
)
# 测试
# 测试
# db_ip = "121.199.167.133"
# db_ip = "121.199.167.133"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论