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
Matevz Golob
erp5
Commits
119ee4a3
Commit
119ee4a3
authored
Aug 05, 2013
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove another way of solving divergences
parent
5bc49754
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1 addition
and
219 deletions
+1
-219
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Delivery_acceptDecision.xml
...teItem/portal_skins/erp5_base/Delivery_acceptDecision.xml
+0
-72
bt5/erp5_base/bt/revision
bt5/erp5_base/bt/revision
+1
-1
product/ERP5/Document/SimulatedDeliveryBuilder.py
product/ERP5/Document/SimulatedDeliveryBuilder.py
+0
-146
No files found.
bt5/erp5_base/SkinTemplateItem/portal_skins/erp5_base/Delivery_acceptDecision.xml
deleted
100644 → 0
View file @
5bc49754
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
delivery = context\n
\n
# By default, we use \'CopyAndPropagate\' to accept decision.\n
delivery.portal_simulation.solveDelivery(delivery, None,\n
\'CopyAndPropagate\',\n
divergence_list=divergence_list)\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
divergence_list=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Delivery_acceptDecision
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_base/bt/revision
View file @
119ee4a3
1044
\ No newline at end of file
1045
\ No newline at end of file
product/ERP5/Document/SimulatedDeliveryBuilder.py
View file @
119ee4a3
...
...
@@ -189,152 +189,6 @@ class SimulatedDeliveryBuilder(BuilderMixin):
delivery_relative_url
,
divergence_to_adopt_list
=
divergence_to_adopt_list
)
@
UnrestrictedMethod
def
solveDeliveryGroupDivergence
(
self
,
delivery_relative_url
,
property_dict
=
None
):
"""
solve each divergence according to users decision (accept, adopt
or do nothing).
"""
if
property_dict
in
(
None
,
{}):
return
delivery
=
self
.
getPortalObject
().
restrictedTraverse
(
delivery_relative_url
)
for
(
property
,
value
)
in
property_dict
.
iteritems
():
delivery
.
setPropertyList
(
property
,
value
)
# Try to remove existing properties/categories from Movements that
# should exist on Deliveries.
for
movement
in
delivery
.
getMovementList
():
for
prop
in
property_dict
.
keys
():
# XXX The following should be implemented in better way.
if
movement
.
hasProperty
(
prop
):
try
:
# for Property
movement
.
_delProperty
(
prop
)
except
AttributeError
:
# for Category
movement
.
setProperty
(
prop
,
None
)
divergence_to_accept_list
=
[]
for
divergence
in
delivery
.
getDivergenceList
():
if
divergence
.
getProperty
(
'tested_property'
)
not
in
property_dict
.
keys
():
continue
divergence_to_accept_list
.
append
(
divergence
)
self
.
_solveDivergence
(
delivery_relative_url
,
divergence_to_accept_list
=
divergence_to_accept_list
)
def
_solveDivergence
(
self
,
delivery_relative_url
,
# XXX-JPS what is this doing here ?????
divergence_to_accept_list
=
None
,
divergence_to_adopt_list
=
None
,
**
kw
):
"""
solve each divergence according to users decision (accept, adopt
or do nothing).
"""
# We have to get a delivery, else, raise a Error
delivery
=
self
.
getPortalObject
().
restrictedTraverse
(
delivery_relative_url
)
if
divergence_to_accept_list
is
None
:
divergence_to_accept_list
=
[]
if
divergence_to_adopt_list
is
None
:
divergence_to_adopt_list
=
[]
if
not
len
(
divergence_to_accept_list
)
and
\
not
len
(
divergence_to_adopt_list
):
return
divergence_list
=
delivery
.
getDivergenceList
()
# First, we update simulation movements according to
# divergence_to_accept_list.
if
len
(
divergence_to_accept_list
):
solver_script
=
delivery
.
_getTypeBasedMethod
(
'acceptDecision'
,
'Delivery_acceptDecision'
)
solver_script
(
divergence_to_accept_list
)
# Then, we update delivery/line/cell from simulation movements
# according to divergence_to_adopt_list.
if
not
len
(
divergence_to_adopt_list
):
return
# Select
movement_type_list
=
(
self
.
getDeliveryLinePortalType
(),
self
.
getDeliveryCellPortalType
())
movement_list
=
delivery
.
getMovementList
(
portal_type
=
movement_type_list
)
simulation_movement_list
=
[]
for
movement
in
movement_list
:
movement
.
edit
(
quantity
=
0
)
for
simulation_movement
in
movement
.
getDeliveryRelatedValueList
(
portal_type
=
"Simulation Movement"
):
simulation_movement_list
.
append
(
simulation_movement
)
# Collect
root_group_node
=
self
.
collectMovement
(
simulation_movement_list
)
# Build
portal
=
self
.
getPortalObject
()
delivery_module
=
getattr
(
portal
,
self
.
getDeliveryModule
())
delivery_to_update_list
=
[
delivery
]
self
.
_resetUpdated
()
delivery_list
=
self
.
_processDeliveryGroup
(
delivery_module
,
root_group_node
,
self
.
getDeliveryMovementGroupList
(),
delivery_to_update_list
=
delivery_to_update_list
,
divergence_list
=
divergence_to_adopt_list
,
force_update
=
1
)
# Then, we should re-apply quantity divergence according to 'Do
# nothing' quanity divergence list because all quantity are already
# calculated in adopt prevision phase.
quantity_dict
=
{}
for
divergence
in
divergence_list
:
if
divergence
.
getProperty
(
'divergence_scope'
)
!=
'quantity'
or
\
divergence
in
divergence_to_accept_list
or
\
divergence
in
divergence_to_adopt_list
:
continue
s_m
=
divergence
.
getProperty
(
'simulation_movement'
)
delivery_movement
=
s_m
.
getDeliveryValue
()
quantity_gap
=
divergence
.
getProperty
(
'decision_value'
)
-
\
divergence
.
getProperty
(
'prevision_value'
)
delivery_movement
.
setQuantity
(
delivery_movement
.
getQuantity
()
+
\
quantity_gap
)
quantity_dict
[
s_m
]
=
\
divergence
.
getProperty
(
'decision_value'
)
# Finally, recalculate delivery_ratio
#
# Here, created/updated movements are not indexed yet. So we try to
# gather delivery relations from simulation movements.
delivery_dict
=
{}
for
s_m
in
simulation_movement_list
:
delivery_path
=
s_m
.
getDelivery
()
delivery_dict
[
delivery_path
]
=
\
delivery_dict
.
get
(
delivery_path
,
[])
+
\
[
s_m
]
for
s_m_list_per_movement
in
delivery_dict
.
values
():
total_quantity
=
sum
([
quantity_dict
.
get
(
s_m
,
s_m
.
getMappedProperty
(
'quantity'
))
\
for
s_m
in
s_m_list_per_movement
])
if
total_quantity
!=
0.0
:
for
s_m
in
s_m_list_per_movement
:
delivery_ratio
=
quantity_dict
.
get
(
s_m
,
s_m
.
getMappedProperty
(
'quantity'
))
\
/
total_quantity
s_m
.
edit
(
delivery_ratio
=
delivery_ratio
)
else
:
for
s_m
in
s_m_list_per_movement
:
delivery_ratio
=
1.0
/
len
(
s_m_list_per_movement
)
s_m
.
edit
(
delivery_ratio
=
delivery_ratio
)
# Call afterscript if new deliveries are created
new_delivery_list
=
[
x
for
x
in
delivery_list
if
x
!=
delivery
]
self
.
callAfterBuildingScript
(
new_delivery_list
,
simulation_movement_list
)
return
delivery_list
solveDivergence
=
UnrestrictedMethod
(
_solveDivergence
)
def
_createDelivery
(
self
,
delivery_module
,
movement_list
,
activate_kw
):
"""
Refer to the docstring in GeneratedDeliveryBuilder.
...
...
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