Commit 084adda5 authored by Jean-Paul Smets's avatar Jean-Paul Smets

improved handling of indexing


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@355 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9bed8678
...@@ -210,6 +210,7 @@ class Amount(Base, Variated): ...@@ -210,6 +210,7 @@ class Amount(Base, Variated):
""" """
Converts target_quantity to default unit Converts target_quantity to default unit
""" """
#if 1:
try: try:
#if 1: #if 1:
resource = self.getResourceValue() resource = self.getResourceValue()
...@@ -217,6 +218,7 @@ class Amount(Base, Variated): ...@@ -217,6 +218,7 @@ class Amount(Base, Variated):
quantity_unit = self.getQuantityUnit() quantity_unit = self.getQuantityUnit()
quantity = self.getTargetQuantity() quantity = self.getTargetQuantity()
converted_quantity = resource.convertQuantity(quantity, quantity_unit, resource_quantity_unit) converted_quantity = resource.convertQuantity(quantity, quantity_unit, resource_quantity_unit)
#else:
except: except:
#else: #else:
LOG("ERP5 WARNING:", 100, 'could not convert target_quantity for %s' % self.getRelativeUrl()) LOG("ERP5 WARNING:", 100, 'could not convert target_quantity for %s' % self.getRelativeUrl())
...@@ -242,7 +244,7 @@ class Amount(Base, Variated): ...@@ -242,7 +244,7 @@ class Amount(Base, Variated):
""" """
quantity = self.getQuantity() quantity = self.getQuantity()
efficiency = self.getEfficiency() efficiency = self.getEfficiency()
if efficiency in (0, 0.0, None): if efficiency in (0, 0.0, None, ''):
efficiency = 1.0 efficiency = 1.0
return float(quantity) / efficiency return float(quantity) / efficiency
...@@ -253,7 +255,7 @@ class Amount(Base, Variated): ...@@ -253,7 +255,7 @@ class Amount(Base, Variated):
""" """
quantity = self.getTargetQuantity() quantity = self.getTargetQuantity()
efficiency = self.getTargetEfficiency() efficiency = self.getTargetEfficiency()
if efficiency in (0, 0.0, None): if efficiency in (0, 0.0, None, ''):
efficiency = 1.0 efficiency = 1.0
return float(quantity) / efficiency return float(quantity) / efficiency
...@@ -264,9 +266,9 @@ class Amount(Base, Variated): ...@@ -264,9 +266,9 @@ class Amount(Base, Variated):
""" """
quantity = self.getConvertedQuantity() quantity = self.getConvertedQuantity()
efficiency = self.getEfficiency() efficiency = self.getEfficiency()
if efficiency in (0, 0.0, None): if efficiency in (0, 0.0, None, ''):
efficiency = 1.0 efficiency = 1.0
if quantity is not None: if quantity not in (None, ''):
return float(quantity) / efficiency return float(quantity) / efficiency
else: else:
return None return None
...@@ -277,10 +279,12 @@ class Amount(Base, Variated): ...@@ -277,10 +279,12 @@ class Amount(Base, Variated):
Take into account efficiency in converted quantity Take into account efficiency in converted quantity
""" """
efficiency = self.getEfficiency() efficiency = self.getEfficiency()
if efficiency in (0, 0.0, None): if efficiency in (0, 0.0, None, ''):
efficiency = 1.0 efficiency = 1.0
if value is not None: if value not in (None, ''):
quantity = float(value) * efficiency quantity = float(value) * efficiency
else:
quantity = value
self.setConvertedQuantity(quantity) self.setConvertedQuantity(quantity)
security.declareProtected(Permissions.AccessContentsInformation, 'getNetConvertedTargetQuantity') security.declareProtected(Permissions.AccessContentsInformation, 'getNetConvertedTargetQuantity')
...@@ -292,7 +296,7 @@ class Amount(Base, Variated): ...@@ -292,7 +296,7 @@ class Amount(Base, Variated):
efficiency = self.getTargetEfficiency() efficiency = self.getTargetEfficiency()
if efficiency in (0, 0.0, None): if efficiency in (0, 0.0, None):
efficiency = 1.0 efficiency = 1.0
if quantity is not None: if quantity not in (None, ''):
return float(quantity) / efficiency return float(quantity) / efficiency
else: else:
return None return None
...@@ -305,8 +309,10 @@ class Amount(Base, Variated): ...@@ -305,8 +309,10 @@ class Amount(Base, Variated):
efficiency = self.getEfficiency() efficiency = self.getEfficiency()
if efficiency in (0, 0.0, None): if efficiency in (0, 0.0, None):
efficiency = 1.0 efficiency = 1.0
if value is not None: if value not in (None, ''):
quantity = float(value) * efficiency quantity = float(value) * efficiency
else:
quantity = value
self.setConvertedTargetQuantity(quantity) self.setConvertedTargetQuantity(quantity)
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoriatedQuantity') security.declareProtected(Permissions.AccessContentsInformation, 'getInventoriatedQuantity')
......
...@@ -249,6 +249,7 @@ An ERP5 Rule...""" ...@@ -249,6 +249,7 @@ An ERP5 Rule..."""
Returns a list of indexable movements Returns a list of indexable movements
""" """
result = [ { 'uid' : self.getUid(), result = [ { 'uid' : self.getUid(),
'id' : self.getId(),
'portal_type' : self.getPortalType(), 'portal_type' : self.getPortalType(),
'url' : self.getUrl(), 'url' : self.getUrl(),
'relative_url' : self.getRelativeUrl(), 'relative_url' : self.getRelativeUrl(),
......
...@@ -305,6 +305,7 @@ a service in a public administration).""" ...@@ -305,6 +305,7 @@ a service in a public administration)."""
Returns a list of indexable movements Returns a list of indexable movements
""" """
result = [ { 'uid' : self.getUid(), result = [ { 'uid' : self.getUid(),
'id' : self.getId(),
'portal_type' : self.getPortalType(), 'portal_type' : self.getPortalType(),
'url' : self.getUrl(), 'url' : self.getUrl(),
'relative_url' : self.getRelativeUrl(), 'relative_url' : self.getRelativeUrl(),
...@@ -333,6 +334,8 @@ a service in a public administration).""" ...@@ -333,6 +334,8 @@ a service in a public administration)."""
'deliverable' : self.isDeliverable(), 'deliverable' : self.isDeliverable(),
'variation_text' : self.getVariationText(), 'variation_text' : self.getVariationText(),
'inventory' : self.getInventoriatedQuantity(), 'inventory' : self.getInventoriatedQuantity(),
'source_total_asset_price' : 0.0,
'destination_total_asset_price' : 0.0,
} ] } ]
for m in self.objectValues(): for m in self.objectValues():
result.extend(m.getMovementIndex()) result.extend(m.getMovementIndex())
......
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