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
Labels
Merge Requests
138
Merge Requests
138
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
Jobs
Commits
Open sidebar
nexedi
erp5
Commits
d6d958be
Commit
d6d958be
authored
Jul 05, 2024
by
Jérome Perrin
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: handle price 0 or None in Inventory API
parent
8ba71199
Pipeline
#35799
failed with stage
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
4 deletions
+30
-4
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.Movement.py
...tTemplateItem/portal_components/document.erp5.Movement.py
+3
-3
product/ERP5/tests/testInventoryAPI.py
product/ERP5/tests/testInventoryAPI.py
+27
-1
No files found.
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.Movement.py
View file @
d6d958be
...
...
@@ -422,7 +422,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
quantity
=
self
.
getQuantity
()
if
quantity
:
source_asset_price
=
self
.
getSourceAssetPrice
()
if
source_asset_price
:
if
source_asset_price
is
not
None
:
return
source_asset_price
*
-
quantity
return
None
...
...
@@ -466,7 +466,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
quantity
=
self
.
getQuantity
()
if
quantity
:
destination_asset_price
=
self
.
getDestinationAssetPrice
()
if
destination_asset_price
:
if
destination_asset_price
is
not
None
:
return
destination_asset_price
*
quantity
return
None
...
...
@@ -520,7 +520,7 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
def
_getAssetPrice
(
self
,
section
,
date
):
price
=
self
.
getPrice
()
if
section
is
None
or
not
pric
e
or
getattr
(
if
section
is
None
or
price
is
Non
e
or
getattr
(
section
.
aq_base
,
'getPriceCurrencyValue'
,
None
)
is
None
:
return
price
...
...
product/ERP5/tests/testInventoryAPI.py
View file @
d6d958be
...
...
@@ -1715,7 +1715,7 @@ class TestMovementHistoryList(InventoryAPITestCase):
# default is an empty list
self
.
assertEqual
(
0
,
len
(
mvt_history_list
))
def
testDefault
0
(
self
):
def
testDefault
None
(
self
):
self
.
_makeMovement
()
getMovementHistoryList
=
self
.
getSimulationTool
().
getMovementHistoryList
mvt_history_list
=
getMovementHistoryList
(
...
...
@@ -1725,6 +1725,32 @@ class TestMovementHistoryList(InventoryAPITestCase):
# If a movement have no price, None is returned
self
.
assertEqual
(
None
,
mvt_history_list
[
0
].
total_price
)
def
testPriceZero
(
self
):
self
.
_makeMovement
(
quantity
=
1
,
price
=
0
)
getMovementHistoryList
=
self
.
getSimulationTool
().
getMovementHistoryList
self
.
assertEqual
(
[(
b
.
total_quantity
,
b
.
total_price
)
for
b
in
getMovementHistoryList
(
section_uid
=
self
.
section
.
getUid
())],
[(
1
,
0
),
]
)
self
.
assertEqual
(
[(
b
.
total_quantity
,
b
.
total_price
)
for
b
in
getMovementHistoryList
(
section_uid
=
self
.
mirror_section
.
getUid
())],
[(
-
1
,
0
),
]
)
def
testPriceNone
(
self
):
self
.
_makeMovement
(
quantity
=
1
,
price
=
None
)
getMovementHistoryList
=
self
.
getSimulationTool
().
getMovementHistoryList
mvt_history_list
=
getMovementHistoryList
(
section_uid
=
self
.
section
.
getUid
(),)
self
.
assertEqual
(
[(
b
.
total_quantity
,
b
.
total_price
)
for
b
in
getMovementHistoryList
(
section_uid
=
self
.
section
.
getUid
())],
[(
1
,
None
),
]
)
self
.
assertEqual
(
[(
b
.
total_quantity
,
b
.
total_price
)
for
b
in
getMovementHistoryList
(
section_uid
=
self
.
mirror_section
.
getUid
())],
[(
-
1
,
None
),
]
)
def
testMovementBothSides
(
self
):
"""Movement History List returns movement from both sides"""
getMovementHistoryList
=
self
.
getSimulationTool
().
getMovementHistoryList
...
...
Jérome Perrin
@jerome
mentioned in merge request
!1974 (closed)
·
Jul 05, 2024
mentioned in merge request
!1974 (closed)
mentioned in merge request !1974
Toggle commit list
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