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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Łukasz Nowak
erp5
Commits
93206c4a
Commit
93206c4a
authored
Feb 02, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
InventoryAPI: Add mirror_section_* brain attributes on InventoryListBrain
parent
0bee523d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
16 deletions
+71
-16
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.InventoryBrain.py
...teItem/portal_components/extension.erp5.InventoryBrain.py
+15
-15
product/ERP5/tests/testInventoryAPI.py
product/ERP5/tests/testInventoryAPI.py
+56
-1
No files found.
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.InventoryBrain.py
View file @
93206c4a
...
...
@@ -114,6 +114,21 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin):
return
section
.
relative_url
section_relative_url
=
ComputedAttribute
(
getSectionRelativeUrl
,
1
)
def
getMirrorSectionValue
(
self
):
return
self
.
_getObjectByUid
(
self
.
mirror_section_uid
)
def
getMirrorSectionTitle
(
self
):
mirror_section
=
self
.
getMirrorSectionValue
()
if
mirror_section
is
not
None
:
return
mirror_section
.
title
mirror_section_title
=
ComputedAttribute
(
getMirrorSectionTitle
,
1
)
def
getMirrorSectionRelativeUrl
(
self
):
mirror_section
=
self
.
getMirrorSectionValue
()
if
mirror_section
is
not
None
:
return
mirror_section
.
relative_url
mirror_section_relative_url
=
ComputedAttribute
(
getMirrorSectionRelativeUrl
,
1
)
def
getNodeValue
(
self
):
return
self
.
_getObjectByUid
(
self
.
node_uid
)
...
...
@@ -338,21 +353,6 @@ class MovementHistoryListBrain(InventoryListBrain):
return
explanation
.
absolute_url
()
return
''
def
getMirrorSectionValue
(
self
):
return
self
.
_getObjectByUid
(
self
.
mirror_section_uid
)
def
getMirrorSectionTitle
(
self
):
mirror_section
=
self
.
getMirrorSectionValue
()
if
mirror_section
is
not
None
:
return
mirror_section
.
title
mirror_section_title
=
ComputedAttribute
(
getMirrorSectionTitle
,
1
)
def
getMirrorSectionRelativeUrl
(
self
):
mirror_section
=
self
.
getMirrorSectionValue
()
if
mirror_section
is
not
None
:
return
mirror_section
.
relative_url
mirror_section_relative_url
=
ComputedAttribute
(
getMirrorSectionRelativeUrl
,
1
)
def
_debit
(
self
):
if
self
.
is_cancellation
:
return
min
(
self
.
total_quantity
,
0
)
...
...
product/ERP5/tests/testInventoryAPI.py
View file @
93206c4a
...
...
@@ -840,6 +840,61 @@ class TestInventoryList(InventoryAPITestCase):
# The total price of grouped movements without price is 0
self
.
assertEqual
(
0
,
inventory_list
[
0
].
total_price
)
def
testBrainClass
(
self
):
"""Inventory List uses InventoryListBrain for brains"""
getInventoryList
=
self
.
getSimulationTool
().
getInventoryList
self
.
_makeMovement
(
quantity
=
100
)
# maybe this check is too low level (Shared/DC/ZRDB//Results.py, class r)
r_bases
=
getInventoryList
().
_class
.
__bases__
brain_class
=
r_bases
[
2
].
__name__
self
.
assertEqual
(
'InventoryListBrain'
,
brain_class
,
"unexpected brain class for InventoryListBrain"
" != %s (bases %s)"
%
(
brain_class
,
r_bases
))
def
testBrainAttribute
(
self
):
"""Test attributes exposed on brains."""
getInventoryList
=
self
.
getSimulationTool
().
getInventoryList
self
.
_makeMovement
(
quantity
=
100
)
brain
=
getInventoryList
(
section_uid
=
self
.
section
.
getUid
())[
0
]
self
.
assertTrue
(
hasattr
(
brain
,
'node_uid'
))
self
.
assertTrue
(
hasattr
(
brain
,
'resource_uid'
))
self
.
assertTrue
(
hasattr
(
brain
,
'section_uid'
))
self
.
assertTrue
(
hasattr
(
brain
,
'date'
))
self
.
assertTrue
(
hasattr
(
brain
,
'function_uid'
))
self
.
assertTrue
(
hasattr
(
brain
,
'payment_uid'
))
self
.
assertTrue
(
hasattr
(
brain
,
'project_uid'
))
self
.
assertTrue
(
hasattr
(
brain
,
'funding_uid'
))
self
.
assertTrue
(
hasattr
(
brain
,
'mirror_node_uid'
))
self
.
assertTrue
(
hasattr
(
brain
,
'mirror_section_uid'
))
self
.
assertTrue
(
hasattr
(
brain
,
'section_title'
))
self
.
assertEqual
(
brain
.
section_title
,
self
.
section
.
getTitle
())
self
.
assertTrue
(
hasattr
(
brain
,
'section_relative_url'
))
self
.
assertEqual
(
brain
.
section_relative_url
,
self
.
section
.
getRelativeUrl
())
self
.
assertTrue
(
hasattr
(
brain
,
'mirror_section_title'
))
self
.
assertEqual
(
brain
.
mirror_section_title
,
self
.
mirror_section
.
getTitle
())
self
.
assertTrue
(
hasattr
(
brain
,
'mirror_section_relative_url'
))
self
.
assertEqual
(
brain
.
mirror_section_relative_url
,
self
.
mirror_section
.
getRelativeUrl
())
self
.
assertTrue
(
hasattr
(
brain
,
'node_title'
))
self
.
assertEqual
(
brain
.
node_title
,
self
.
node
.
getTitle
())
self
.
assertTrue
(
hasattr
(
brain
,
'node_translated_title'
))
self
.
assertEqual
(
brain
.
node_title
,
self
.
node
.
getTranslatedTitle
())
self
.
assertTrue
(
hasattr
(
brain
,
'node_relative_url'
))
self
.
assertEqual
(
brain
.
node_relative_url
,
self
.
node
.
getRelativeUrl
())
self
.
assertTrue
(
hasattr
(
brain
,
'resource_title'
))
self
.
assertEqual
(
brain
.
resource_title
,
self
.
resource
.
getTitle
())
self
.
assertTrue
(
hasattr
(
brain
,
'resource_translated_title'
))
self
.
assertEqual
(
brain
.
resource_title
,
self
.
resource
.
getTranslatedTitle
())
self
.
assertTrue
(
hasattr
(
brain
,
'resource_reference'
))
self
.
assertEqual
(
brain
.
resource_reference
,
self
.
resource
.
getReference
())
self
.
assertTrue
(
hasattr
(
brain
,
'resource_relative_url'
))
self
.
assertEqual
(
brain
.
resource_relative_url
,
self
.
resource
.
getRelativeUrl
())
def
test_GroupByNode
(
self
):
getInventoryList
=
self
.
getSimulationTool
().
getInventoryList
self
.
_makeMovement
(
quantity
=
100
)
...
...
@@ -1458,7 +1513,7 @@ class TestMovementHistoryList(InventoryAPITestCase):
self
.
assertEqual
(
2
,
len
(
getMovementHistoryList
()))
def
testBrainClass
(
self
):
"""Movement History List uses
Inven
toryListBrain for brains"""
"""Movement History List uses
MovementHis
toryListBrain for brains"""
getMovementHistoryList
=
self
.
getSimulationTool
().
getMovementHistoryList
self
.
_makeMovement
(
quantity
=
100
)
# maybe this check is too low level (Shared/DC/ZRDB//Results.py, class r)
...
...
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