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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Cédric Le Ninivin
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
Show 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:
...
@@ -205,15 +205,20 @@ class AmountGeneratorMixin:
base_amount_list
=
(
BaseAmountDict
(
*
args
).
__of__
(
amount
)
base_amount_list
=
(
BaseAmountDict
(
*
args
).
__of__
(
amount
)
for
amount
in
amount_list
)
for
amount
in
amount_list
)
# First define the method that will browse recursively
def
getLineSortKey
(
line
):
# the amount generator lines and accumulate applicable values
int_index
=
line
.
getIntIndex
()
return
(
line
.
getFloatIndex
()
if
int_index
is
None
else
int_index
,
random
.
random
())
def
accumulateAmountList
(
self
):
def
accumulateAmountList
(
self
):
"""Browse recursively the amount generator lines
and accumulate applicable values
"""
amount_generator_line_list
=
self
.
contentValues
(
amount_generator_line_list
=
self
.
contentValues
(
portal_type
=
amount_generator_line_type_list
)
portal_type
=
amount_generator_line_type_list
)
# Recursively feed base_amount
# Recursively feed base_amount
if
amount_generator_line_list
:
if
amount_generator_line_list
:
amount_generator_line_list
.
sort
(
key
=
lambda
x
:
(
x
.
getIntIndex
(),
amount_generator_line_list
.
sort
(
key
=
getLineSortKey
)
random
.
random
()))
for
amount_generator_line
in
amount_generator_line_list
:
for
amount_generator_line
in
amount_generator_line_list
:
accumulateAmountList
(
amount_generator_line
)
accumulateAmountList
(
amount_generator_line
)
return
return
...
@@ -366,8 +371,6 @@ class AmountGeneratorMixin:
...
@@ -366,8 +371,6 @@ class AmountGeneratorMixin:
delivery_amount
=
base_amount
.
getObject
()
delivery_amount
=
base_amount
.
getObject
()
if
not
is_mapped_value
:
if
not
is_mapped_value
:
self
=
delivery_amount
.
asComposedDocument
(
amount_generator_type_list
)
self
=
delivery_amount
.
asComposedDocument
(
amount_generator_type_list
)
# Browse recursively the amount generator lines and accumulate
# applicable values - now execute the method
accumulateAmountList
(
self
)
accumulateAmountList
(
self
)
return
result
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