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
Carlos Ramos Carreño
erp5
Commits
19edd898
Commit
19edd898
authored
Sep 21, 2018
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stock optimisation: do not consider a single node for cancelling auto planned movements
parent
7587f0bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
2 deletions
+46
-2
product/ERP5/mixin/builder.py
product/ERP5/mixin/builder.py
+5
-1
product/ERP5/tests/testOrderBuilder.py
product/ERP5/tests/testOrderBuilder.py
+41
-1
No files found.
product/ERP5/mixin/builder.py
View file @
19edd898
...
@@ -250,9 +250,13 @@ class BuilderMixin(XMLObject, Amount, Predicate):
...
@@ -250,9 +250,13 @@ class BuilderMixin(XMLObject, Amount, Predicate):
# previous optimisations are obsolete
# previous optimisations are obsolete
elif
round
(
inventory_item
.
inventory
,
5
)
>
min_stock
:
elif
round
(
inventory_item
.
inventory
,
5
)
>
min_stock
:
delta
=
inventory_item
.
inventory
-
min_stock
delta
=
inventory_item
.
inventory
-
min_stock
node_uid
=
inventory_item
.
node_uid
# if node_uid is provided, we have to look at all provided nodes
if
kw
.
has_key
(
'node_uid'
):
node_uid
=
kw
[
'node_uid'
]
optimized_inventory_list
=
portal
.
portal_simulation
.
getInventoryList
(
optimized_inventory_list
=
portal
.
portal_simulation
.
getInventoryList
(
resource_uid
=
inventory_item
.
resource_uid
,
resource_uid
=
inventory_item
.
resource_uid
,
node_uid
=
inventory_item
.
node_uid
,
node_uid
=
node_uid
,
variation_text
=
inventory_item
.
variation_text
,
variation_text
=
inventory_item
.
variation_text
,
simulation_state
=
"auto_planned"
,
simulation_state
=
"auto_planned"
,
sort_on
=
[(
"date"
,
"descending"
)],
sort_on
=
[(
"date"
,
"descending"
)],
...
...
product/ERP5/tests/testOrderBuilder.py
View file @
19edd898
...
@@ -536,4 +536,44 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase):
...
@@ -536,4 +536,44 @@ class TestOrderBuilder(TestOrderBuilderMixin, ERP5TypeTestCase):
make this method now works fine with inventories and with variation
make this method now works fine with inventories and with variation
"""
"""
self
.
checkGenerateMovementListForStockOptimisationWithInventories
(
self
.
checkGenerateMovementListForStockOptimisationWithInventories
(
variation_category_list
=
[
'colour/green'
,
'size/big'
])
variation_category_list
=
[
'colour/green'
,
'size/big'
])
\ No newline at end of file
def
test_06_checkUpdateOfAutoPlannedMovement
(
self
):
"""
So we use order builder to create auto planned movements. generateMovementListForStockOptimisation
should be able to allows us to reduce quantities of auto planned movements when needed
"""
# changing type_list here is somehow dirty, decision would need to be taken if this is acceptable
# for everyone to have auto_planned as part of future inventory
self
.
portal
.
portal_workflow
.
order_workflow
.
states
[
'auto_planned'
].
type_list
=
(
'planned_order'
,
'future_inventory'
)
self
.
portal
.
portal_caches
.
clearAllCache
()
self
.
assertTrue
(
'auto_planned'
in
self
.
portal
.
getPortalFutureInventoryStateList
())
# end of patch
resource
=
self
.
resource
self
.
createOrderBuilder
()
self
.
fillOrderBuilder
()
fixed_date
=
DateTime
(
'2018/09/21'
)
self
.
pinDateTime
(
fixed_date
)
resource_url
=
self
.
resource
.
getRelativeUrl
()
node_uid_list
=
[
self
.
node_1
.
getUid
(),
self
.
node_2
.
getUid
()]
def
checkStockOptimisationForTwoNodes
(
expected_result
):
self
.
checkOrderBuilderStockOptimisationResult
(
expected_result
,
node_uid
=
node_uid_list
,
group_by_node
=
0
)
checkStockOptimisationForTwoNodes
([])
self
.
_makeMovement
(
quantity
=-
5
,
destination_value
=
self
.
node_1
,
simulation_state
=
'confirmed'
,
start_date
=
DateTime
(
'2018/09/21'
))
checkStockOptimisationForTwoNodes
([(
resource_url
,
''
,
5.0
,
'2018/09/21'
,
'2018/09/21'
)])
auto_planned_one
=
self
.
_makeMovement
(
quantity
=
3
,
destination_value
=
self
.
node_2
,
simulation_state
=
'auto_planned'
,
start_date
=
DateTime
(
'2018/09/18'
))
checkStockOptimisationForTwoNodes
([(
resource_url
,
''
,
2.0
,
'2018/09/21'
,
'2018/09/21'
)])
auto_planned_two
=
self
.
_makeMovement
(
quantity
=
2
,
destination_value
=
self
.
node_1
,
simulation_state
=
'auto_planned'
,
start_date
=
DateTime
(
'2018/09/19'
))
checkStockOptimisationForTwoNodes
([])
# But if we more stock than expected, auto planned movements should be reduced
self
.
_makeMovement
(
quantity
=
1
,
destination_value
=
self
.
node_1
,
simulation_state
=
'confirmed'
,
start_date
=
DateTime
(
'2018/09/29'
))
checkStockOptimisationForTwoNodes
([(
resource_url
,
''
,
-
1.0
,
'2018/09/19'
,
'2018/09/19'
)])
self
.
_makeMovement
(
quantity
=
4
,
destination_value
=
self
.
node_2
,
simulation_state
=
'confirmed'
,
start_date
=
DateTime
(
'2018/09/29'
))
checkStockOptimisationForTwoNodes
([(
resource_url
,
''
,
-
3.0
,
'2018/09/18'
,
'2018/09/18'
),
(
resource_url
,
''
,
-
2.0
,
'2018/09/19'
,
'2018/09/19'
)])
\ No newline at end of file
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