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
Mikolaï Krol
erp5
Commits
d4dce69d
Commit
d4dce69d
authored
Dec 13, 2018
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testInventory: update test
remove useless test_21 update test_20 with various packing list
parent
cc8672de
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
443 additions
and
395 deletions
+443
-395
product/ERP5/tests/testInventory.py
product/ERP5/tests/testInventory.py
+443
-395
No files found.
product/ERP5/tests/testInventory.py
View file @
d4dce69d
...
@@ -76,7 +76,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -76,7 +76,7 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
"""
"""
return
(
'erp5_base'
,
'erp5_pdm'
,
'erp5_simulation'
,
'erp5_trade'
,
return
(
'erp5_base'
,
'erp5_pdm'
,
'erp5_simulation'
,
'erp5_trade'
,
'erp5_configurator_standard_trade_template'
,
'erp5_configurator_standard_trade_template'
,
'erp5_apparel'
,
'erp5_simulation_test'
)
'erp5_apparel'
,
'erp5_simulation_test'
,
'erp5_mrp'
)
def
setUpPreferences
(
self
):
def
setUpPreferences
(
self
):
#create apparel variation preferences
#create apparel variation preferences
...
@@ -1231,21 +1231,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -1231,21 +1231,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
LOG
(
'SQL Query was : '
,
0
,
str
(
simulation
.
getInventory
(
src__
=
1
,
**
kw
)))
LOG
(
'SQL Query was : '
,
0
,
str
(
simulation
.
getInventory
(
src__
=
1
,
**
kw
)))
self
.
assertEqual
(
e_inventory
,
a_inventory
,
msg
)
self
.
assertEqual
(
e_inventory
,
a_inventory
,
msg
)
def
_testGetInventoryAssetPrice
(
self
,
expected
,
**
kw
):
"""
Shared testing method
"""
simulation
=
self
.
getPortal
().
portal_simulation
e_inventory
=
expected
LOG
(
'Testing inventory with args :'
,
0
,
kw
)
a_inventory
=
simulation
.
getInventoryAssetPrice
(
**
kw
)
if
e_inventory
!=
a_inventory
:
msg
=
'Inventory differs between expected (%s) and real (%s) price'
\
%
(
repr
(
e_inventory
),
repr
(
a_inventory
))
LOG
(
'TestInventory._testGetInventoryAssetPrice'
,
0
,
msg
)
LOG
(
'SQL Query was : '
,
0
,
str
(
simulation
.
getInventoryAssetPrice
(
src__
=
1
,
**
kw
)))
self
.
assertEqual
(
e_inventory
,
a_inventory
,
msg
)
def
stepTestGetInventoryOnSimulationState
(
self
,
sequence
=
None
,
def
stepTestGetInventoryOnSimulationState
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
...
@@ -3550,8 +3535,8 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -3550,8 +3535,8 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
packing_list
=
packing_list_module
.
newContent
(
packing_list
=
packing_list_module
.
newContent
(
portal_type
=
packing_list_portal_type
)
portal_type
=
packing_list_portal_type
)
if
kw
.
get
(
'
star
t_date'
,
None
)
is
not
None
:
if
kw
.
get
(
'
a
t_date'
,
None
)
is
not
None
:
start_date
=
stop_date
=
kw
[
'
star
t_date'
]
start_date
=
stop_date
=
kw
[
'
a
t_date'
]
else
:
else
:
start_date
=
stop_date
=
DateTime
()
-
2
start_date
=
stop_date
=
DateTime
()
-
2
packing_list
.
edit
(
packing_list
.
edit
(
...
@@ -3573,7 +3558,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -3573,7 +3558,6 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
price
=
price
price
=
price
)
)
sequence
.
edit
(
packing_list
=
packing_list
)
sequence
.
edit
(
packing_list
=
packing_list
)
return
packing_list_line
def
stepCreateSalePackingListToSectionNodeForFirstResource
(
self
,
sequence
=
None
,
def
stepCreateSalePackingListToSectionNodeForFirstResource
(
self
,
sequence
=
None
,
...
@@ -3707,453 +3691,517 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
...
@@ -3707,453 +3691,517 @@ class TestInventory(TestOrderMixin, ERP5TypeTestCase):
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
sequence_list
.
play
(
self
)
def
stepCreateIPLForModule
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepInitialAWarehouseX
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
node
=
sequence
.
get
(
'node'
)
#sale packing list
section
=
sequence
.
get
(
'section'
)
at_date
=
DateTime
(
'2013/02/10 00:00:00 GMT+9'
)
other_node
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
packing_list_module
=
self
.
getPortal
().
getDefaultModule
(
A
=
sequence
.
get
(
'section'
)
portal_type
=
'Internal Packing List'
)
X
=
sequence
.
get
(
'node'
)
packing_list
=
packing_list_module
.
newContent
(
mirror_section
=
sequence
.
get
(
'mirror_section'
)
portal_type
=
'Internal Packing List'
)
mirror_node
=
sequence
.
get
(
'mirror_node'
)
start_date
=
stop_date
=
self
.
start_date_1
#same owner but different warehouse
packing_list
.
edit
(
specialise
=
self
.
business_process
,
source_section_value
=
section
,
source_value
=
node
,
destination_section_value
=
section
,
destination_value
=
other_node
,
start_date
=
start_date
,
stop_date
=
stop_date
,
price_currency
=
self
.
price_currency
)
sequence
.
edit
(
packing_list
=
packing_list
)
def
stepCreatePackingListLineWithQuantity3
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
packing_list
=
sequence
.
get
(
'packing_list'
)
resource_value
=
sequence
.
get
(
'resource'
)
packing_list_line
=
packing_list
.
newContent
(
portal_type
=
'Internal Packing List Line'
)
packing_list_line
.
edit
(
resource_value
=
resource_value
,
quantity
=
3.
)
def
stepCreatePackingListLineWithQuantity_3
(
self
,
sequence
=
None
,
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
sequence_list
,
packing_list
=
sequence
.
get
(
'packing_list'
)
section
=
A
,
resource_value
=
sequence
.
get
(
'resource'
)
node
=
X
,
packing_list_line
=
packing_list
.
newContent
(
mirror_section
=
mirror_section
,
portal_type
=
'Internal Packing List Line'
)
mirror_node
=
mirror_node
,
packing_list_line
.
edit
(
resource_value
=
resource_value
,
resource
=
resource
,
quantity
=
-
3.
quantity
=
100
,
)
at_date
=
at_date
,
packing_list
=
'Sale Packing List'
)
def
stepCreatePackingListLineWithQuantity30
(
self
,
sequence
=
None
,
def
stepCreateIPLFromAWarehouseXToAWarehouseYWithQuantity3
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
A
=
sequence
.
get
(
'section'
)
packing_list
=
sequence
.
get
(
'packing_list'
)
X
=
sequence
.
get
(
'node'
)
resource_value
=
sequence
.
get
(
'resource'
)
Y
=
sequence
.
get
(
'other_node'
)
packing_list_line
=
packing_list
.
newContent
(
resource
=
sequence
.
get
(
'resource'
)
portal_type
=
'Internal Packing List Line'
)
at_date
=
DateTime
(
'2013/02/11 00:00:00 GMT+9'
)
packing_list_line
.
edit
(
resource_value
=
resource_value
,
quantity
=
30.
)
def
stepCreatePackingListLineWithQuantity_30
(
self
,
sequence
=
None
,
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
sequence_list
,
packing_list
=
sequence
.
get
(
'packing_list'
)
section
=
A
,
resource_value
=
sequence
.
get
(
'resource'
)
node
=
Y
,
packing_list_line
=
packing_list
.
newContent
(
mirror_section
=
A
,
portal_type
=
'Internal Packing List Line'
)
mirror_node
=
X
,
packing_list_line
.
edit
(
resource_value
=
resource_value
,
resource
=
resource
,
quantity
=
-
30.
quantity
=
3
,
)
at_date
=
at_date
,
packing_list
=
'Internal Packing List'
)
def
stepCancelIPLFromAWarehouseXToAWarehouseYWithQuantity3
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
A
=
sequence
.
get
(
'section'
)
X
=
sequence
.
get
(
'node'
)
Y
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
at_date
=
DateTime
(
'2013/02/11 02:00:00 GMT+9'
)
def
stepCreatePackingListLineWithQuantity33
(
self
,
sequence
=
None
,
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
sequence_list
,
packing_list
=
sequence
.
get
(
'packing_list'
)
section
=
A
,
resource_value
=
sequence
.
get
(
'resource'
)
node
=
X
,
packing_list_line
=
packing_list
.
newContent
(
mirror_section
=
A
,
portal_type
=
'Internal Packing List Line'
)
mirror_node
=
Y
,
packing_list_line
.
edit
(
resource_value
=
resource_value
,
resource
=
resource
,
quantity
=
33.
quantity
=
3
,
)
at_date
=
at_date
,
def
stepTestMultiCancelInventory
(
self
,
sequence
=
None
,
packing_list
=
'Internal Packing List'
)
sequence_list
=
None
,
**
kw
):
resource_value
=
sequence
.
get
(
'resource'
)
def
stepCreateIPLFromAWarehouseXToAWarehouseYWithQuantity30
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
node_value
=
sequence
.
get
(
'node'
)
A
=
sequence
.
get
(
'section'
)
other_node_value
=
sequence
.
get
(
'other_node'
)
X
=
sequence
.
get
(
'node'
)
section_value
=
sequence
.
get
(
'section'
)
Y
=
sequence
.
get
(
'other_node'
)
at_date
=
self
.
start_date_1
resource
=
sequence
.
get
(
'resource'
)
self
.
_testGetInventory
(
at_date
=
DateTime
(
'2013/02/13 04:00:00 GMT+9'
)
expected
=
67
,
section_uid
=
section_value
.
getUid
(),
node_uid
=
node_value
.
getUid
(),
resource_uid
=
resource_value
.
getUid
(),
at_date
=
at_date
)
self
.
_testGetInventory
(
expected
=
33
,
section_uid
=
section_value
.
getUid
(),
node_uid
=
other_node_value
.
getUid
(),
resource_uid
=
resource_value
.
getUid
(),
at_date
=
at_date
)
def
test_20_InventoryWhenCancelInternalPackingList
(
self
,
quite
=
0
,
run
=
run_all_test
):
self
.
stepCreatePackingList
(
sequence
=
sequence
,
"""
sequence_list
=
sequence_list
,
When Company A's 33 of product G was shipped from warehouse X
section
=
A
,
to warehouse Y (ownership is still same, just location change)
node
=
Y
,
in real world, an ERP5 user made many mistakes to enter the above
mirror_section
=
A
,
single fact and in the end he created five IPL(Internal Packing List)
mirror_node
=
X
,
to record the single fact.
resource
=
resource
,
quantity
=
30
,
IPL1 (quantity is wrong)
at_date
=
at_date
,
start_date 2013/Feb/10
packing_list
=
'Internal Packing List'
)
source_section A destination_section A
source X destination Y
resource G quantity 3
simulation_state
IPL2 (Cancellation of IPL1)
start_date 2013/Feb/10
source_section A destination_section A
source X destination Y
resource G quantity -3
simulation_state delivered
IPL3 (He made a mistake again!)
start_date 2013/Feb/10
source_section A destination_section A
source X destination Y
resource H quantity 30
simulation_state delivered
IPL4 (Cancellation of IPL3)
start_date 2013/Feb/10
source_section A destination_section A
source X destination Y
resource H quantity -30
simulation_state delivered
IPL5 (Finally he was able to enter data correctly!)
start_date 2013/Feb/10
source_section A destination_section A
source X destination Y
resource G quantity 33
simulation_state delivered
"""
if
not
run
:
return
self
.
start_date_1
=
'2013/02/10 00:00:00 GMT+9'
sequence_list
=
SequenceList
()
sequence_string
=
'CreateOrganisationsForModule
\
CreateNotVariatedResource
\
Tic
\
CreatePackingListAtTheDate1
\
CreatePackingListLine
\
Tic
\
DeliverPackingList
\
Tic
\
CreateIPLForModule
\
CreatePackingListLineWithQuantity3
\
Tic
\
DeliverPackingList
\
Tic
\
CreateIPLForModule
\
CreatePackingListLineWithQuantity_3
\
Tic
\
DeliverPackingList
\
Tic
\
CreateIPLForModule
\
CreatePackingListLineWithQuantity30
\
Tic
\
DeliverPackingList
\
Tic
\
CreateIPLForModule
\
CreatePackingListLineWithQuantity_30
\
Tic
\
DeliverPackingList
\
Tic
\
CreateIPLForModule
\
CreatePackingListLineWithQuantity33
\
Tic
\
DeliverPackingList
\
Tic
\
TestMultiCancelInventory
\
'
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
stepCancelIPLFromAWarehouseXToAWarehouseYWithQuantity30
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
A
=
sequence
.
get
(
'section'
)
X
=
sequence
.
get
(
'node'
)
Y
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
at_date
=
DateTime
(
'2013/02/14 05:00:00 GMT+9'
)
def
stepCreateOneMoreSection
(
self
,
sequence
=
None
,
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
sequence_list
,
self
.
stepCreateOrganisation
(
sequence
=
sequence
,
section
=
A
,
sequence_list
=
sequence_list
,
**
kw
)
node
=
X
,
one_more_section
=
sequence
.
get
(
'organisation'
)
mirror_section
=
A
,
sequence
.
edit
(
mirror_node
=
Y
,
one_more_section
=
one_more_section
resource
=
resource
,
)
quantity
=
30
,
at_date
=
at_date
,
packing_list
=
'Internal Packing List'
)
def
stepCreateS
alePackingListToA
(
self
,
sequence
=
None
,
def
stepCreateS
PLFromAWarehouseXToBWarehouseYWithQuantity30
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
#A
A
=
sequence
.
get
(
'section'
)
section
=
sequence
.
get
(
'section'
)
X
=
sequence
.
get
(
'node'
)
node
=
sequence
.
get
(
'node'
)
B
=
sequence
.
get
(
'other_section'
)
Y
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
at_date
=
DateTime
(
'2013/02/14 04:00:00 GMT+9'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
sequence_list
=
sequence_list
,
section
=
section
,
section
=
B
,
node
=
node
,
node
=
Y
,
mirror_section
=
A
,
mirror_node
=
X
,
resource
=
resource
,
resource
=
resource
,
quantity
=
1
0
,
quantity
=
3
0
,
price
=
100
,
at_date
=
at_date
,
packing_list
=
'Sale Packing List'
)
packing_list
=
'Sale Packing List'
)
def
stepCreateP
urchasePackingListForASecond
(
self
,
sequence
=
None
,
def
stepCreateP
PLForCWarehouseXFromAWarehouseXWithQuantity10
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
#A
section
=
sequence
.
get
(
'section'
)
node
=
sequence
.
get
(
'node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
C
=
sequence
.
get
(
'one_more_section'
)
X
=
sequence
.
get
(
'node'
)
A
=
sequence
.
get
(
'section'
)
X
=
sequence
.
get
(
'node'
)
at_date
=
DateTime
(
'2013/02/11 04:00:00 GMT+9'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
sequence_list
=
sequence_list
,
section
=
section
,
section
=
C
,
node
=
node
,
node
=
X
,
mirror_section
=
A
,
mirror_node
=
X
,
resource
=
resource
,
resource
=
resource
,
quantity
=
15
,
quantity
=
10
,
price
=
200
,
at_date
=
at_date
,
packing_list
=
'Purchase Packing List'
)
packing_list
=
'Purchase Packing List'
)
def
stepC
reatePurchasePackingListForAThird
(
self
,
sequence
=
None
,
def
stepC
ancelSPLFromAWarehouseXToBWarehouseYWithQuantity30
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
#A
A
=
sequence
.
get
(
'section'
)
section
=
sequence
.
get
(
'section'
)
X
=
sequence
.
get
(
'node'
)
node
=
sequence
.
get
(
'node'
)
B
=
sequence
.
get
(
'other_section'
)
Y
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
at_date
=
DateTime
(
'2013/02/14 06:00:00 GMT+9'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
sequence_list
=
sequence_list
,
section
=
section
,
section
=
A
,
node
=
node
,
node
=
X
,
mirror_section
=
B
,
mirror_node
=
Y
,
resource
=
resource
,
resource
=
resource
,
quantity
=
2
0
,
quantity
=
3
0
,
price
=
200
,
at_date
=
at_date
,
packing_list
=
'Purchas
e Packing List'
)
packing_list
=
'Sal
e Packing List'
)
def
stepCreatePurchasePackingListForB
(
self
,
sequence
=
None
,
def
stepCreateProductionPFromAFactoryZToAWarehouseXWithQuantity10
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
#B
A
=
sequence
.
get
(
'section'
)
section
=
sequence
.
get
(
'other_section
'
)
Z
=
sequence
.
get
(
'factory
'
)
node
=
sequence
.
get
(
'other_
node'
)
X
=
sequence
.
get
(
'
node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
at_date
=
DateTime
(
'2013/02/14 08:00:00 GMT+9'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
sequence_list
=
sequence_list
,
section
=
section
,
section
=
A
,
node
=
node
,
node
=
X
,
mirror_section
=
A
,
mirror_node
=
Z
,
resource
=
resource
,
resource
=
resource
,
quantity
=
20
,
quantity
=
10
,
price
=
55
,
at_date
=
at_date
,
packing_list
=
'Purchase Packing List'
)
packing_list
=
'Production Packing List'
)
def
stepCreateS
alePackingListFromAToB
(
self
,
sequence
=
None
,
def
stepCreateS
PLFromAWarehouseXToBWarehouseYWithQuantity24
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
#B
A
=
sequence
.
get
(
'section'
)
section
=
sequence
.
get
(
'other_section'
)
X
=
sequence
.
get
(
'node'
)
node
=
sequence
.
get
(
'other_node'
)
B
=
sequence
.
get
(
'other_section'
)
Y
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
#A
at_date
=
DateTime
(
'2013/02/16 00:00:00 GMT+9'
)
mirror_section
=
sequence
.
get
(
'section'
)
mirror_node
=
sequence
.
get
(
'node'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
packing_list_line_a_to_b
=
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
sequence_list
=
sequence_list
,
section
=
section
,
section
=
B
,
node
=
node
,
node
=
Y
,
mirror_section
=
mirror_section
,
mirror_section
=
A
,
mirror_node
=
mirror_node
,
mirror_node
=
X
,
resource
=
resource
,
resource
=
resource
,
quantity
=
30
,
quantity
=
24
,
at_date
=
at_date
,
packing_list
=
'Sale Packing List'
)
packing_list
=
'Sale Packing List'
)
sequence
.
edit
(
packing_list_line_a_to_b
=
packing_list_line_a_to_b
)
def
stepCreateP
urchasePackingListForCFromA
(
self
,
sequence
=
None
,
def
stepCreateP
PLForCWarehouseXFromBWarehouseYWithQuantity5
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
C
=
sequence
.
get
(
'one_more_section'
)
#C
X
=
sequence
.
get
(
'node'
)
section
=
sequence
.
get
(
'one_more
_section'
)
B
=
sequence
.
get
(
'other
_section'
)
node
=
sequence
.
get
(
'
node'
)
Y
=
sequence
.
get
(
'other_
node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
#A
at_date
=
DateTime
(
'2013/02/24 00:00:00 GMT+9'
)
mirror_section
=
sequence
.
get
(
'section'
)
mirror_node
=
sequence
.
get
(
'node'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
packing_list_line_a_to_c
=
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
sequence_list
=
sequence_list
,
section
=
section
,
section
=
C
,
node
=
node
,
node
=
X
,
mirror_section
=
mirror_section
,
mirror_section
=
B
,
mirror_node
=
mirror_node
,
mirror_node
=
Y
,
resource
=
resource
,
resource
=
resource
,
quantity
=
10
,
quantity
=
5
,
at_date
=
at_date
,
packing_list
=
'Purchase Packing List'
)
packing_list
=
'Purchase Packing List'
)
sequence
.
edit
(
packing_list_line_a_to_c
=
packing_list_line_a_to_c
)
def
stepCreatePurchasePackingListForCFromB
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
def
stepCreateIPLFromAWarehouseXToAWarehouseYWithQuantity33
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
#C
A
=
sequence
.
get
(
'section'
)
section
=
sequence
.
get
(
'one_more_section'
)
X
=
sequence
.
get
(
'node'
)
node
=
sequence
.
get
(
'node'
)
Y
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
#B
at_date
=
DateTime
(
'2013/02/25 01:00:00 GMT+9'
)
mirror_section
=
sequence
.
get
(
'other_section'
)
mirror_node
=
sequence
.
get
(
'other_node'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
packing_list_line_b_to_c
=
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
sequence_list
=
sequence_list
,
section
=
section
,
section
=
A
,
node
=
node
,
node
=
Y
,
mirror_section
=
mirror_section
,
mirror_section
=
A
,
mirror_node
=
mirror_node
,
mirror_node
=
X
,
resource
=
resource
,
at_date
=
at_date
,
quantity
=
33
,
packing_list
=
'Internal Packing List'
)
def
stepCancelPPLForCWarehouseXFromBWarehouseYWithQuantity5
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
C
=
sequence
.
get
(
'one_more_section'
)
X
=
sequence
.
get
(
'node'
)
B
=
sequence
.
get
(
'other_section'
)
Y
=
sequence
.
get
(
'other_node'
)
resource
=
sequence
.
get
(
'resource'
)
at_date
=
DateTime
(
'2013/02/25 02:00:00 GMT+9'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
section
=
B
,
node
=
Y
,
mirror_section
=
C
,
mirror_node
=
X
,
resource
=
resource
,
resource
=
resource
,
quantity
=
5
,
quantity
=
5
,
packing_list
=
'Purchase Packing List'
)
at_date
=
at_date
,
sequence
.
edit
(
packing_list_line_b_to_c
=
packing_list_line_b_to_c
)
packing_list
=
'Purchase Packing List'
)
def
stepCreate
SalePackingListFromCToA
(
self
,
sequence
=
None
,
def
stepCreate
PPLForCWarehouseXFromBWarehouseYWithQuantity10
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
C
=
sequence
.
get
(
'one_more_section'
)
#A
X
=
sequence
.
get
(
'node'
)
section
=
sequence
.
get
(
'
section'
)
B
=
sequence
.
get
(
'other_
section'
)
node
=
sequence
.
get
(
'
node'
)
Y
=
sequence
.
get
(
'other_
node'
)
resource
=
sequence
.
get
(
'resource'
)
resource
=
sequence
.
get
(
'resource'
)
#C
at_date
=
DateTime
(
'2013/02/26 00:00:00 GMT+9'
)
mirror_section
=
sequence
.
get
(
'one_more_section'
)
mirror_node
=
sequence
.
get
(
'node'
)
self
.
stepCreatePackingList
(
sequence
=
sequence
,
packing_list_line_c_to_a
=
self
.
stepCreatePackingList
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
sequence_list
=
sequence_list
,
section
=
section
,
section
=
C
,
node
=
node
,
node
=
X
,
mirror_section
=
mirror_section
,
mirror_section
=
B
,
mirror_node
=
mirror_node
,
mirror_node
=
Y
,
resource
=
resource
,
resource
=
resource
,
quantity
=
2
,
quantity
=
10
,
packing_list
=
'Sale Packing List'
)
at_date
=
at_date
,
sequence
.
edit
(
packing_list_line_c_to_a
=
packing_list_line_c_to_a
)
packing_list
=
'Purchase Packing List'
)
def
stepCreateOneMoreSection
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
self
.
stepCreateOrganisation
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
**
kw
)
one_more_section
=
sequence
.
get
(
'organisation'
)
sequence
.
edit
(
one_more_section
=
one_more_section
)
def
stepCreateFactory
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
self
.
stepCreateOrganisation
(
sequence
=
sequence
,
sequence_list
=
sequence_list
,
**
kw
)
factory
=
sequence
.
get
(
'organisation'
)
sequence
.
edit
(
factory
=
factory
)
def
stepDeliverProductionPackingList
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
# Switch to "started" state
packing_list
=
sequence
.
get
(
'packing_list'
)
workflow_tool
=
self
.
getPortal
().
portal_workflow
workflow_tool
.
doActionFor
(
packing_list
,
"confirm_action"
,
"production_packing_list_workflow"
)
self
.
commit
()
# Apply tic so that the packing list is not in building state
self
.
tic
()
# acceptable here because this is not the job
# of the test to check if can do all transition
# without processing messages
workflow_tool
.
doActionFor
(
packing_list
,
"set_ready_action"
,
"production_packing_list_workflow"
)
self
.
tic
()
workflow_tool
.
doActionFor
(
packing_list
,
"start_action"
,
"production_packing_list_workflow"
)
workflow_tool
.
doActionFor
(
packing_list
,
"stop_action"
,
"production_packing_list_workflow"
)
workflow_tool
.
doActionFor
(
packing_list
,
"deliver_action"
,
"production_packing_list_workflow"
)
def
step
testCircularMovementQuantit
y
(
self
,
sequence
=
None
,
def
step
TestMultiCancelInventor
y
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
sequence_list
=
None
,
**
kw
):
resource_value
=
sequence
.
get
(
'resource'
)
resource_value
=
sequence
.
get
(
'resource'
)
node_value
=
sequence
.
get
(
'node
'
)
A
=
sequence
.
get
(
'section
'
)
other_node_value
=
sequence
.
get
(
'other_node
'
)
B
=
sequence
.
get
(
'other_section
'
)
section_value
=
sequence
.
get
(
'
section'
)
C
=
sequence
.
get
(
'one_more_
section'
)
other_section_value
=
sequence
.
get
(
'other_section
'
)
X
=
sequence
.
get
(
'node
'
)
one_more_section_value
=
sequence
.
get
(
'one_more_section
'
)
Y
=
sequence
.
get
(
'other_node
'
)
#C
self
.
_testGetInventory
(
self
.
_testGetInventory
(
expected
=
13
,
expected
=
33
,
section_uid
=
one_more_section_value
.
getUid
(),
section_uid
=
A
.
getUid
(),
node_uid
=
node_value
.
getUid
(),
node_uid
=
Y
.
getUid
(),
resource_uid
=
resource_value
.
getUid
()
resource_uid
=
resource_value
.
getUid
())
)
#B
self
.
_testGetInventory
(
self
.
_testGetInventory
(
expected
=
45
,
expected
=
43
,
section_uid
=
other_section_value
.
getUid
(),
section_uid
=
A
.
getUid
(),
node_uid
=
other_node_value
.
getUid
(),
node_uid
=
X
.
getUid
(),
resource_uid
=
resource_value
.
getUid
()
resource_uid
=
resource_value
.
getUid
())
)
#A
self
.
_testGetInventory
(
self
.
_testGetInventory
(
expected
=
7
,
expected
=
14
,
section_uid
=
section_value
.
getUid
(),
section_uid
=
B
.
getUid
(),
node_uid
=
node_value
.
getUid
(),
node_uid
=
Y
.
getUid
(),
resource_uid
=
resource_value
.
getUid
()
resource_uid
=
resource_value
.
getUid
())
)
def
steptestCircularMovementPrice
(
self
,
sequence
=
None
,
self
.
_testGetInventory
(
sequence_list
=
None
,
**
kw
):
expected
=
20
,
resource_value
=
sequence
.
get
(
'resource'
)
section_uid
=
C
.
getUid
(),
node_value
=
sequence
.
get
(
'node'
)
node_uid
=
X
.
getUid
(),
other_node_value
=
sequence
.
get
(
'other_node'
)
resource_uid
=
resource_value
.
getUid
())
section_value
=
sequence
.
get
(
'section'
)
other_section_value
=
sequence
.
get
(
'other_section'
)
at_date
=
DateTime
(
'2013/02/15 00:00:00 GMT+9'
)
one_more_section_value
=
sequence
.
get
(
'one_more_section'
)
#C
self
.
_testGetInventory
(
self
.
_testGetInventoryAssetPrice
(
expected
=
0
,
expected
=
160
,
section_uid
=
A
.
getUid
(),
section_uid
=
one_more_section_value
.
getUid
(),
node_uid
=
Y
.
getUid
(),
node_uid
=
node_value
.
getUid
(),
at_date
=
at_date
,
resource_uid
=
resource_value
.
getUid
(),
resource_uid
=
resource_value
.
getUid
())
valuation_method
=
'WeightedAverage'
)
self
.
_testGetInventory
(
#B
expected
=
100
,
self
.
_testGetInventoryAssetPrice
(
section_uid
=
A
.
getUid
(),
expected
=
129
,
node_uid
=
X
.
getUid
(),
section_uid
=
other_section_value
.
getUid
(),
at_date
=
at_date
,
node_uid
=
other_node_value
.
getUid
(),
resource_uid
=
resource_value
.
getUid
())
resource_uid
=
resource_value
.
getUid
(),
valuation_method
=
'WeightedAverage'
self
.
_testGetInventory
(
)
expected
=
0
,
#A
section_uid
=
B
.
getUid
(),
self
.
_testGetInventoryAssetPrice
(
node_uid
=
Y
.
getUid
(),
expected
=
178
,
at_date
=
at_date
,
section_uid
=
section_value
.
getUid
(),
resource_uid
=
resource_value
.
getUid
())
node_uid
=
node_value
.
getUid
(),
resource_uid
=
resource_value
.
getUid
(),
self
.
_testGetInventory
(
valuation_method
=
'WeightedAverage'
expected
=
10
,
)
section_uid
=
C
.
getUid
(),
node_uid
=
X
.
getUid
(),
at_date
=
at_date
,
resource_uid
=
resource_value
.
getUid
())
at_date
=
DateTime
(
'2013/02/25 00:00:00 GMT+9'
)
self
.
_testGetInventory
(
expected
=
0
,
section_uid
=
A
.
getUid
(),
node_uid
=
Y
.
getUid
(),
at_date
=
at_date
,
resource_uid
=
resource_value
.
getUid
())
self
.
_testGetInventory
(
expected
=
76
,
section_uid
=
A
.
getUid
(),
node_uid
=
X
.
getUid
(),
at_date
=
at_date
,
resource_uid
=
resource_value
.
getUid
())
self
.
_testGetInventory
(
expected
=
19
,
section_uid
=
B
.
getUid
(),
node_uid
=
Y
.
getUid
(),
at_date
=
at_date
,
resource_uid
=
resource_value
.
getUid
())
def
test_21_CircularMovements
(
self
,
quite
=
0
,
run
=
run_all_test
):
self
.
_testGetInventory
(
expected
=
15
,
section_uid
=
C
.
getUid
(),
node_uid
=
X
.
getUid
(),
at_date
=
at_date
,
resource_uid
=
resource_value
.
getUid
())
def
test_20_InventoryWhenCancelPackingList
(
self
,
quite
=
0
,
run
=
run_all_test
):
"""
"""
Owner A, warehouse X, product G, quantity 10, total price is 1000
initial 2013/02/10 00:00:00 GMT+9:
Owner B, warehouse Y, product G, quantity 20, total price is 1100
A warehouse X, has product: Notvariated 100
Owner C, warehouse X, product G, quantity 0 , total price is 0
2013/02/11 00:00:00 GMT+9
IPL 1: A warehouse X ----> A warehouse Y, quantity: 3
Then, product G was moved like below:
2013/02/11 02:00:00 GMT+9
cancel IPL1
Owner A purchased 15 of product G for the price of 3000
2013/02/13 04:00:00 GMT+9
Owner A purchased 20 of product G for the price of 400
0
IPL 2: A warehouse X ----> A warehouse Y, quantity: 3
0
Owner B purchased 30 of product G from Owner A(price is determined at the end of Nov).
2013/02/14 04:00:00 GMT+9
Owner C purchased 10 of product G from Owner A(price is determined at the end of Nov).
SPL 1: A warehouse X ----> B warehouse Y, quantity: 30
Owner C get 5 of product G from Owner B(price is determined at the end of Nov).
Owner A get 2 of product G from Owner C(price is determined at the end of Nov).
2013/02/14 05:00:00 GMT+9
cancel IPL2
2013/02/11 04:00:00 GMT+9
PPL 1: A warehouse X ----> C warehouse X, quantity: 10
2013/02/14 06:00:00 GMT+9
cancel SPL1
2013/02/14 08:00:00 GMT+9
Production PL: A factory Z ---> A warehouse X, quantity: 10
2013/02/16 00:00:00 GMT+9
SPL 2: A warehouse X ----> B warehouse Y, quantity: 24
2013/02/24 00:00:00 GMT+9
PPL 2: B warehouse Y ----> C warehouse X, quantity: 5
2013/02/25 01:00:00 GMT+9
IPL 3: A warehouse X ----> A warehouse Y, quantity: 33
2013/02/25 02:00:00 GMT+9
cancel PPL 2
2013/02/26 00:00:00 GMT+9
PPL 3: B warehouse Y ----> C warehouse X, quantity: 10
As we see in this example, product G was moved between A and B, B and
C, C and A, it is circulating. Then, at the end of Mouth, Price of
product G of Owner A depends on price of product G of owner B, this
kind of thing happens. (And if it is a real circulation, price can't be
decided, it must not happen, but theoretically it can happen.
"""
"""
if
not
run
:
return
if
not
run
:
return
sequence_list
=
SequenceList
()
sequence_list
=
SequenceList
()
sequence_string
=
'CreateOrganisationsForModule
\
sequence_string
=
'CreateOrganisationsForModule
\
CreateOneMoreSection
\
CreateOneMoreSection
\
CreateFactory
\
CreateNotVariatedResource
\
CreateNotVariatedResource
\
Tic
\
Tic
\
CreateSalePackingListToA
\
InitialAWarehouseX
\
Tic
\
Tic
\
DeliverPackingList
\
DeliverPackingList
\
Tic
\
Tic
\
Create
PurchasePackingListForB
\
Create
IPLFromAWarehouseXToAWarehouseYWithQuantity3
\
Tic
\
Tic
\
DeliverPackingList
\
DeliverPackingList
\
Tic
\
Tic
\
CreatePurchasePackingListForASecond
\
CancelIPLFromAWarehouseXToAWarehouseYWithQuantity3
\
Tic
\
DeliverPackingList
\
DeliverPackingList
\
Tic
\
Tic
\
CreatePurchasePackingListForAThird
\
CreateIPLFromAWarehouseXToAWarehouseYWithQuantity30
\
Tic
\
DeliverPackingList
\
DeliverPackingList
\
Tic
\
Tic
\
CreateSalePackingListFromAToB
\
CreateSPLFromAWarehouseXToBWarehouseYWithQuantity30
\
Tic
\
DeliverPackingList
\
DeliverPackingList
\
Tic
\
Tic
\
CreatePurchasePackingListForCFromA
\
CancelIPLFromAWarehouseXToAWarehouseYWithQuantity30
\
Tic
\
DeliverPackingList
\
DeliverPackingList
\
Tic
\
Tic
\
CreatePurchasePackingListForCFromB
\
CreatePPLForCWarehouseXFromAWarehouseXWithQuantity10
\
Tic
\
DeliverPackingList
\
Tic
\
CancelSPLFromAWarehouseXToBWarehouseYWithQuantity30
\
Tic
\
DeliverPackingList
\
DeliverPackingList
\
Tic
\
Tic
\
CreateSalePackingListFromCToA
\
CreateProductionPFromAFactoryZToAWarehouseXWithQuantity10
\
Tic
\
DeliverProductionPackingList
\
Tic
\
CreateSPLFromAWarehouseXToBWarehouseYWithQuantity24
\
Tic
\
DeliverPackingList
\
DeliverPackingList
\
Tic
\
Tic
\
steptestCircularMovementQuantity
\
CreatePPLForCWarehouseXFromBWarehouseYWithQuantity5
\
Tic
\
DeliverPackingList
\
Tic
\
Tic
\
steptestCircularMovementPrice
\
CreateIPLFromAWarehouseXToAWarehouseYWithQuantity33
\
Tic
\
DeliverPackingList
\
Tic
\
CancelPPLForCWarehouseXFromBWarehouseYWithQuantity5
\
Tic
\
DeliverPackingList
\
Tic
\
CreatePPLForCWarehouseXFromBWarehouseYWithQuantity10
\
Tic
\
DeliverPackingList
\
Tic
\
TestMultiCancelInventory
\
'
'
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
sequence_list
.
play
(
self
)
...
...
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