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
Douglas
erp5
Commits
4923ce56
Commit
4923ce56
authored
Dec 31, 2014
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inventory API: expose more brain properties
parent
8e7737c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
3 deletions
+44
-3
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.InventoryBrain.py
...teItem/portal_components/extension.erp5.InventoryBrain.py
+29
-2
product/ERP5/tests/testInventoryAPI.py
product/ERP5/tests/testInventoryAPI.py
+15
-1
No files found.
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.InventoryBrain.py
View file @
4923ce56
...
@@ -92,7 +92,7 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin):
...
@@ -92,7 +92,7 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin):
return
uid_cache
[
uid
]
return
uid_cache
[
uid
]
except
KeyError
:
except
KeyError
:
result_list
=
self
.
portal_catalog
.
unrestrictedSearchResults
(
uid
=
uid
,
limit
=
1
,
result_list
=
self
.
portal_catalog
.
unrestrictedSearchResults
(
uid
=
uid
,
limit
=
1
,
select_dict
=
dict
(
title
=
None
,
relative_url
=
None
))
select_dict
=
dict
(
title
=
None
,
relative_url
=
None
,
reference
=
None
))
result
=
None
result
=
None
if
result_list
:
if
result_list
:
result
=
result_list
[
0
]
result
=
result_list
[
0
]
...
@@ -123,6 +123,12 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin):
...
@@ -123,6 +123,12 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin):
return
node
.
title
return
node
.
title
node_title
=
ComputedAttribute
(
getNodeTitle
,
1
)
node_title
=
ComputedAttribute
(
getNodeTitle
,
1
)
def
getNodeTranslatedTitle
(
self
):
node
=
self
.
getNodeValue
()
if
node
is
not
None
:
return
node
.
getObject
().
getTranslatedTitle
()
node_translated_title
=
ComputedAttribute
(
getNodeTranslatedTitle
,
1
)
def
getNodeRelativeUrl
(
self
):
def
getNodeRelativeUrl
(
self
):
node
=
self
.
getNodeValue
()
node
=
self
.
getNodeValue
()
if
node
is
not
None
:
if
node
is
not
None
:
...
@@ -138,6 +144,12 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin):
...
@@ -138,6 +144,12 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin):
return
resource
.
title
return
resource
.
title
resource_title
=
ComputedAttribute
(
getResourceTitle
,
1
)
resource_title
=
ComputedAttribute
(
getResourceTitle
,
1
)
def
getResourceTranslatedTitle
(
self
):
resource
=
self
.
getResourceValue
()
if
resource
is
not
None
:
return
resource
.
getObject
().
getTranslatedTitle
()
resource_translated_title
=
ComputedAttribute
(
getResourceTranslatedTitle
,
1
)
def
getResourceRelativeUrl
(
self
):
def
getResourceRelativeUrl
(
self
):
resource
=
self
.
getResourceValue
()
resource
=
self
.
getResourceValue
()
if
resource
is
not
None
:
if
resource
is
not
None
:
...
@@ -147,7 +159,7 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin):
...
@@ -147,7 +159,7 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin):
def
getResourceReference
(
self
):
def
getResourceReference
(
self
):
resource
=
self
.
getResourceValue
()
resource
=
self
.
getResourceValue
()
if
resource
is
not
None
:
if
resource
is
not
None
:
return
resource
.
getReference
()
return
resource
.
reference
resource_reference
=
ComputedAttribute
(
getResourceReference
,
1
)
resource_reference
=
ComputedAttribute
(
getResourceReference
,
1
)
def
getListItemUrl
(
self
,
cname_id
,
selection_index
,
selection_name
):
def
getListItemUrl
(
self
,
cname_id
,
selection_index
,
selection_name
):
...
@@ -326,6 +338,21 @@ class MovementHistoryListBrain(InventoryListBrain):
...
@@ -326,6 +338,21 @@ class MovementHistoryListBrain(InventoryListBrain):
return
explanation
.
absolute_url
()
return
explanation
.
absolute_url
()
return
''
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
):
def
_debit
(
self
):
if
self
.
is_cancellation
:
if
self
.
is_cancellation
:
return
min
(
self
.
total_quantity
,
0
)
return
min
(
self
.
total_quantity
,
0
)
...
...
product/ERP5/tests/testInventoryAPI.py
View file @
4923ce56
...
@@ -1484,20 +1484,34 @@ class TestMovementHistoryList(InventoryAPITestCase):
...
@@ -1484,20 +1484,34 @@ class TestMovementHistoryList(InventoryAPITestCase):
self
.
assertTrue
(
hasattr
(
brain
,
'mirror_node_uid'
))
self
.
assertTrue
(
hasattr
(
brain
,
'mirror_node_uid'
))
self
.
assertTrue
(
hasattr
(
brain
,
'mirror_section_uid'
))
self
.
assertTrue
(
hasattr
(
brain
,
'mirror_section_uid'
))
# compatiblity names
self
.
assertTrue
(
hasattr
(
brain
,
'section_title'
))
self
.
assertTrue
(
hasattr
(
brain
,
'section_title'
))
self
.
assertEqual
(
brain
.
section_title
,
self
.
section
.
getTitle
())
self
.
assertEqual
(
brain
.
section_title
,
self
.
section
.
getTitle
())
self
.
assertTrue
(
hasattr
(
brain
,
'section_relative_url'
))
self
.
assertTrue
(
hasattr
(
brain
,
'section_relative_url'
))
self
.
assertEqual
(
brain
.
section_relative_url
,
self
.
section
.
getRelativeUrl
())
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
.
assertTrue
(
hasattr
(
brain
,
'node_title'
))
self
.
assertEqual
(
brain
.
node_title
,
self
.
node
.
getTitle
())
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
.
assertTrue
(
hasattr
(
brain
,
'node_relative_url'
))
self
.
assertEqual
(
brain
.
node_relative_url
,
self
.
node
.
getRelativeUrl
())
self
.
assertEqual
(
brain
.
node_relative_url
,
self
.
node
.
getRelativeUrl
())
self
.
assertTrue
(
hasattr
(
brain
,
'resource_title'
))
self
.
assertTrue
(
hasattr
(
brain
,
'resource_title'
))
self
.
assertEqual
(
brain
.
resource_title
,
self
.
resource
.
getTitle
())
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
.
assertTrue
(
hasattr
(
brain
,
'resource_relative_url'
))
self
.
assertEqual
(
brain
.
resource_relative_url
,
self
.
resource
.
getRelativeUrl
())
self
.
assertEqual
(
brain
.
resource_relative_url
,
self
.
resource
.
getRelativeUrl
())
def
testBrainGetItem
(
self
):
def
testBrainGetItem
(
self
):
"""Test __getitem__ interface on brains."""
"""Test __getitem__ interface on brains."""
getMovementHistoryList
=
self
.
getSimulationTool
().
getMovementHistoryList
getMovementHistoryList
=
self
.
getSimulationTool
().
getMovementHistoryList
...
...
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