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
Klaus Wölfel
erp5
Commits
e103920a
Commit
e103920a
authored
Aug 24, 2017
by
Cédric Le Ninivin
Committed by
Klaus Wölfel
Apr 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
buildermixin: Stock optimization can now check intermediate negative stocks
parent
f914fa8b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
9 deletions
+22
-9
bt5/erp5_base/MixinTemplateItem/portal_components/mixin.erp5.BuilderMixin.py
...TemplateItem/portal_components/mixin.erp5.BuilderMixin.py
+22
-9
No files found.
bt5/erp5_base/MixinTemplateItem/portal_components/mixin.erp5.BuilderMixin.py
View file @
e103920a
...
@@ -168,7 +168,10 @@ class BuilderMixin(XMLObject, Amount, Predicate):
...
@@ -168,7 +168,10 @@ 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
now
=
DateTime
()
now
=
DateTime
()
movement_list
=
[]
movement_list
=
[]
for
attribute
,
method
in
[(
'node_uid'
,
'getDestinationUid'
),
for
attribute
,
method
in
[(
'node_uid'
,
'getDestinationUid'
),
...
@@ -232,20 +235,30 @@ class BuilderMixin(XMLObject, Amount, Predicate):
...
@@ -232,20 +235,30 @@ 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
min_inventory
=
resource
.
getFutureInventory
(
variation_text
=
inventory_item
.
variation_text
,
at_date
=
stop_date
,
**
kw
)
quantity
=
max
(
min_flow
,
-
min_inventory
)
# No need to create a movement with quantity == 0
if
quantity
!=
0
:
movement
=
newMovement
(
inventory_item
,
resource
)
movement
=
newMovement
(
inventory_item
,
resource
)
movement
.
edit
(
movement
.
edit
(
start_date
=
stop_date
-
max_delay
,
start_date
=
stop_date
-
max_delay
,
stop_date
=
stop_date
,
stop_date
=
stop_date
,
quantity
=
max
(
min_flow
,
-
inventory_item
.
inventory
)
,
quantity
=
quantity
,
)
)
movement_list
.
append
(
movement
)
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
...
...
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