Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Coopdevs OCB mirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Coopdevs
Odoo
Coopdevs OCB mirror
Commits
daf8bdf6
Commit
daf8bdf6
authored
10 years ago
by
Fabien Meghazi
Browse files
Options
Downloads
Patches
Plain Diff
[ADD] support for multiple value query args in keep_query()
parent
381507e6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openerp/addons/base/ir/ir_ui_view.py
+20
-9
20 additions, 9 deletions
openerp/addons/base/ir/ir_ui_view.py
with
20 additions
and
9 deletions
openerp/addons/base/ir/ir_ui_view.py
+
20
−
9
View file @
daf8bdf6
...
...
@@ -49,15 +49,26 @@ _logger = logging.getLogger(__name__)
MOVABLE_BRANDING
=
[
'
data-oe-model
'
,
'
data-oe-id
'
,
'
data-oe-field
'
,
'
data-oe-xpath
'
]
def
keep_query
(
*
args
,
**
kw
):
if
not
args
and
not
kw
:
args
=
(
'
*
'
,)
params
=
kw
.
copy
()
query_params
=
frozenset
(
werkzeug
.
url_decode
(
request
.
httprequest
.
query_string
).
keys
())
for
keep_param
in
args
:
for
param
in
fnmatch
.
filter
(
query_params
,
keep_param
):
if
param
not
in
params
and
param
in
request
.
params
:
params
[
param
]
=
request
.
params
[
param
]
def
keep_query
(
*
keep_params
,
**
additional_params
):
"""
Generate a query string keeping the current request querystring
'
s parameters specified
in ``keep_params`` and also adds the parameters specified in ``additional_params``.
Multiple values query string params will be merged into a single one with comma seperated
values.
The ``keep_params`` arguments can use wildcards too, eg:
keep_query(
'
search
'
,
'
shop_*
'
, page=4)
"""
if
not
keep_params
and
not
additional_params
:
keep_params
=
(
'
*
'
,)
params
=
additional_params
.
copy
()
qs_keys
=
request
.
httprequest
.
args
.
keys
()
for
keep_param
in
keep_params
:
for
param
in
fnmatch
.
filter
(
qs_keys
,
keep_param
):
if
param
not
in
additional_params
and
param
in
qs_keys
:
params
[
param
]
=
'
,
'
.
join
(
request
.
httprequest
.
args
.
getlist
(
param
))
return
werkzeug
.
urls
.
url_encode
(
params
)
class
view_custom
(
osv
.
osv
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment