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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Papa Tamsir Kane
erp5
Commits
d62dacd7
Commit
d62dacd7
authored
Dec 16, 2011
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
_migrateSimulationTree: automatically delete orphan Simulation Movements
parent
33f1ef9c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
22 deletions
+27
-22
product/ERP5/Document/AppliedRule.py
product/ERP5/Document/AppliedRule.py
+27
-22
No files found.
product/ERP5/Document/AppliedRule.py
View file @
d62dacd7
...
@@ -322,6 +322,7 @@ class AppliedRule(XMLObject, ExplainableMixin):
...
@@ -322,6 +322,7 @@ class AppliedRule(XMLObject, ExplainableMixin):
if
history_item
[
'simulation_state'
]
in
draft_state_list
:
if
history_item
[
'simulation_state'
]
in
draft_state_list
:
continue
continue
# Delivery is/was not is draft state
# Delivery is/was not is draft state
resolveCategory
=
portal
.
portal_categories
.
resolveCategory
order_dict
=
{}
order_dict
=
{}
old_dict
=
{}
old_dict
=
{}
# Caller may want to drop duplicate SM, like a unbuilt SM if there's
# Caller may want to drop duplicate SM, like a unbuilt SM if there's
...
@@ -330,31 +331,35 @@ class AppliedRule(XMLObject, ExplainableMixin):
...
@@ -330,31 +331,35 @@ class AppliedRule(XMLObject, ExplainableMixin):
# remember them and returns None for duplicates.
# remember them and returns None for duplicates.
sort_sm
=
lambda
x
:
(
not
x
.
getDelivery
(),
not
x
.
getQuantity
(),
x
.
getId
())
sort_sm
=
lambda
x
:
(
not
x
.
getDelivery
(),
not
x
.
getQuantity
(),
x
.
getId
())
for
sm
in
sorted
(
self
.
objectValues
(),
key
=
sort_sm
):
for
sm
in
sorted
(
self
.
objectValues
(),
key
=
sort_sm
):
sm_dict
=
old_dict
.
setdefault
(
sm
.
getOrder
()
or
sm
.
getDelivery
(),
{})
line
=
sm
.
getOrder
()
or
sm
.
getDelivery
()
recurse_list
=
deque
(({
get_matching_key
(
sm
):
(
sm
,)},))
# Check SM is not orphan, which happened with old buggy trees.
while
recurse_list
:
if
resolveCategory
(
line
)
is
not
None
:
for
k
,
x
in
recurse_list
.
popleft
().
iteritems
():
sm_dict
=
old_dict
.
setdefault
(
line
,
{})
if
not
k
:
recurse_list
=
deque
(({
get_matching_key
(
sm
):
(
sm
,)},))
continue
while
recurse_list
:
if
len
(
x
)
>
1
:
for
k
,
x
in
recurse_list
.
popleft
().
iteritems
():
x
=
[
x
for
x
in
x
if
x
.
getDelivery
()
or
x
.
getQuantity
()]
if
not
k
:
continue
if
len
(
x
)
>
1
:
if
len
(
x
)
>
1
:
x
.
sort
(
key
=
sort_sm
)
x
=
[
x
for
x
in
x
if
x
.
getDelivery
()
or
x
.
getQuantity
()]
sm_dict
.
setdefault
(
k
,
[]).
extend
(
x
)
for
x
in
x
:
r
=
{}
for
x
in
x
.
objectValues
():
sm_list
=
x
.
getMovementList
()
if
sm_list
:
r
.
setdefault
(
x
.
getSpecialise
(),
[]).
append
(
sm_list
)
for
x
in
r
.
values
():
if
len
(
x
)
>
1
:
if
len
(
x
)
>
1
:
x
=
[
y
for
y
in
x
if
any
(
z
.
getDelivery
()
for
z
in
y
)]
or
x
[:
1
]
x
.
sort
(
key
=
sort_sm
)
x
,
=
x
sm_dict
.
setdefault
(
k
,
[]).
extend
(
x
)
for
x
in
x
:
r
=
{}
r
=
{}
for
x
in
x
:
for
x
in
x
.
objectValues
():
r
.
setdefault
(
get_matching_key
(
x
),
[]).
append
(
x
)
sm_list
=
x
.
getMovementList
()
recurse_list
.
append
(
r
)
if
sm_list
:
r
.
setdefault
(
x
.
getSpecialise
(),
[]).
append
(
sm_list
)
for
x
in
r
.
values
():
if
len
(
x
)
>
1
:
x
=
[
y
for
y
in
x
if
any
(
z
.
getDelivery
()
for
z
in
y
)]
or
x
[:
1
]
x
,
=
x
r
=
{}
for
x
in
x
:
r
.
setdefault
(
get_matching_key
(
x
),
[]).
append
(
x
)
recurse_list
.
append
(
r
)
self
.
_delObject
(
sm
.
getId
())
self
.
_delObject
(
sm
.
getId
())
# Here Delivery.isSimulated works because Movement.isSimulated
# Here Delivery.isSimulated works because Movement.isSimulated
# does not see the simulated movements we've just deleted.
# does not see the simulated movements we've just deleted.
...
...
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