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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Romain Courteaud
erp5
Commits
5db52eee
Commit
5db52eee
authored
Apr 23, 2019
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Movement: Do not crash if section has no 'getPriceCurrency' attribute
/reviewed-on
nexedi/erp5!859
parent
7cc3d26d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
1 deletion
+29
-1
product/ERP5/Document/Movement.py
product/ERP5/Document/Movement.py
+3
-1
product/ERP5/tests/testInventoryAPI.py
product/ERP5/tests/testInventoryAPI.py
+26
-0
No files found.
product/ERP5/Document/Movement.py
View file @
5db52eee
...
...
@@ -516,7 +516,9 @@ class Movement(XMLObject, Amount, CompositionMixin, AmountGeneratorMixin):
def
_getAssetPrice
(
self
,
section
,
date
):
price
=
self
.
getPrice
()
if
section
is
None
or
not
price
:
if
section
is
None
or
not
price
or
getattr
(
section
.
aq_base
,
'getPriceCurrencyValue'
,
None
)
is
None
:
return
price
currency_value
=
self
.
getPriceCurrencyValue
()
if
currency_value
:
...
...
product/ERP5/tests/testInventoryAPI.py
View file @
5db52eee
...
...
@@ -1635,6 +1635,32 @@ class TestInventoryList(InventoryAPITestCase):
self
.
assertTrue
(
result
is
not
None
)
self
.
assertEqual
(
internal_data
[
cur
][
'after'
][
'total_price'
],
round
(
result
))
def
test_TotalPriceIndexationWhenSectionIsPerson
(
self
):
"""
Checks that when source_section or destination_section is Person
total_price is indexed correctly.
Added after a bug that caused bad indexation in such cases
"""
getInventoryList
=
self
.
getSimulationTool
().
getInventoryList
movement
=
self
.
_makeMovement
(
quantity
=
1
,
price
=
5
)
person_1
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
person_2
=
self
.
portal
.
person_module
.
newContent
(
portal_type
=
'Person'
)
currency
=
self
.
portal
.
currency_module
.
newContent
(
portal_type
=
'Currency'
)
movement
.
edit
(
source_section_value
=
person_1
,
destination_section_value
=
person_2
,
price_currency_value
=
currency
,
)
self
.
tic
()
inventory_list_1
=
getInventoryList
(
section_uid
=
person_1
.
getUid
())
self
.
assertEqual
(
len
(
inventory_list_1
),
1
)
self
.
assertEqual
(
inventory_list_1
[
0
].
total_price
,
-
5.0
)
inventory_list_2
=
getInventoryList
(
section_uid
=
person_2
.
getUid
())
self
.
assertEqual
(
len
(
inventory_list_2
),
1
)
self
.
assertEqual
(
inventory_list_2
[
0
].
total_price
,
5.0
)
class
TestMovementHistoryList
(
InventoryAPITestCase
):
"""Tests Movement history list methods.
"""
...
...
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