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
1
Merge Requests
1
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
Cédric Le Ninivin
erp5
Commits
81ba8b96
Commit
81ba8b96
authored
Aug 24, 2017
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
buildermixin: Stock optimization can now check intermediate negative stocks
parent
07d72ea4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
9 deletions
+21
-9
product/ERP5/mixin/builder.py
product/ERP5/mixin/builder.py
+21
-9
No files found.
product/ERP5/mixin/builder.py
View file @
81ba8b96
...
@@ -167,7 +167,9 @@ class BuilderMixin(XMLObject, Amount, Predicate):
...
@@ -167,7 +167,9 @@ class BuilderMixin(XMLObject, Amount, Predicate):
delivery_module
=
getattr
(
self
.
getPortalObject
(),
self
.
getDeliveryModule
())
delivery_module
=
getattr
(
self
.
getPortalObject
(),
self
.
getDeliveryModule
())
getattr
(
delivery_module
,
delivery_module_before_building_script_id
)()
getattr
(
delivery_module
,
delivery_module_before_building_script_id
)()
def
generateMovementListForStockOptimisation
(
self
,
group_by_node
=
1
,
**
kw
):
def
generateMovementListForStockOptimisation
(
self
,
group_by_node
=
1
,
allow_intermediate_negative_stock
=
True
,
**
kw
):
from
Products.ERP5Type.Document
import
newTempMovement
from
Products.ERP5Type.Document
import
newTempMovement
now
=
DateTime
()
now
=
DateTime
()
movement_list
=
[]
movement_list
=
[]
...
@@ -230,22 +232,32 @@ class BuilderMixin(XMLObject, Amount, Predicate):
...
@@ -230,22 +232,32 @@ class BuilderMixin(XMLObject, Amount, Predicate):
min_flow
=
resource
.
getProperty
(
supply_prefix
+
'_supply_line_min_flow'
,
0
)
min_flow
=
resource
.
getProperty
(
supply_prefix
+
'_supply_line_min_flow'
,
0
)
max_delay
=
resource
.
getProperty
(
supply_prefix
+
'_supply_line_max_delay'
,
0
)
max_delay
=
resource
.
getProperty
(
supply_prefix
+
'_supply_line_max_delay'
,
0
)
min_stock
=
resource
.
getProperty
(
supply_prefix
+
'_supply_line_min_stock'
,
0
)
min_stock
=
resource
.
getProperty
(
supply_prefix
+
'_supply_line_min_stock'
,
0
)
if
round
(
inventory_item
.
inventory
,
5
)
<
min_stock
:
if
round
(
inventory_item
.
inventory
,
5
)
<
min_stock
\
or
allow_intermediate_negative_stock
==
False
:
stop_date
=
resource
.
getNextAlertInventoryDate
(
stop_date
=
resource
.
getNextAlertInventoryDate
(
reference_quantity
=
min_stock
,
reference_quantity
=
min_stock
,
variation_text
=
inventory_item
.
variation_text
,
variation_text
=
inventory_item
.
variation_text
,
from_date
=
now
,
from_date
=
now
,
group_by_node
=
group_by_node
,
group_by_node
=
group_by_node
,
look_for_minimal
=
not
allow_intermediate_negative_stock
,
**
kw
)
**
kw
)
if
stop_date
is
None
:
if
stop_date
is
None
:
stop_date
=
now
stop_date
=
now
movement
=
newMovement
(
inventory_item
,
resource
)
min_inventory
=
resource
.
getFutureInventory
(
movement
.
edit
(
variation_text
=
inventory_item
.
variation_text
,
start_date
=
stop_date
-
max_delay
,
at_date
=
stop_date
,
stop_date
=
stop_date
,
**
kw
quantity
=
max
(
min_flow
,
-
inventory_item
.
inventory
),
)
)
quantity
=
max
(
min_flow
,
-
min_inventory
)
movement_list
.
append
(
movement
)
# No need to create a movement with quantity == 0
if
quantity
!=
0
:
movement
=
newMovement
(
inventory_item
,
resource
)
movement
.
edit
(
start_date
=
stop_date
-
max_delay
,
stop_date
=
stop_date
,
quantity
=
quantity
,
)
movement_list
.
append
(
movement
)
# We could need to cancel automated stock optimization if for some reasons
# We could need to cancel automated stock optimization if for some reasons
# previous optimisations are obsolete
# previous optimisations are obsolete
elif
round
(
inventory_item
.
inventory
,
5
)
>
min_stock
:
elif
round
(
inventory_item
.
inventory
,
5
)
>
min_stock
:
...
...
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