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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Xiaowu Zhang
erp5
Commits
cfa08898
Commit
cfa08898
authored
May 11, 2021
by
Xiaowu Zhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_trade: show calculation steps
parent
3b239e0f
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
226 additions
and
13 deletions
+226
-13
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/InventoryReportCell_getRelatedMovementUrl.py
...s/erp5_trade/InventoryReportCell_getRelatedMovementUrl.py
+2
-3
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/InventoryReportLine_createMovementHistoryCellList.py
...rade/InventoryReportLine_createMovementHistoryCellList.py
+13
-4
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/InventoryReportLine_createMovementHistoryCellList.xml
...ade/InventoryReportLine_createMovementHistoryCellList.xml
+8
-0
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/InventoryReportLine_view.xml
...Item/portal_skins/erp5_trade/InventoryReportLine_view.xml
+1
-0
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/InventoryReportLine_view/listbox_total_asset_price.xml
...de/InventoryReportLine_view/listbox_total_asset_price.xml
+109
-0
bt5/erp5_trade/TestTemplateItem/portal_components/test.erp5.testInventoryReportModule.py
.../portal_components/test.erp5.testInventoryReportModule.py
+69
-3
bt5/erp5_trade/TestTemplateItem/portal_components/test.erp5.testInventoryReportModule.xml
...portal_components/test.erp5.testInventoryReportModule.xml
+24
-3
No files found.
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/InventoryReportCell_getRelatedMovementUrl.py
View file @
cfa08898
if
url_dict
:
jio_key
=
'/'
.
join
(
context
.
movement_url
.
split
(
'/'
)[
-
2
:])
return
{
'command'
:
'push_history'
,
'options'
:
{
'jio_key'
:
jio_key
'jio_key'
:
context
.
movement_url
},
}
else
:
return
context
.
movement_url
return
"%s/%s"
%
(
context
.
getPortalObject
().
absolute_url
(),
context
.
movement_url
)
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/InventoryReportLine_createMovementHistoryCellList.py
View file @
cfa08898
...
...
@@ -8,7 +8,9 @@ getMovementHistoryList = portal.portal_simulation.getMovementHistoryList
current_date_kw
=
kw
.
copy
()
kw
.
pop
(
'valuation_method'
,
None
)
kw
[
'sort_on'
]
=
((
'date'
,
'ascending'
),)
kw
[
'sort_on'
]
=
((
'stock.date'
,
'ascending'
),)
kw
[
'simulation_state'
]
=
portal
.
getPortalCurrentInventoryStateList
()
+
portal
.
getPortalTransitInventoryStateList
()
movement_dict
=
OrderedDict
()
current_id
=
1
...
...
@@ -22,11 +24,18 @@ for date, value_list in movement_dict.iteritems():
same_date_length
=
len
(
value_list
)
for
index
in
range
(
same_date_length
):
if
index
<
same_date_length
-
1
:
current_date_kw
[
'uid'
]
=
NegatedQuery
(
SimpleQuery
(
uid
=
[
x
.
getUid
()
for
x
in
value_list
[
index
+
1
:]]))
exclude_uid_list
=
[
x
.
getUid
()
for
x
in
value_list
[
index
+
1
:]]
current_date_kw
[
'uid'
]
=
NegatedQuery
(
SimpleQuery
(
uid
=
exclude_uid_list
))
else
:
exclude_uid_list
=
[]
current_date_kw
.
pop
(
'uid'
,
None
)
total_asset_price
=
getCurrentInventoryAssetPrice
(
**
current_date_kw
)
movement
=
value_list
[
index
]
# same date internal order, calculate asset price later
if
movement
.
getUid
()
in
exclude_uid_list
:
total_asset_price
=
''
else
:
total_asset_price
=
getCurrentInventoryAssetPrice
(
**
current_date_kw
)
or
0
if
not
getattr
(
movement
,
'isDelivery'
,
0
):
explanation
=
movement
.
getExplanationValue
()
else
:
...
...
@@ -36,7 +45,7 @@ for date, value_list in movement_dict.iteritems():
id
=
format
(
current_id
,
'07d'
),
portal_type
=
'Inventory Report Cell'
,
date
=
movement
.
date
,
movement_url
=
explanation
.
absolute_u
rl
(),
movement_url
=
explanation
.
getRelativeU
rl
(),
explanation_text
=
movement
.
getExplanationText
(),
node_title
=
movement
.
node_title
,
section_title
=
movement
.
section_title
,
...
...
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/InventoryReportLine_createMovementHistoryCellList.xml
View file @
cfa08898
...
...
@@ -52,6 +52,14 @@
<key>
<string>
_params
</string>
</key>
<value>
<string>
**kw
</string>
</value>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<value>
<tuple>
<string>
Manager
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
InventoryReportLine_createMovementHistoryCellList
</string>
</value>
...
...
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/InventoryReportLine_view.xml
View file @
cfa08898
...
...
@@ -93,6 +93,7 @@
<list>
<string>
listbox_date
</string>
<string>
listbox_total_quantity
</string>
<string>
listbox_total_asset_price
</string>
</list>
</value>
</item>
...
...
bt5/erp5_trade/SkinTemplateItem/portal_skins/erp5_trade/InventoryReportLine_view/listbox_total_asset_price.xml
0 → 100644
View file @
cfa08898
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ProxyField"
module=
"Products.ERP5Form.ProxyField"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
delegated_list
</string>
</key>
<value>
<list>
<string>
default
</string>
<string>
title
</string>
</list>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
listbox_total_asset_price
</string>
</value>
</item>
<item>
<key>
<string>
message_values
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
external_validator_failed
</string>
</key>
<value>
<string>
The input failed the external validator.
</string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
overrides
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
target
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
tales
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
default
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
target
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key>
<string>
values
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
default
</string>
</key>
<value>
<string></string>
</value>
</item>
<item>
<key>
<string>
field_id
</string>
</key>
<value>
<string>
my_view_mode_total_price
</string>
</value>
</item>
<item>
<key>
<string>
form_id
</string>
</key>
<value>
<string>
Base_viewTradeFieldLibrary
</string>
</value>
</item>
<item>
<key>
<string>
target
</string>
</key>
<value>
<string>
Click to edit the target
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
Total Asset Price
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_trade/TestTemplateItem/portal_components/test.erp5.testInventoryReportModule.py
View file @
cfa08898
...
...
@@ -449,7 +449,7 @@ class TestInventoryReportModule(TestOrderMixin, SecurityTestCase):
pl
.
stop
()
pl
.
deliver
()
self
.
tic
()
def
stepSetResourceUnit
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
resource_list
=
sequence
.
get
(
'resource_list'
)
...
...
@@ -527,8 +527,8 @@ class TestInventoryReportModule(TestOrderMixin, SecurityTestCase):
self
.
assertEqual
(
inventory_report_line_list
[
3
].
total_asset_price
,
0
)
self
.
assertEqual
(
inventory_report_line_list
[
4
].
total_quantity
,
45
-
14
)
self
.
assertAlmostEqual
(
inventory_report_line_list
[
4
].
total_asset_price
,
(
45
-
14
)
*
80
*
0.13
)
inventory_report
=
self
.
getInventoryReportModule
().
newContent
(
portal_type
=
'Inventory Report'
)
inventory_report
.
edit
(
destination_value
=
sequence
.
get
(
'organisation_euro'
),
...
...
@@ -682,6 +682,45 @@ class TestInventoryReportModule(TestOrderMixin, SecurityTestCase):
self
.
assertAlmostEqual
(
inventory_report_line_list
[
4
].
total_asset_price
,
51
*
201
*
0.14
)
def
stepTestCalculateStep
(
self
,
sequence
=
None
,
sequence_list
=
None
,
**
kw
):
inventory_report
=
self
.
getInventoryReportModule
().
newContent
(
portal_type
=
'Inventory Report'
)
inventory_report
.
edit
(
destination_section_value
=
sequence
.
get
(
'organisation_euro'
),
valuation_method
=
'Fifo'
)
self
.
tic
()
inventory_report
.
InventoryReport_calculateProductStock
(
batch_mode
=
True
)
self
.
assertEqual
(
inventory_report
.
getSimulationState
(),
'calculating'
)
self
.
tic
()
self
.
assertEqual
(
inventory_report
.
getSimulationState
(),
'recorded'
)
self
.
tic
()
inventory_report_line_list
=
inventory_report
.
contentValues
(
portal_type
=
'Inventory Report Line'
)
self
.
assertEqual
(
len
(
inventory_report_line_list
),
1
)
inventory_report_line
=
inventory_report_line_list
[
0
]
inventory_report_cell_list
=
inventory_report_line
.
contentValues
(
portal_type
=
'Inventory Report Cell'
)
self
.
assertEqual
(
len
(
inventory_report_cell_list
),
5
)
inventory_report_cell_list
.
sort
(
key
=
lambda
x
:
x
.
id
)
self
.
assertEqual
(
inventory_report_cell_list
[
0
].
total_asset_price
,
832
)
self
.
assertEqual
(
inventory_report_cell_list
[
1
].
total_asset_price
,
1664
)
self
.
assertEqual
(
inventory_report_cell_list
[
2
].
total_asset_price
,
1144
)
self
.
assertEqual
(
inventory_report_cell_list
[
3
].
total_asset_price
,
''
)
self
.
assertEqual
(
inventory_report_cell_list
[
4
].
total_asset_price
,
1222.40
)
self
.
assertEqual
(
inventory_report_cell_list
[
0
].
running_total_quantity
,
80
)
self
.
assertEqual
(
inventory_report_cell_list
[
1
].
running_total_quantity
,
160
)
self
.
assertEqual
(
inventory_report_cell_list
[
2
].
running_total_quantity
,
110
)
self
.
assertTrue
(
inventory_report_cell_list
[
3
].
running_total_quantity
in
[
124
,
96
])
self
.
assertEqual
(
inventory_report_cell_list
[
4
].
running_total_quantity
,
110
)
self
.
assertEqual
(
inventory_report_cell_list
[
0
].
total_quantity
,
80
)
self
.
assertEqual
(
inventory_report_cell_list
[
1
].
total_quantity
,
80
)
self
.
assertEqual
(
inventory_report_cell_list
[
2
].
total_quantity
,
-
50
)
self
.
assertTrue
(
inventory_report_cell_list
[
3
].
total_quantity
in
[
-
14
,
14
])
self
.
assertTrue
(
inventory_report_cell_list
[
4
].
total_quantity
in
[
-
14
,
14
])
def
test_01_workflowAndAccessPermission
(
self
,
run
=
run_all_test
):
"""
"""
...
...
@@ -854,6 +893,33 @@ class TestInventoryReportModule(TestOrderMixin, SecurityTestCase):
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
test_03_checkCalculateStep
(
self
,
run
=
run_all_test
):
if
not
run
:
return
sequence_list
=
SequenceList
()
sequence_string
=
'CreateNotVariatedResource
\
stepCreateThreeCurrencys
\
stepSetResourceUnit
\
stepCreateThreeOrganisations
\
stepCreateTwoWarehouse
\
stepTic
\
stepCreatePurchasePackingListFromRMBToEURO
\
stepDeliverPackingList
\
stepTic
\
stepCreatePurchasePackingListFromRMBToEURO
\
stepDeliverPackingList
\
stepTic
\
stepCreateSalesPackingListEUROToUSD
\
stepDeliverPackingList
\
stepTic
\
stepCreateInternalPackingListFromEUROWarehouseEuroToEuroWarehouseB
\
stepDeliverPackingList
\
stepTic
\
stepTestCalculateStep
\
'
sequence_list
.
addSequenceString
(
sequence_string
)
sequence_list
.
play
(
self
)
def
_test_suite
():
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestInventoryReportModule
))
...
...
bt5/erp5_trade/TestTemplateItem/portal_components/test.erp5.testInventoryReportModule.xml
View file @
cfa08898
...
...
@@ -6,6 +6,12 @@
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testInventoryReportModule
</string>
</value>
...
...
@@ -53,13 +59,28 @@
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
I
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
...
...
@@ -72,7 +93,7 @@
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
M
=
</string>
</persistent>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAA
Q
=
</string>
</persistent>
</value>
</item>
</dictionary>
...
...
@@ -81,7 +102,7 @@
</dictionary>
</pickle>
</record>
<record
id=
"
3"
aka=
"AAAAAAAAAAM
="
>
<record
id=
"
4"
aka=
"AAAAAAAAAAQ
="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
...
...
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