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):
"""
Converts target_quantity to default unit
"""
#if 1:
try:
#if 1:
resource = self.getResourceValue()
......@@ -217,6 +218,7 @@ class Amount(Base, Variated):
quantity_unit = self.getQuantityUnit()
quantity = self.getTargetQuantity()
converted_quantity = resource.convertQuantity(quantity, quantity_unit, resource_quantity_unit)
#else:
except:
#else:
LOG("ERP5 WARNING:", 100, 'could not convert target_quantity for %s' % self.getRelativeUrl())
......@@ -242,7 +244,7 @@ class Amount(Base, Variated):
"""
quantity = self.getQuantity()
efficiency = self.getEfficiency()
if efficiency in (0, 0.0, None):
if efficiency in (0, 0.0, None, ''):
efficiency = 1.0
return float(quantity) / efficiency
......@@ -253,7 +255,7 @@ class Amount(Base, Variated):
"""
quantity = self.getTargetQuantity()
efficiency = self.getTargetEfficiency()
if efficiency in (0, 0.0, None):
if efficiency in (0, 0.0, None, ''):
efficiency = 1.0
return float(quantity) / efficiency
......@@ -264,9 +266,9 @@ class Amount(Base, Variated):
"""
quantity = self.getConvertedQuantity()
efficiency = self.getEfficiency()
if efficiency in (0, 0.0, None):
if efficiency in (0, 0.0, None, ''):
efficiency = 1.0
if quantity is not None:
if quantity not in (None, ''):
return float(quantity) / efficiency
else:
return None
......@@ -277,10 +279,12 @@ class Amount(Base, Variated):
Take into account efficiency in converted quantity
"""
efficiency = self.getEfficiency()
if efficiency in (0, 0.0, None):
if efficiency in (0, 0.0, None, ''):
efficiency = 1.0
if value is not None:
if value not in (None, ''):
quantity = float(value) * efficiency
else:
quantity = value
self.setConvertedQuantity(quantity)
security.declareProtected(Permissions.AccessContentsInformation, 'getNetConvertedTargetQuantity')
......@@ -292,7 +296,7 @@ class Amount(Base, Variated):
efficiency = self.getTargetEfficiency()
if efficiency in (0, 0.0, None):
efficiency = 1.0
if quantity is not None:
if quantity not in (None, ''):
return float(quantity) / efficiency
else:
return None
......@@ -305,8 +309,10 @@ class Amount(Base, Variated):
efficiency = self.getEfficiency()
if efficiency in (0, 0.0, None):
efficiency = 1.0
if value is not None:
if value not in (None, ''):
quantity = float(value) * efficiency
else:
quantity = value
self.setConvertedTargetQuantity(quantity)
security.declareProtected(Permissions.AccessContentsInformation, 'getInventoriatedQuantity')
......
......@@ -249,6 +249,7 @@ An ERP5 Rule..."""
Returns a list of indexable movements
"""
result = [ { 'uid' : self.getUid(),
'id' : self.getId(),
'portal_type' : self.getPortalType(),
'url' : self.getUrl(),
'relative_url' : self.getRelativeUrl(),
......
......@@ -304,35 +304,38 @@ a service in a public administration)."""
"""
Returns a list of indexable movements
"""
result = [ { 'uid' : self.getUid(),
'portal_type' : self.getPortalType(),
'url' : self.getUrl(),
'relative_url' : self.getRelativeUrl(),
'parent_uid' : self.getParentUid(),
'simulation_state' : self.getSimulationState(),
'order_uid' : self.getOrderUid(),
'explanation_uid' : self.getExplanationUid(),
'delivery_uid' : self.getDeliveryUid(),
'source_uid' : self.getSourceUid(),
'destination_uid' : self.getDestinationUid(),
'source_section_uid' : self.getSourceSectionUid(),
'destination_section_uid' : self.getDestinationSectionUid(),
'resource_uid' : self.getResourceUid(),
'quantity' : self.getNetConvertedQuantity(),
'start_date' : self.getStartDate(),
'stop_date' : self.getStopDate(),
'target_quantity' : self.getNetConvertedTargetQuantity(),
'target_start_date' : self.getTargetStartDate(),
'target_stop_date' : self.getTargetStopDate(),
'price' : self.getPrice(),
'total_price' : self.getTotalPrice(),
'target_total_price' : self.getTargetTotalPrice(),
'has_cell_content' : 0,
'accountable' : self.isAccountable(),
'orderable' : self.isOrderable(),
'deliverable' : self.isDeliverable(),
'variation_text' : self.getVariationText(),
'inventory' : self.getInventoriatedQuantity(),
result = [ { 'uid' : self.getUid(),
'id' : self.getId(),
'portal_type' : self.getPortalType(),
'url' : self.getUrl(),
'relative_url' : self.getRelativeUrl(),
'parent_uid' : self.getParentUid(),
'simulation_state' : self.getSimulationState(),
'order_uid' : self.getOrderUid(),
'explanation_uid' : self.getExplanationUid(),
'delivery_uid' : self.getDeliveryUid(),
'source_uid' : self.getSourceUid(),
'destination_uid' : self.getDestinationUid(),
'source_section_uid' : self.getSourceSectionUid(),
'destination_section_uid' : self.getDestinationSectionUid(),
'resource_uid' : self.getResourceUid(),
'quantity' : self.getNetConvertedQuantity(),
'start_date' : self.getStartDate(),
'stop_date' : self.getStopDate(),
'target_quantity' : self.getNetConvertedTargetQuantity(),
'target_start_date' : self.getTargetStartDate(),
'target_stop_date' : self.getTargetStopDate(),
'price' : self.getPrice(),
'total_price' : self.getTotalPrice(),
'target_total_price' : self.getTargetTotalPrice(),
'has_cell_content' : 0,
'accountable' : self.isAccountable(),
'orderable' : self.isOrderable(),
'deliverable' : self.isDeliverable(),
'variation_text' : self.getVariationText(),
'inventory' : self.getInventoriatedQuantity(),
'source_total_asset_price' : 0.0,
'destination_total_asset_price' : 0.0,
} ]
for m in self.objectValues():
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