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
2
Merge Requests
2
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
5e2357e9
Commit
5e2357e9
authored
Jul 05, 2019
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder: get value from default supply if not defined in stock definition supply
parent
6ba419ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
20 deletions
+26
-20
product/ERP5/mixin/builder.py
product/ERP5/mixin/builder.py
+26
-20
No files found.
product/ERP5/mixin/builder.py
View file @
5e2357e9
...
...
@@ -299,17 +299,24 @@ class BuilderMixin(XMLObject, Amount, Predicate):
time_second_ratio
=
resource_value
.
getQuantityUnitDefinitionRatio
(
portal
.
portal_categories
.
quantity_unit
.
time
.
second
)
default_quantity_unit_relative_url
=
default_quantity_unit_value
.
getCategoryRelativeUrl
()
def
getMinMaxDelayAndOrderDelay
(
supply
):
time_quantity_unit_value
=
supply
.
getTimeQuantityUnitValue
()
def
getCorrectSupplyParameter
(
selected_supply
,
default_supply
,
method_id
):
if
selected_supply
==
default_supply
:
return
getattr
(
default_supply
,
method_id
)()
selected_supply_method
=
getattr
(
selected_supply
,
method_id
)
default_supply_method
=
getattr
(
default_supply
,
method_id
)
return
selected_supply_method
()
or
default_supply_method
()
def
getMinMaxDelayAndOrderDelay
(
selected_supply
,
default_supply
):
time_quantity_unit_value
=
getCorrectSupplyParameter
(
selected_supply
,
default_supply
,
'getTimeQuantityUnitValue'
)
min_delay_second
=
0
max_delay_second
=
0
min_order_delay_second
=
0
max_order_delay_second
=
0
if
time_quantity_unit_value
is
not
None
:
min_delay
=
supply
.
getMinDelay
(
)
max_delay
=
supply
.
getMaxDelay
(
)
min_order_delay
=
supply
.
getMinOrderDelay
(
)
max_order_delay
=
supply
.
getMaxOrderDelay
(
)
min_delay
=
getCorrectSupplyParameter
(
selected_supply
,
default_supply
,
'getMinDelay'
)
max_delay
=
getCorrectSupplyParameter
(
selected_supply
,
default_supply
,
'getMaxDelay'
)
min_order_delay
=
getCorrectSupplyParameter
(
selected_supply
,
default_supply
,
'getMinOrderDelay'
)
max_order_delay
=
getCorrectSupplyParameter
(
selected_supply
,
default_supply
,
'getMaxOrderDelay'
)
time_second_conversion_ratio
=
resource_value
.
getQuantityUnitDefinitionRatio
(
time_quantity_unit_value
)
/
time_second_ratio
if
min_delay
:
min_delay_second
=
min_delay
*
time_second_conversion_ratio
...
...
@@ -320,10 +327,10 @@ class BuilderMixin(XMLObject, Amount, Predicate):
if
max_delay
:
max_order_delay_second
=
max_order_delay
*
time_second_conversion_ratio
return
min_delay_second
,
max_delay_second
,
min_order_delay_second
,
max_order_delay_second
min_delay_second
,
max_delay_second
,
min_order_delay_second
,
max_order_delay_second
=
getMinMaxDelayAndOrderDelay
(
supply
)
min_delay_second
,
max_delay_second
,
min_order_delay_second
,
max_order_delay_second
=
getMinMaxDelayAndOrderDelay
(
supply
,
supply
)
def
getOrderQuantityUnitDefaultQuantityUnitConversionRatio
(
supply
):
order_quantity_unit_value
=
supply
.
getOrderQuantityUnitValue
(
)
def
getOrderQuantityUnitDefaultQuantityUnitConversionRatio
(
s
elected_supply
,
default_s
upply
):
order_quantity_unit_value
=
getCorrectSupplyParameter
(
selected_supply
,
default_supply
,
'getOrderQuantityUnitValue'
)
order_quantity_unit_default_quantity_unit_conversion_ratio
=
1
#min_order_in_default_quantity_unit = 0
#max_order_in_default_quantity_unit = float('inf')
...
...
@@ -340,10 +347,10 @@ class BuilderMixin(XMLObject, Amount, Predicate):
max_order_in_default_quantity_unit = max_order * order_quantity_unit_default_quantity_unit_conversion_ratio
"""
return
order_quantity_unit_default_quantity_unit_conversion_ratio
order_quantity_unit_default_quantity_unit_conversion_ratio
=
getOrderQuantityUnitDefaultQuantityUnitConversionRatio
(
supply
)
order_quantity_unit_default_quantity_unit_conversion_ratio
=
getOrderQuantityUnitDefaultQuantityUnitConversionRatio
(
supply
,
supply
)
def
getDefaultQuantityUnitFlowQuantityUnitConversionRatio
(
supply
):
flow_quantity_unit_value
=
supply
.
getFlowQuantityUnitValue
(
)
def
getDefaultQuantityUnitFlowQuantityUnitConversionRatio
(
s
elected_supply
,
default_s
upply
):
flow_quantity_unit_value
=
getCorrectSupplyParameter
(
selected_supply
,
default_supply
,
'getFlowQuantityUnitValue'
)
default_quantity_unit_flow_quantity_unit_conversion_ratio
=
1
if
flow_quantity_unit_value
is
not
None
:
flow_quantity_unit_relative_url
=
flow_quantity_unit_value
.
getCategoryRelativeUrl
()
...
...
@@ -351,7 +358,7 @@ class BuilderMixin(XMLObject, Amount, Predicate):
default_quantity_unit_flow_quantity_unit_conversion_ratio
=
1
/
flow_quantity_unit_default_quantity_unit_conversion_ratio
return
default_quantity_unit_flow_quantity_unit_conversion_ratio
default_quantity_unit_flow_quantity_unit_conversion_ratio
=
getDefaultQuantityUnitFlowQuantityUnitConversionRatio
(
supply
)
default_quantity_unit_flow_quantity_unit_conversion_ratio
=
getDefaultQuantityUnitFlowQuantityUnitConversionRatio
(
supply
,
supply
)
def
getPreviousValidDate
(
date
):
...
...
@@ -367,8 +374,8 @@ class BuilderMixin(XMLObject, Amount, Predicate):
# Initiate variables to match original script from Yusei T.
# XXX To be cleaned
if
selected_supply
!=
supply
:
local_min_delay_second
,
local_max_delay_second
,
local_min_order_delay_second
,
local_max_order_delay_second
=
getMinMaxDelayAndOrderDelay
(
selected_supply
)
local_order_quantity_unit_default_quantity_unit_conversion_ratio
=
getOrderQuantityUnitDefaultQuantityUnitConversionRatio
(
selected_supply
)
local_min_delay_second
,
local_max_delay_second
,
local_min_order_delay_second
,
local_max_order_delay_second
=
getMinMaxDelayAndOrderDelay
(
selected_supply
,
supply
)
local_order_quantity_unit_default_quantity_unit_conversion_ratio
=
getOrderQuantityUnitDefaultQuantityUnitConversionRatio
(
selected_supply
,
supply
)
else
:
local_min_delay_second
,
local_max_delay_second
,
local_min_order_delay_second
,
local_max_order_delay_second
=
min_delay_second
,
max_delay_second
,
min_order_delay_second
,
max_order_delay_second
local_order_quantity_unit_default_quantity_unit_conversion_ratio
=
order_quantity_unit_default_quantity_unit_conversion_ratio
...
...
@@ -377,14 +384,13 @@ class BuilderMixin(XMLObject, Amount, Predicate):
start_date
=
getPreviousValidDate
(
addToDate
(
limit_date
,
second
=-
delay_second
)
)
stop_date
=
addToDate
(
start_date
,
second
=
delay_second
).
earliestTime
()
order_delay_second
=
local_max_order_delay_second
or
local_min_order_delay_second
or
0
effective_date
=
addToDate
(
start_date
,
second
=-
order_delay_second
)
order_quantity
=
ceil
(
quantity
/
local_order_quantity_unit_default_quantity_unit_conversion_ratio
)
quantity
=
order_quantity
*
local_order_quantity_unit_default_quantity_unit_conversion_ratio
return
order_quantity
,
selected_supply
.
getOrderQuantityUnitValue
(),
effective_date
,
start_date
,
stop_date
,
quantity
return
order_quantity
,
getCorrectSupplyParameter
(
selected_supply
,
default_supply
,
'getOrderQuantityUnitValue'
),
effective_date
,
start_date
,
stop_date
,
quantity
resource_portal_type
=
resource_value
.
getPortalType
()
def
newMovement
(
effective_date
,
start_date
,
stop_date
,
quantity
,
quantity_unit
):
...
...
@@ -512,10 +518,10 @@ class BuilderMixin(XMLObject, Amount, Predicate):
selected_supply
=
chooseCorrectSupply
(
default_supply
=
supply
,
start_date_range_min
=
period_start_date
,
start_date_range_max
=
next_period_start_date
)
#we found a stock definition supply
if
selected_supply
!=
supply
:
min_stock_value
=
selected_supply
.
getMinOrderQuantity
()
/
getDefaultQuantityUnitFlowQuantityUnitConversionRatio
(
selected_
supply
)
min_stock_value
=
getCorrectSupplyParameter
(
selected_supply
,
supply
,
'getMinOrderQuantity'
)
/
getDefaultQuantityUnitFlowQuantityUnitConversionRatio
(
selected_supply
,
supply
)
else
:
min_stock_value
=
selected_supply
.
getMinOrderQuantity
()
/
default_quantity_unit_flow_quantity_unit_conversion_ratio
factor
=
selected_supply
.
getMinFlow
(
)
factor
=
getCorrectSupplyParameter
(
selected_supply
,
default_supply
,
'getMinFlow'
)
period_history_list
=
[]
if
next_period_history_list
and
\
...
...
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