Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
hh_ccs
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
贺阳
hh_ccs
Commits
fd679109
提交
fd679109
authored
11月 25, 2025
作者:
贺阳
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
批量查询的优化
上级
ad79df9f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
47 行增加
和
32 行删除
+47
-32
__manifest__.py
multi_record_search/__manifest__.py
+1
-1
multi_search.py
multi_record_search/models/multi_search.py
+46
-31
没有找到文件。
multi_record_search/__manifest__.py
浏览文件 @
fd679109
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
This module provides a mixin that allows searching multiple records at once using special syntax:
This module provides a mixin that allows searching multiple records at once using special syntax:
{term1 term2 term3}
{term1 term2 term3}
[term1, term2, term3]
[term1, term2, term3]
空格,逗号,换行 这些可以在系统参数进行自定义,用{}或[]包围
The mixin can be inherited by any model to enable multi-search functionality.
The mixin can be inherited by any model to enable multi-search functionality.
"""
,
"""
,
'author'
:
'SeaTek'
,
'author'
:
'SeaTek'
,
...
...
multi_record_search/models/multi_search.py
浏览文件 @
fd679109
...
@@ -14,38 +14,53 @@ class BaseModel(models.AbstractModel):
...
@@ -14,38 +14,53 @@ class BaseModel(models.AbstractModel):
"""Check is multi-search pattern or not."""
"""Check is multi-search pattern or not."""
if
not
isinstance
(
value
,
str
):
if
not
isinstance
(
value
,
str
):
return
False
,
[]
return
False
,
[]
# 直接根据逗号或空格或换行符分割
if
value
.
startswith
(
'{'
)
and
value
.
endswith
(
'}'
)
or
value
.
startswith
(
'['
)
and
value
.
endswith
(
']'
):
separators
=
self
.
env
[
'ir.config_parameter'
]
.
sudo
()
.
get_param
(
'multi_record_search_separators'
,
content
=
value
[
1
:
-
1
]
default
=
"[',', ',', ' ', '
\n
', ' ']"
)
if
not
content
:
separators
=
eval
(
separators
)
return
False
,
[]
# 判断value是否包含分隔符
# 直接根据逗号或空格或换行符分割
if
any
(
sep
in
value
for
sep
in
separators
)
or
value
.
startswith
(
'{'
)
and
value
.
endswith
(
'}'
)
or
value
.
startswith
(
separators
=
self
.
env
[
'ir.config_parameter'
]
.
sudo
()
.
get_param
(
'multi_record_search_separators'
,
'['
)
and
value
.
endswith
(
']'
):
default
=
"[',', ',', ' ', '
\n
', ' ']"
)
print
(
'value:
%
s'
%
value
)
separators
=
eval
(
separators
)
# {record1 record2 ...}
for
sep
in
separators
:
if
value
.
startswith
(
'{'
)
and
value
.
endswith
(
'}'
):
content
=
content
.
replace
(
sep
,
'!'
)
content
=
value
[
1
:
-
1
]
.
strip
()
search_terms
=
[
term
.
strip
()
for
term
in
content
.
split
(
'!'
)
if
term
.
strip
()]
if
not
content
:
if
search_terms
:
return
False
,
[]
search_terms
=
[
term
.
strip
()
for
term
in
content
.
split
()
if
term
.
strip
()]
return
bool
(
search_terms
),
search_terms
return
bool
(
search_terms
),
search_terms
# search_terms = [term.strip() for term in content.split() if term.strip()]
# [record1, record2, ...]
return
bool
(
search_terms
),
search_terms
elif
value
.
startswith
(
'['
)
and
value
.
endswith
(
']'
):
# # 直接根据逗号或空格或换行符分割
content
=
value
[
1
:
-
1
]
.
strip
()
# separators = self.env['ir.config_parameter'].sudo().get_param('multi_record_search_separators',
if
not
content
:
# default="[',', ',', ' ', '\n', ' ']")
return
False
,
[]
# separators = eval(separators)
# # 判断value是否包含分隔符
search_terms
=
[
term
.
strip
()
for
term
in
content
.
split
(
','
)
if
term
.
strip
()]
# if any(sep in value for sep in separators) or value.startswith('{') and value.endswith('}') or value.startswith(
return
bool
(
search_terms
),
search_terms
# '[') and value.endswith(']'):
else
:
# print('value:%s' % value)
# # {record1 record2 ...}
for
sep
in
separators
:
# if value.startswith('{') and value.endswith('}'):
value
=
value
.
replace
(
sep
,
'!'
)
# content = value[1:-1].strip()
search_terms
=
[
term
.
strip
()
for
term
in
value
.
split
(
'!'
)
if
term
.
strip
()]
# if not content:
if
search_terms
:
# return False, []
return
bool
(
search_terms
),
search_terms
#
# search_terms = [term.strip() for term in content.split() if term.strip()]
# return bool(search_terms), search_terms
#
# # [record1, record2, ...]
# elif value.startswith('[') and value.endswith(']'):
# content = value[1:-1].strip()
# if not content:
# return False, []
#
# search_terms = [term.strip() for term in content.split(',') if term.strip()]
# return bool(search_terms), search_terms
# else:
#
# for sep in separators:
# value = value.replace(sep, '!')
# search_terms = [term.strip() for term in value.split('!') if term.strip()]
# if search_terms:
# return bool(search_terms), search_terms
return
False
,
[]
return
False
,
[]
@api.model
@api.model
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论