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
5092bdbc
Commit
5092bdbc
authored
Jan 16, 2018
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder: Use periodicity to determinate start date
parent
d4fb0dc6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
product/ERP5/mixin/builder.py
product/ERP5/mixin/builder.py
+15
-4
No files found.
product/ERP5/mixin/builder.py
View file @
5092bdbc
...
@@ -334,6 +334,14 @@ class BuilderMixin(XMLObject, Amount, Predicate):
...
@@ -334,6 +334,14 @@ class BuilderMixin(XMLObject, Amount, Predicate):
else
:
else
:
default_quantity_unit_order_quantity_unit_conversion_ratio
=
1
default_quantity_unit_order_quantity_unit_conversion_ratio
=
1
def
getPreviousValidDate
(
date
):
# We suppose the system has not been configured to handled per hour commands
return
DateTime
(
supply
.
getNextPeriodicalDate
(
date
.
earliestTime
(),
# Hackish and dangerous
next_start_date
=
date
.
earliestTime
(),
factor
=-
1
)).
earliestTime
()
# Function to define the minimal quantity to be ordered
# Function to define the minimal quantity to be ordered
def
minimalQuantity
(
quantity
,
date
):
def
minimalQuantity
(
quantity
,
date
):
# Initiate variables to match original script from Yusei T.
# Initiate variables to match original script from Yusei T.
...
@@ -342,11 +350,14 @@ class BuilderMixin(XMLObject, Amount, Predicate):
...
@@ -342,11 +350,14 @@ class BuilderMixin(XMLObject, Amount, Predicate):
next_date
=
date
next_date
=
date
delay_second
=
max_delay_second
or
min_delay_second
or
0
delay_second
=
max_delay_second
or
min_delay_second
or
0
start_date
=
addToDate
(
date
,
second
=-
delay_second
)
start_date
=
getPreviousValidDate
(
addToDate
(
date
,
second
=-
delay_second
)
)
stop_date
=
addToDate
(
start_date
,
second
=
delay_second
).
earliestTime
()
order_quantity
=
ceil
(
quantity
*
conversion_ratio
)
order_quantity
=
ceil
(
quantity
*
conversion_ratio
)
quantity
=
order_quantity
/
conversion_ratio
quantity
=
order_quantity
/
conversion_ratio
return
order_quantity
,
order_quantity_unit_value
,
start_date
,
quantity
return
order_quantity
,
order_quantity_unit_value
,
start_date
,
stop_date
,
quantity
resource_portal_type
=
resource_value
.
getPortalType
()
resource_portal_type
=
resource_value
.
getPortalType
()
def
newMovement
(
start_date
,
stop_date
,
quantity
,
quantity_unit
):
def
newMovement
(
start_date
,
stop_date
,
quantity
,
quantity_unit
):
...
@@ -383,12 +394,12 @@ class BuilderMixin(XMLObject, Amount, Predicate):
...
@@ -383,12 +394,12 @@ class BuilderMixin(XMLObject, Amount, Predicate):
for
date
,
inventory
in
history_list
:
for
date
,
inventory
in
history_list
:
if
ordered_inventory
+
inventory
<
min_inventory
:
# SKU
if
ordered_inventory
+
inventory
<
min_inventory
:
# SKU
quantity
=
min_inventory
-
inventory
-
ordered_inventory
quantity
=
min_inventory
-
inventory
-
ordered_inventory
ordered_quantity
,
ordered_unit
,
ordered_date
,
quantity
=
minimalQuantity
(
quantity
,
date
)
ordered_quantity
,
ordered_unit
,
ordered_date
,
delivery_date
,
quantity
=
minimalQuantity
(
quantity
,
date
)
ordered_inventory
=
ordered_inventory
+
quantity
ordered_inventory
=
ordered_inventory
+
quantity
movement_list
.
append
(
movement_list
.
append
(
newMovement
(
newMovement
(
ordered_date
,
ordered_date
,
addToDate
(
date
,
second
=-
1
)
,
delivery_date
,
ordered_quantity
,
ordered_quantity
,
ordered_unit
ordered_unit
)
)
...
...
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