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
Ekaterina
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):
...
@@ -68,35 +68,36 @@ class AcceptSolver(SolverMixin, ConfigurableMixin, XMLObject):
if
solved_property_list
is
None
:
if
solved_property_list
is
None
:
portal_type
=
self
.
getPortalObject
().
portal_types
.
getTypeInfo
(
self
)
portal_type
=
self
.
getPortalObject
().
portal_types
.
getTypeInfo
(
self
)
solved_property_list
=
portal_type
.
getTestedPropertyList
()
solved_property_list
=
portal_type
.
getTestedPropertyList
()
for
simulation_movement
in
self
.
getDeliveryValueList
():
if
1
:
if
activate_kw
is
not
None
:
for
simulation_movement
in
self
.
getDeliveryValueList
():
simulation_movement
.
setDefaultActivateParameterDict
(
activate_kw
)
if
activate_kw
is
not
None
:
movement
=
simulation_movement
.
getDeliveryValue
()
simulation_movement
.
setDefaultActivateParameterDict
(
activate_kw
)
value_dict
=
{}
movement
=
simulation_movement
.
getDeliveryValue
()
base_category_set
=
set
(
movement
.
getBaseCategoryList
())
value_dict
=
{}
for
solved_property
in
solved_property_list
:
base_category_set
=
set
(
movement
.
getBaseCategoryList
())
if
solved_property
in
base_category_set
:
for
solved_property
in
solved_property_list
:
# XXX-Leo: Hack, the accept solver was 'accepting' only the first
if
solved_property
in
base_category_set
:
# value of a category and discarding all others by using only
# XXX-Leo: Hack, the accept solver was 'accepting' only the first
# movement.getProperty().
# value of a category and discarding all others by using only
# A proper fix would perhaps be to use .getPropertyList() always
# movement.getProperty().
# (and use .setPropertyList()), but we need to do property
# A proper fix would perhaps be to use .getPropertyList() always
# mapping on simulation and there is no
# (and use .setPropertyList()), but we need to do property
# simulation_movement.setMappedPropertyList().
# mapping on simulation and there is no
new_value
=
movement
.
getPropertyList
(
solved_property
)
# simulation_movement.setMappedPropertyList().
else
:
new_value
=
movement
.
getPropertyList
(
solved_property
)
new_value
=
movement
.
getProperty
(
solved_property
)
else
:
# XXX hard coded
new_value
=
movement
.
getProperty
(
solved_property
)
if
solved_property
==
'quantity'
:
# XXX hard coded
new_quantity
=
new_value
*
simulation_movement
.
getDeliveryRatio
()
if
solved_property
==
'quantity'
:
value_dict
.
update
({
'quantity'
:
new_quantity
})
new_quantity
=
new_value
*
simulation_movement
.
getDeliveryRatio
()
else
:
value_dict
.
update
({
'quantity'
:
new_quantity
})
value_dict
.
update
({
solved_property
:
new_value
})
else
:
for
property_id
,
value
in
value_dict
.
iteritems
():
value_dict
.
update
({
solved_property
:
new_value
})
if
not
simulation_movement
.
isPropertyRecorded
(
property_id
):
for
property_id
,
value
in
value_dict
.
iteritems
():
simulation_movement
.
recordProperty
(
property_id
)
if
not
simulation_movement
.
isPropertyRecorded
(
property_id
):
simulation_movement
.
setMappedProperty
(
property_id
,
value
)
simulation_movement
.
recordProperty
(
property_id
)
simulation_movement
.
expand
(
activate_kw
=
activate_kw
)
simulation_movement
.
setMappedProperty
(
property_id
,
value
)
simulation_movement
.
expand
(
activate_kw
=
activate_kw
)
# Finish solving
# Finish solving
if
self
.
getPortalObject
().
portal_workflow
.
isTransitionPossible
(
if
self
.
getPortalObject
().
portal_workflow
.
isTransitionPossible
(
self
,
'succeed'
):
self
,
'succeed'
):
...
...
product/ERP5/Document/TradeModelSolver.py
View file @
8a551780
...
@@ -92,55 +92,56 @@ class TradeModelSolver(AcceptSolver):
...
@@ -92,55 +92,56 @@ class TradeModelSolver(AcceptSolver):
if
applied_rule
.
getSpecialiseReference
()
==
'default_trade_model_rule'
:
if
applied_rule
.
getSpecialiseReference
()
==
'default_trade_model_rule'
:
trade_model_related_movement_list
.
append
(
movement
)
trade_model_related_movement_list
.
append
(
movement
)
# Second, apply changes on invoice lines to simulation movements,
if
1
:
# then expand.
# Second, apply changes on invoice lines to simulation movements,
for
movement
,
simulation_movement_list
in
delivery_dict
.
iteritems
():
# then expand.
if
movement
in
trade_model_related_movement_list
:
for
movement
,
simulation_movement_list
in
delivery_dict
.
iteritems
():
continue
if
movement
in
trade_model_related_movement_list
:
for
simulation_movement
in
simulation_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
:
if
activate_kw
is
not
None
:
simulation_movement
.
setDefaultActivateParameterDict
(
activate_kw
)
movement
.
setDefaultActivateParameterDict
(
activate_kw
)
value_dict
=
{}
for
solved_property
in
solved_property_list
:
for
solved_property
in
solved_property_list
:
new_value
=
movement
.
getProperty
(
solved_property
)
if
solved_property
==
'quantity'
:
if
solved_property
==
'quantity'
:
new_quantity
=
new_value
*
simulation_movement
.
getDeliveryRatio
()
simulation_movement_list
=
movement
.
getDeliveryRelatedValueList
()
value_dict
.
update
({
'quantity'
:
new_quantity
})
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
:
else
:
value_dict
.
update
({
solved_property
:
new_value
})
# XXX TODO we need to support multiple values for categories or
for
property_id
,
value
in
value_dict
.
iteritems
():
# list type property.
if
not
simulation_movement
.
isPropertyRecorded
(
property_id
):
simulation_movement
=
movement
.
getDeliveryRelatedValue
()
simulation_movement
.
recordProperty
(
property_id
)
movement
.
setProperty
(
solved_property
,
simulation_movement
.
setMappedProperty
(
property_id
,
value
)
simulation_movement
.
getProperty
(
solved_property
))
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
))
# Finish solving
# Finish solving
if
self
.
getPortalObject
().
portal_workflow
.
isTransitionPossible
(
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