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
Laurent S
erp5
Commits
39ad1e16
Commit
39ad1e16
authored
Apr 12, 2018
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_core]: Add function to get item parameter dict in InventoryBrain to be used to create URL
parent
4267ba77
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
58 deletions
+97
-58
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.InventoryBrain.py
...teItem/portal_components/extension.erp5.InventoryBrain.py
+97
-58
No files found.
product/ERP5/bootstrap/erp5_core/ExtensionTemplateItem/portal_components/extension.erp5.InventoryBrain.py
View file @
39ad1e16
...
@@ -173,6 +173,75 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin):
...
@@ -173,6 +173,75 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin):
return
resource
.
reference
return
resource
.
reference
resource_reference
=
ComputedAttribute
(
getResourceReference
,
1
)
resource_reference
=
ComputedAttribute
(
getResourceReference
,
1
)
def
getListItemParamDict
(
self
,
cname_id
,
selection_index
,
selection_name
):
query_kw
=
{
'variation_text'
:
self
.
variation_text
,
'selection_name'
:
selection_name
,
'selection_index'
:
selection_index
,
'domain_name'
:
selection_name
,
'node_uid'
:
self
.
node_uid
}
query_kw_update
=
{}
if
cname_id
==
'getCurrentInventory'
:
query_kw_update
=
{
'simulation_state'
:
list
(
self
.
getPortalCurrentInventoryStateList
()
+
\
self
.
getPortalTransitInventoryStateList
()),
'omit_transit'
:
1
,
'transit_simulation_state'
:
list
(
self
.
getPortalTransitInventoryStateList
())
}
elif
cname_id
==
'getAvailableInventory'
:
query_kw_update
=
{
'simulation_state'
:
list
(
self
.
getPortalCurrentInventoryStateList
()
+
\
self
.
getPortalTransitInventoryStateList
()),
'omit_transit'
:
1
,
'transit_simulation_state'
:
list
(
self
.
getPortalTransitInventoryStateList
()),
'reserved_kw'
:
{
'simulation_state'
:
list
(
self
.
getPortalReservedInventoryStateList
()),
'transit_simulation_state'
:
list
(
self
.
getPortalTransitInventoryStateList
()),
'omit_input'
:
1
}
}
elif
cname_id
in
(
'getFutureInventory'
,
'inventory'
,
):
query_kw_update
=
{
'simulation_state'
:
\
list
(
self
.
getPortalFutureInventoryStateList
())
+
\
list
(
self
.
getPortalTransitInventoryStateList
())
+
\
list
(
self
.
getPortalReservedInventoryStateList
())
+
\
list
(
self
.
getPortalCurrentInventoryStateList
())
}
elif
cname_id
==
'getInventoryAtDate'
:
query_kw_update
=
{
'to_date'
:
self
.
at_date
,
'simulation_state'
:
\
list
(
self
.
getPortalFutureInventoryStateList
())
+
\
list
(
self
.
getPortalReservedInventoryStateList
())
}
query_kw
.
update
(
query_kw_update
)
return
query_kw
def
getListItemUrlDict
(
self
,
cname_id
,
selection_index
,
selection_name
):
"""
Returns url result dict for Inventory
"""
jio_key
=
self
.
getResourceValue
().
getRelativeUrl
()
return
{
'command'
:
'push_history'
,
'view_kw'
:
{
'view'
:
'view_movement_history'
,
'jio_key'
:
jio_key
,
'extra_param_json'
:
self
.
getListItemParamDict
(
cname_id
,
selection_index
,
selection_name
)
},
'options'
:
{
'jio_key'
:
jio_key
}
}
def
getListItemUrl
(
self
,
cname_id
,
selection_index
,
selection_name
):
def
getListItemUrl
(
self
,
cname_id
,
selection_index
,
selection_name
):
"""Returns the URL for column `cname_id`. Used by ListBox
"""Returns the URL for column `cname_id`. Used by ListBox
"""
"""
...
@@ -190,61 +259,17 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin):
...
@@ -190,61 +259,17 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin):
return
explanation
.
absolute_url
()
return
explanation
.
absolute_url
()
return
''
return
''
elif
resource
is
not
None
:
elif
resource
is
not
None
:
# A resource is defined, so try to display the movement list
form_id
=
'Resource_viewMovementHistory'
query_kw
=
{
'variation_text'
:
self
.
variation_text
,
'selection_name'
:
selection_name
,
'selection_index'
:
selection_index
,
'domain_name'
:
selection_name
,
"node_uid"
:
self
.
node_uid
}
# Add parameters to query_kw
query_kw_update
=
{}
if
cname_id
in
(
'transformed_resource_title'
,
):
if
cname_id
in
(
'transformed_resource_title'
,
):
return
resource
.
absolute_url
()
return
resource
.
absolute_url
()
elif
cname_id
in
(
'getCurrentInventory'
,
):
# A resource is defined, so try to display the movement list
query_kw_update
=
{
form_id
=
'Resource_viewMovementHistory'
'simulation_state'
:
query_kw
=
self
.
getListItemParamDict
(
cname_id
,
list
(
self
.
getPortalCurrentInventoryStateList
()
+
\
selection_index
,
self
.
getPortalTransitInventoryStateList
()),
selection_name
'omit_transit'
:
1
,
)
'transit_simulation_state'
:
list
(
return
'%s/%s?%s&reset=1'
%
(
resource
.
absolute_url
(),
self
.
getPortalTransitInventoryStateList
())
form_id
,
}
make_query
(
**
query_kw
))
elif
cname_id
in
(
'getAvailableInventory'
,
):
query_kw_update
=
{
'simulation_state'
:
list
(
self
.
getPortalCurrentInventoryStateList
()
+
\
self
.
getPortalTransitInventoryStateList
()),
'omit_transit'
:
1
,
'transit_simulation_state'
:
list
(
self
.
getPortalTransitInventoryStateList
()),
'reserved_kw'
:
{
'simulation_state'
:
list
(
self
.
getPortalReservedInventoryStateList
()),
'transit_simulation_state'
:
list
(
self
.
getPortalTransitInventoryStateList
()),
'omit_input'
:
1
}
}
elif
cname_id
in
(
'getFutureInventory'
,
'inventory'
,
):
query_kw_update
=
{
'simulation_state'
:
\
list
(
self
.
getPortalFutureInventoryStateList
())
+
\
list
(
self
.
getPortalTransitInventoryStateList
())
+
\
list
(
self
.
getPortalReservedInventoryStateList
())
+
\
list
(
self
.
getPortalCurrentInventoryStateList
())
}
elif
cname_id
in
(
'getInventoryAtDate'
,
):
query_kw_update
=
{
'to_date'
:
self
.
at_date
,
'simulation_state'
:
\
list
(
self
.
getPortalFutureInventoryStateList
())
+
\
list
(
self
.
getPortalReservedInventoryStateList
())
}
query_kw
.
update
(
query_kw_update
)
return
'%s/%s?%s&reset=1'
%
(
resource
.
absolute_url
(),
form_id
,
make_query
(
**
query_kw
)
)
# default case, if it's a movement, return link to the explanation of this
# default case, if it's a movement, return link to the explanation of this
# movement.
# movement.
...
@@ -341,15 +366,29 @@ class MovementHistoryListBrain(InventoryListBrain):
...
@@ -341,15 +366,29 @@ class MovementHistoryListBrain(InventoryListBrain):
return
self
.
_convertDateToZone
(
self
.
date_utc
)
return
self
.
_convertDateToZone
(
self
.
date_utc
)
date
=
ComputedAttribute
(
_date
,
1
)
date
=
ComputedAttribute
(
_date
,
1
)
def
getListItem
(
self
,
cname_id
,
selection_index
,
selection_name
):
document
=
self
.
getObject
()
if
document
.
isMovement
():
return
document
.
getExplanationValue
()
def
getListItemUrlDict
(
self
,
cname_id
,
selection_index
,
selection_name
):
return
{
'command'
:
'push_history'
,
'options'
:
{
'jio_key'
:
self
.
getListItem
(
cname_id
,
selection_index
,
selection_name
).
getRelativeUrl
(),
'view'
:
'view'
}
}
def
getListItemUrl
(
self
,
cname_id
,
selection_index
,
selection_name
):
def
getListItemUrl
(
self
,
cname_id
,
selection_index
,
selection_name
):
"""Returns the URL for column `cname_id`. Used by ListBox
"""Returns the URL for column `cname_id`. Used by ListBox
Here we just want a link to the explanation of movement.
Here we just want a link to the explanation of movement.
"""
"""
document
=
self
.
getObject
()
item
=
self
.
getListItem
(
cname_id
,
selection_index
,
selection_name
)
if
document
.
isMovement
():
if
item
is
not
None
:
explanation
=
document
.
getExplanationValue
()
return
item
.
absolute_url
()
if
explanation
is
not
None
:
return
explanation
.
absolute_url
()
return
''
return
''
def
_debit
(
self
):
def
_debit
(
self
):
...
...
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