Commit 6af84365 authored by Xiaowu Zhang's avatar Xiaowu Zhang Committed by Ayush Tiwari

erp5_core: add method to get url parameter

parent ac01cf72
...@@ -173,6 +173,55 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin): ...@@ -173,6 +173,55 @@ 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 in ('getCurrentInventory', ):
query_kw_update = {
'simulation_state':
list(self.getPortalCurrentInventoryStateList() + \
self.getPortalTransitInventoryStateList()),
'omit_transit': 1,
'transit_simulation_state': list(
self.getPortalTransitInventoryStateList())
}
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 query_kw
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,58 +239,11 @@ class InventoryListBrain(ComputedAttributeGetItemCompatibleMixin): ...@@ -190,58 +239,11 @@ 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, selection_index, selection_name)
list(self.getPortalCurrentInventoryStateList() + \
self.getPortalTransitInventoryStateList()),
'omit_transit': 1,
'transit_simulation_state': list(
self.getPortalTransitInventoryStateList())
}
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(), return '%s/%s?%s&reset=1' % ( resource.absolute_url(),
form_id, form_id,
make_query(**query_kw) ) make_query(**query_kw) )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment