Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Sebastien Robin
erp5
Commits
429960e5
Commit
429960e5
authored
Apr 09, 2014
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Amount Generator: make lines sortable with float indices
parent
9623656d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
product/ERP5/mixin/amount_generator.py
product/ERP5/mixin/amount_generator.py
+9
-6
No files found.
product/ERP5/mixin/amount_generator.py
View file @
429960e5
...
...
@@ -205,15 +205,20 @@ class AmountGeneratorMixin:
base_amount_list
=
(
BaseAmountDict
(
*
args
).
__of__
(
amount
)
for
amount
in
amount_list
)
# First define the method that will browse recursively
# the amount generator lines and accumulate applicable values
def
getLineSortKey
(
line
):
int_index
=
line
.
getIntIndex
()
return
(
line
.
getFloatIndex
()
if
int_index
is
None
else
int_index
,
random
.
random
())
def
accumulateAmountList
(
self
):
"""Browse recursively the amount generator lines
and accumulate applicable values
"""
amount_generator_line_list
=
self
.
contentValues
(
portal_type
=
amount_generator_line_type_list
)
# Recursively feed base_amount
if
amount_generator_line_list
:
amount_generator_line_list
.
sort
(
key
=
lambda
x
:
(
x
.
getIntIndex
(),
random
.
random
()))
amount_generator_line_list
.
sort
(
key
=
getLineSortKey
)
for
amount_generator_line
in
amount_generator_line_list
:
accumulateAmountList
(
amount_generator_line
)
return
...
...
@@ -366,8 +371,6 @@ class AmountGeneratorMixin:
delivery_amount
=
base_amount
.
getObject
()
if
not
is_mapped_value
:
self
=
delivery_amount
.
asComposedDocument
(
amount_generator_type_list
)
# Browse recursively the amount generator lines and accumulate
# applicable values - now execute the method
accumulateAmountList
(
self
)
return
result
...
...
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