Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.core
Commits
8ddc1e98
Commit
8ddc1e98
authored
Mar 06, 2025
by
Romain Courteaud
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: speed up Sale Supply retrieval by explicitely filtering with SQL
parent
f79a9ea8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
12 deletions
+11
-12
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Movement_getPriceCalculationOperandDict.py
...pos_accounting/Movement_getPriceCalculationOperandDict.py
+11
-12
No files found.
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/Movement_getPriceCalculationOperandDict.py
View file @
8ddc1e98
...
...
@@ -14,7 +14,7 @@ def sort_key_method(e):
minus
=
0
return
0
-
1
*
int
(
parent
.
hasDestination
())
-
minus
def
filter_method
(
currency
,
destination_project
,
group
):
def
filter_method
(
currency
,
destination_project
):
def
filter_by_source_function_and_group
(
l
):
ret
=
[]
for
i
in
l
:
...
...
@@ -43,22 +43,21 @@ def filter_method(currency, destination_project, group):
return
ret
return
filter_by_source_function_and_group
source
=
context
.
getSourceValue
()
if
source
is
None
:
group
=
None
else
:
group
=
source
.
getGroup
()
kw
[
'filter_method'
]
=
filter_method
(
context
.
getPriceCurrency
(),
context
.
getDestinationProject
(),
group
)
kw
[
'filter_method'
]
=
filter_method
(
context
.
getPriceCurrency
(),
context
.
getDestinationProject
())
kw
[
'sort_key_method'
]
=
sort_key_method
resource
=
context
.
getResourceValue
()
price_currency
=
context
.
getPriceCurrencyValue
()
if
resource
is
not
None
:
product_line
=
resource
.
getProductLine
()
if
product_line
:
kw
[
'categories'
]
=
kw
.
get
(
'categories'
,
[])
+
[
'product_line/%s'
%
product_line
]
if
(
resource
is
not
None
)
and
(
price_currency
is
not
None
):
# Explicitely filter with SQL, to reduce the number of predicates to check
# Currently, only Sales are handled
# See also SaleSupplyLine_asPredicate
kw
[
'resource__uid'
]
=
resource
.
getUid
()
kw
[
'price_currency__uid'
]
=
price_currency
.
getUid
()
kw
[
'validation_state'
]
=
'validated'
kw
[
'portal_type'
]
=
[
'Sale Supply Line'
,
'Sale Supply Cell'
]
return
resource
.
getPriceCalculationOperandDict
(
default
=
default
,
context
=
context
,
**
kw
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment