Commit fd6bcf41 authored by Jérome Perrin's avatar Jérome Perrin

remove try: except: in getListItemUrl (it was always failing with...

remove try: except: in getListItemUrl (it was always failing with getMovementHistoryList, because Resource_zGetMovementList doesnot select resource_relative_url).
Instead, if the object is a movement, make a link to the explanation of this movement.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@12934 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent edc45d88
...@@ -160,70 +160,75 @@ class InventoryListBrain(ZSQLBrain): ...@@ -160,70 +160,75 @@ class InventoryListBrain(ZSQLBrain):
return '' return ''
def getListItemUrl(self, cname_id, selection_index, selection_name): def getListItemUrl(self, cname_id, selection_index, selection_name):
# XXX FIXME can catch to many exceptions """Returns the URL for column `cname_id`. Used by ListBox
try: """
if cname_id in ('getExplanationText', 'getExplanation', ): if cname_id in ('getExplanationText', 'getExplanation', ):
o = self.getObject() o = self.getObject()
if o is not None: if o is not None:
if not getattr(o, 'isDelivery', 0): if not getattr(o, 'isDelivery', 0):
explanation = o.getExplanationValue() explanation = o.getExplanationValue()
else:
# Additional inventory movements are catalogged in stock table
# with the inventory's uid. Then they are their own explanation.
explanation = o
if explanation is not None:
return '%s/%s/view' % (
self.portal_url.getPortalObject().absolute_url(),
explanation.getRelativeUrl())
else: else:
return '' # Additional inventory movements are catalogged in stock table
elif (self.resource_relative_url is not None): # with the inventory's uid. Then they are their own explanation.
# A resource is defined, so try to display the movement list explanation = o
resource = self.portal_categories.unrestrictedTraverse( if explanation is not None:
self.resource_relative_url) return '%s/%s/view' % (
form_name = 'Resource_viewMovementHistory' self.portal_url.getPortalObject().absolute_url(),
query_kw = { explanation.getRelativeUrl())
'variation_text': self.variation_text, else:
'selection_name': selection_name, return ''
'selection_index': selection_index, elif getattr(self, 'resource_relative_url', None) is not None:
'domain_name': selection_name, # A resource is defined, so try to display the movement list
resource = self.portal_categories.unrestrictedTraverse(
self.resource_relative_url)
form_name = 'Resource_viewMovementHistory'
query_kw = {
'variation_text': self.variation_text,
'selection_name': selection_name,
'selection_index': selection_index,
'domain_name': selection_name,
}
# Add parameters to query_kw
query_kw_update = {}
if cname_id in ('getCurrentInventory', ):
query_kw_update = {
'simulation_state': list(self.getPortalCurrentInventoryStateList())
} }
# Add parameters to query_kw elif cname_id in ('getAvailableInventory', ):
query_kw_update = {} query_kw_update = {
if cname_id in ('getCurrentInventory', ): 'simulation_state': \
query_kw_update = { list(self.getPortalReservedInventoryStateList()) + \
'simulation_state': list(self.getPortalCurrentInventoryStateList()) list(self.getPortalCurrentInventoryStateList())
} }
elif cname_id in ('getAvailableInventory', ): elif cname_id in ('getFutureInventory', 'inventory', ):
query_kw_update = { query_kw_update = {
'simulation_state': \ 'simulation_state': \
list(self.getPortalReservedInventoryStateList()) + \ list(self.getPortalFutureInventoryStateList()) + \
list(self.getPortalCurrentInventoryStateList()) list(self.getPortalReservedInventoryStateList()) + \
} list(self.getPortalCurrentInventoryStateList())
elif cname_id in ('getFutureInventory', 'inventory', ): }
query_kw_update = { elif cname_id in ('getInventoryAtDate', ):
'simulation_state': \ query_kw_update = {
list(self.getPortalFutureInventoryStateList()) + \ 'to_date': self.at_date,
list(self.getPortalReservedInventoryStateList()) + \ 'simulation_state': \
list(self.getPortalCurrentInventoryStateList()) list(self.getPortalFutureInventoryStateList()) + \
} list(self.getPortalReservedInventoryStateList())
elif cname_id in ('getInventoryAtDate', ): }
query_kw_update = { query_kw.update(query_kw_update)
'to_date': self.at_date, return '%s/%s?%s&reset=1' % ( resource.absolute_url(),
'simulation_state': \ form_name,
list(self.getPortalFutureInventoryStateList()) + \ make_query(**query_kw) )
list(self.getPortalReservedInventoryStateList())
} # default case, if it's a movement, return link to the explanation of this
query_kw.update(query_kw_update) # movement.
# Return result o = self.getObject()
return '%s/%s?%s&reset=1' % ( if getattr(o, 'isMovement', 0):
resource.absolute_url(), explanation = o.getExplanationValue()
form_name, if explanation is not None:
make_query(**query_kw)) return '%s/%s/view' % (
except (AttributeError, KeyError), e: self.portal_url.getPortalObject().absolute_url(),
LOG('InventoryListBrain', PROBLEM, explanation.getRelativeUrl())
'exception caught in getListItemUrl', e) return ''
return ''
def getAggregateListText(self): def getAggregateListText(self):
aggregate_list = self.Resource_zGetAggregateList( aggregate_list = self.Resource_zGetAggregateList(
......
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