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
31e63f1b
Commit
31e63f1b
authored
Feb 12, 2019
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder: Reach workable calculation
parent
ba0e917e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
3 deletions
+36
-3
product/ERP5/mixin/builder.py
product/ERP5/mixin/builder.py
+36
-3
No files found.
product/ERP5/mixin/builder.py
View file @
31e63f1b
...
...
@@ -450,7 +450,7 @@ class BuilderMixin(XMLObject, Amount, Predicate):
)
# Prepare period_list
limit_date
=
getPreviousValidDate
(
from_date
)
limit_date
=
getPreviousValidDate
(
getPreviousValidDate
(
from_date
)
-
0.1
)
limit_date_list
=
[]
last_date
=
getPreviousValidDate
(
history_list
[
-
1
][
0
])
while
limit_date
<=
last_date
:
...
...
@@ -460,6 +460,9 @@ class BuilderMixin(XMLObject, Amount, Predicate):
# Hackish and dangerous
next_start_date
=
limit_date
)).
earliestTime
()
min_stock_value
=
supply
.
getMinOrderQuantity
()
/
default_quantity_unit_flow_quantity_unit_conversion_ratio
factor
=
supply
.
getMinFlow
()
next_period_history_list
=
[]
#self.log(limit_date_list)
# Create a movement per period
for
period_start_date
in
limit_date_list
:
...
...
@@ -470,16 +473,46 @@ class BuilderMixin(XMLObject, Amount, Predicate):
next_start_date
=
period_start_date
)).
earliestTime
()
period_history_list
=
[]
if
next_period_history_list
and
\
next_next_period_start_date
==
next_period_start_date
:
period_history_list
=
next_period_history_list
[:]
while
history_list
and
history_list
[
0
][
0
]
<
next_period_start_date
:
period_history_list
.
append
(
history_list
.
pop
(
0
))
# Using period history list calculate min stock
min_inventory
=
self
.
Base_evaluateMinInventoryForSupplyAtDate
(
# In this iteration we verify that the invetory is always superior
# to the min_stock_value
min_inventory_end_of_period
=
min_stock_value
# Anticipate next period need if a ratio is defined
next_period_history_list
=
[]
next_next_period_start_date
=
DateTime
(
supply
.
getNextPeriodicalDate
(
next_period_start_date
,
next_start_date
=
next_period_start_date
)).
earliestTime
()
if
factor
and
next_next_period_start_date
<=
last_date
:
# prepare new hixtory_list
while
history_list
and
history_list
[
0
][
0
]
<
next_next_period_start_date
:
next_period_history_list
.
append
(
history_list
.
pop
(
0
))
# Calculate need with ratio
# Here it is actually just a ratio of the next period consumption.
min_inventory_end_of_period
=
self
.
Base_evaluateMinInventoryForSupplyAtDate
(
supply
=
supply
,
history_list
=
next_period_history_list
,
at_date
=
next_period_start_date
,
factor
=
factor
,
min_stock_value
=
min_inventory_end_of_period
,
)
week_consumption
=
self
.
Base_evaluateMinInventoryForSupplyAtDate
(
supply
=
supply
,
history_list
=
period_history_list
,
at_date
=
period_start_date
,
conversion_ratio
=
default_quantity_unit_flow_quantity_unit_conversion_ratio
,
factor
=
1
,
)
min_inventory
=
min_inventory_end_of_period
+
week_consumption
quantity
=
0
if
future_inventory_to_date
<
min_inventory
:
# SKU
...
...
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