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
alecs_myu
erp5
Commits
8a551780
Commit
8a551780
authored
May 03, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Indent parts of 2 solver methods before actually edit them
parent
8d213f3c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
74 deletions
+76
-74
product/ERP5/Document/AcceptSolver.py
product/ERP5/Document/AcceptSolver.py
+30
-29
product/ERP5/Document/TradeModelSolver.py
product/ERP5/Document/TradeModelSolver.py
+46
-45
No files found.
product/ERP5/Document/AcceptSolver.py
View file @
8a551780
...
...
@@ -68,35 +68,36 @@ class AcceptSolver(SolverMixin, ConfigurableMixin, XMLObject):
if
solved_property_list
is
None
:
portal_type
=
self
.
getPortalObject
().
portal_types
.
getTypeInfo
(
self
)
solved_property_list
=
portal_type
.
getTestedPropertyList
()
for
simulation_movement
in
self
.
getDeliveryValueList
():
if
activate_kw
is
not
None
:
simulation_movement
.
setDefaultActivateParameterDict
(
activate_kw
)
movement
=
simulation_movement
.
getDeliveryValue
()
value_dict
=
{}
base_category_set
=
set
(
movement
.
getBaseCategoryList
())
for
solved_property
in
solved_property_list
:
if
solved_property
in
base_category_set
:
# XXX-Leo: Hack, the accept solver was 'accepting' only the first
# value of a category and discarding all others by using only
# movement.getProperty().
# A proper fix would perhaps be to use .getPropertyList() always
# (and use .setPropertyList()), but we need to do property
# mapping on simulation and there is no
# simulation_movement.setMappedPropertyList().
new_value
=
movement
.
getPropertyList
(
solved_property
)
else
:
new_value
=
movement
.
getProperty
(
solved_property
)
# XXX hard coded
if
solved_property
==
'quantity'
:
new_quantity
=
new_value
*
simulation_movement
.
getDeliveryRatio
()
value_dict
.
update
({
'quantity'
:
new_quantity
})
else
:
value_dict
.
update
({
solved_property
:
new_value
})
for
property_id
,
value
in
value_dict
.
iteritems
():
if
not
simulation_movement
.
isPropertyRecorded
(
property_id
):
simulation_movement
.
recordProperty
(
property_id
)
simulation_movement
.
setMappedProperty
(
property_id
,
value
)
simulation_movement
.
expand
(
activate_kw
=
activate_kw
)
if
1
:
for
simulation_movement
in
self
.
getDeliveryValueList
():
if
activate_kw
is
not
None
:
simulation_movement
.
setDefaultActivateParameterDict
(
activate_kw
)
movement
=
simulation_movement
.
getDeliveryValue
()
value_dict
=
{}
base_category_set
=
set
(
movement
.
getBaseCategoryList
())
for
solved_property
in
solved_property_list
:
if
solved_property
in
base_category_set
:
# XXX-Leo: Hack, the accept solver was 'accepting' only the first
# value of a category and discarding all others by using only
# movement.getProperty().
# A proper fix would perhaps be to use .getPropertyList() always
# (and use .setPropertyList()), but we need to do property
# mapping on simulation and there is no
# simulation_movement.setMappedPropertyList().
new_value
=
movement
.
getPropertyList
(
solved_property
)
else
:
new_value
=
movement
.
getProperty
(
solved_property
)
# XXX hard coded
if
solved_property
==
'quantity'
:
new_quantity
=
new_value
*
simulation_movement
.
getDeliveryRatio
()
value_dict
.
update
({
'quantity'
:
new_quantity
})
else
:
value_dict
.
update
({
solved_property
:
new_value
})
for
property_id
,
value
in
value_dict
.
iteritems
():
if
not
simulation_movement
.
isPropertyRecorded
(
property_id
):
simulation_movement
.
recordProperty
(
property_id
)
simulation_movement
.
setMappedProperty
(
property_id
,
value
)
simulation_movement
.
expand
(
activate_kw
=
activate_kw
)
# Finish solving
if
self
.
getPortalObject
().
portal_workflow
.
isTransitionPossible
(
self
,
'succeed'
):
...
...
product/ERP5/Document/TradeModelSolver.py
View file @
8a551780
...
...
@@ -92,55 +92,56 @@ class TradeModelSolver(AcceptSolver):
if
applied_rule
.
getSpecialiseReference
()
==
'default_trade_model_rule'
:
trade_model_related_movement_list
.
append
(
movement
)
# Second, apply changes on invoice lines to simulation movements,
# then expand.
for
movement
,
simulation_movement_list
in
delivery_dict
.
iteritems
():
if
movement
in
trade_model_related_movement_list
:
continue
for
simulation_movement
in
simulation_movement_list
:
if
1
:
# Second, apply changes on invoice lines to simulation movements,
# then expand.
for
movement
,
simulation_movement_list
in
delivery_dict
.
iteritems
():
if
movement
in
trade_model_related_movement_list
:
continue
for
simulation_movement
in
simulation_movement_list
:
if
activate_kw
is
not
None
:
simulation_movement
.
setDefaultActivateParameterDict
(
activate_kw
)
value_dict
=
{}
for
solved_property
in
solved_property_list
:
new_value
=
movement
.
getProperty
(
solved_property
)
if
solved_property
==
'quantity'
:
new_quantity
=
new_value
*
simulation_movement
.
getDeliveryRatio
()
value_dict
.
update
({
'quantity'
:
new_quantity
})
else
:
value_dict
.
update
({
solved_property
:
new_value
})
for
property_id
,
value
in
value_dict
.
iteritems
():
if
not
simulation_movement
.
isPropertyRecorded
(
property_id
):
simulation_movement
.
recordProperty
(
property_id
)
simulation_movement
.
setMappedProperty
(
property_id
,
value
)
simulation_movement
.
expand
(
activate_kw
=
activate_kw
)
# Third, adopt changes on trade model related lines.
# XXX non-linear case is not yet supported.
for
movement
in
trade_model_related_movement_list
:
if
activate_kw
is
not
None
:
simulation_movement
.
setDefaultActivateParameterDict
(
activate_kw
)
value_dict
=
{}
movement
.
setDefaultActivateParameterDict
(
activate_kw
)
for
solved_property
in
solved_property_list
:
new_value
=
movement
.
getProperty
(
solved_property
)
if
solved_property
==
'quantity'
:
new_quantity
=
new_value
*
simulation_movement
.
getDeliveryRatio
()
value_dict
.
update
({
'quantity'
:
new_quantity
})
simulation_movement_list
=
movement
.
getDeliveryRelatedValueList
()
total_quantity
=
sum
(
[
x
.
getQuantity
()
for
x
in
simulation_movement_list
])
movement
.
setQuantity
(
total_quantity
)
for
simulation_movement
in
simulation_movement_list
:
quantity
=
simulation_movement
.
getQuantity
()
if
total_quantity
!=
0.0
:
delivery_ratio
=
quantity
/
total_quantity
else
:
delivery_ratio
=
1.0
/
len
(
simulation_movement_list
)
delivery_error
=
total_quantity
*
delivery_ratio
-
quantity
simulation_movement
.
edit
(
delivery_ratio
=
delivery_ratio
,
delivery_error
=
delivery_error
,
activate_kw
=
activate_kw
)
else
:
value_dict
.
update
({
solved_property
:
new_value
})
for
property_id
,
value
in
value_dict
.
iteritems
():
if
not
simulation_movement
.
isPropertyRecorded
(
property_id
):
simulation_movement
.
recordProperty
(
property_id
)
simulation_movement
.
setMappedProperty
(
property_id
,
value
)
simulation_movement
.
expand
(
activate_kw
=
activate_kw
)
# Third, adopt changes on trade model related lines.
# XXX non-linear case is not yet supported.
for
movement
in
trade_model_related_movement_list
:
if
activate_kw
is
not
None
:
movement
.
setDefaultActivateParameterDict
(
activate_kw
)
for
solved_property
in
solved_property_list
:
if
solved_property
==
'quantity'
:
simulation_movement_list
=
movement
.
getDeliveryRelatedValueList
()
total_quantity
=
sum
(
[
x
.
getQuantity
()
for
x
in
simulation_movement_list
])
movement
.
setQuantity
(
total_quantity
)
for
simulation_movement
in
simulation_movement_list
:
quantity
=
simulation_movement
.
getQuantity
()
if
total_quantity
!=
0.0
:
delivery_ratio
=
quantity
/
total_quantity
else
:
delivery_ratio
=
1.0
/
len
(
simulation_movement_list
)
delivery_error
=
total_quantity
*
delivery_ratio
-
quantity
simulation_movement
.
edit
(
delivery_ratio
=
delivery_ratio
,
delivery_error
=
delivery_error
,
activate_kw
=
activate_kw
)
else
:
# XXX TODO we need to support multiple values for categories or
# list type property.
simulation_movement
=
movement
.
getDeliveryRelatedValue
()
movement
.
setProperty
(
solved_property
,
simulation_movement
.
getProperty
(
solved_property
))
# XXX TODO we need to support multiple values for categories or
# list type property.
simulation_movement
=
movement
.
getDeliveryRelatedValue
()
movement
.
setProperty
(
solved_property
,
simulation_movement
.
getProperty
(
solved_property
))
# Finish solving
if
self
.
getPortalObject
().
portal_workflow
.
isTransitionPossible
(
...
...
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