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
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
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Paul Graydon
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
Show 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):
return
uid_cache
[
uid
]
except
KeyError
:
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
if
result_list
:
result
=
result_list
[
0
]
...
...
@@ -123,6 +123,12 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin):
return
node
.
title
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
):
node
=
self
.
getNodeValue
()
if
node
is
not
None
:
...
...
@@ -138,6 +144,12 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin):
return
resource
.
title
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
):
resource
=
self
.
getResourceValue
()
if
resource
is
not
None
:
...
...
@@ -147,7 +159,7 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin):
def
getResourceReference
(
self
):
resource
=
self
.
getResourceValue
()
if
resource
is
not
None
:
return
resource
.
getReference
()
return
resource
.
reference
resource_reference
=
ComputedAttribute
(
getResourceReference
,
1
)
def
getListItemUrl
(
self
,
cname_id
,
selection_index
,
selection_name
):
...
...
@@ -326,6 +338,21 @@ 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 @
4923ce56
...
...
@@ -1484,20 +1484,34 @@ class TestMovementHistoryList(InventoryAPITestCase):
self
.
assertTrue
(
hasattr
(
brain
,
'mirror_node_uid'
))
self
.
assertTrue
(
hasattr
(
brain
,
'mirror_section_uid'
))
# compatiblity names
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
testBrainGetItem
(
self
):
"""Test __getitem__ interface on brains."""
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