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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Klaus Wölfel
erp5
Commits
eb566e3e
Commit
eb566e3e
authored
May 18, 2020
by
Cédric Le Ninivin
Committed by
Klaus Wölfel
Apr 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_base: BuilderMixin add function to get Mergeable Delivery List List
parent
258577ad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
bt5/erp5_base/MixinTemplateItem/portal_components/mixin.erp5.BuilderMixin.py
...TemplateItem/portal_components/mixin.erp5.BuilderMixin.py
+41
-0
No files found.
bt5/erp5_base/MixinTemplateItem/portal_components/mixin.erp5.BuilderMixin.py
View file @
eb566e3e
...
...
@@ -151,6 +151,47 @@ class BuilderMixin(XMLObject, Amount, Predicate):
self
.
callAfterBuildingScript
(
delivery_list
,
movement_list
,
**
kw
)
return
delivery_list
security
.
declarePublic
(
'getMergeableDeliveryListList'
)
def
getMergeableDeliveryListList
(
self
,
movement_list
=
None
):
"""
Return a List Of Delivery Lists that can be merged together
"""
delivery_movement_group_list
=
self
.
getDeliveryMovementGroupList
()
if
delivery_movement_group_list
:
delivery_select_method_id
=
self
.
getDeliverySelectMethodId
()
if
delivery_select_method_id
:
delivery_to_update_list
=
getattr
(
self
,
delivery_select_method_id
)
\
(
movement_list
=
movement_list
)
if
delivery_to_update_list
:
delivery_to_update_list
=
[
sql_delivery
.
getObject
()
for
sql_delivery
in
delivery_to_update_list
]
grouped_delivery_dict
=
self
.
groupedDeliveryDict
(
delivery_to_update_list
,
delivery_movement_group_list
)
mergeable_delivery_list_list
=
[]
for
mergeable_delivery_list
in
grouped_delivery_dict
.
itervalues
():
if
len
(
mergeable_delivery_list
)
>
1
:
mergeable_delivery_list_list
.
append
(
mergeable_delivery_list
)
return
mergeable_delivery_list_list
return
[]
def
groupedDeliveryDict
(
self
,
delivery_to_update_list
,
delivery_movement_group_list
):
"""
Group Deliveries according to their properties in the delivery_movement_group_list
"""
delivery_dict
=
{}
for
delivery
in
delivery_to_update_list
:
property_dict_list
=
[]
for
movement_group
in
delivery_movement_group_list
:
property_dict_list
.
append
(
movement_group
.
_getPropertyDict
(
delivery
))
property_tuple_list
=
[]
for
property_dict
in
property_dict_list
:
property_tuple_list
+=
[
(
x
,
y
)
if
not
isinstance
(
y
,
list
)
else
(
x
,
tuple
(
sorted
(
y
)))
for
x
,
y
in
property_dict
.
iteritems
()
]
delivery_property_identifier
=
tuple
(
sorted
(
property_tuple_list
))
delivery_dict
.
setdefault
(
delivery_property_identifier
,
[]).
append
(
delivery
)
return
delivery_dict
def
getRelatedBusinessLinkValueList
(
self
):
return
self
.
getDeliveryBuilderRelatedValueList
(
portal_type
=
'Business Link'
)
...
...
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