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(),
......
...@@ -304,35 +304,38 @@ a service in a public administration).""" ...@@ -304,35 +304,38 @@ 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(),
'portal_type' : self.getPortalType(), 'id' : self.getId(),
'url' : self.getUrl(), 'portal_type' : self.getPortalType(),
'relative_url' : self.getRelativeUrl(), 'url' : self.getUrl(),
'parent_uid' : self.getParentUid(), 'relative_url' : self.getRelativeUrl(),
'simulation_state' : self.getSimulationState(), 'parent_uid' : self.getParentUid(),
'order_uid' : self.getOrderUid(), 'simulation_state' : self.getSimulationState(),
'explanation_uid' : self.getExplanationUid(), 'order_uid' : self.getOrderUid(),
'delivery_uid' : self.getDeliveryUid(), 'explanation_uid' : self.getExplanationUid(),
'source_uid' : self.getSourceUid(), 'delivery_uid' : self.getDeliveryUid(),
'destination_uid' : self.getDestinationUid(), 'source_uid' : self.getSourceUid(),
'source_section_uid' : self.getSourceSectionUid(), 'destination_uid' : self.getDestinationUid(),
'destination_section_uid' : self.getDestinationSectionUid(), 'source_section_uid' : self.getSourceSectionUid(),
'resource_uid' : self.getResourceUid(), 'destination_section_uid' : self.getDestinationSectionUid(),
'quantity' : self.getNetConvertedQuantity(), 'resource_uid' : self.getResourceUid(),
'start_date' : self.getStartDate(), 'quantity' : self.getNetConvertedQuantity(),
'stop_date' : self.getStopDate(), 'start_date' : self.getStartDate(),
'target_quantity' : self.getNetConvertedTargetQuantity(), 'stop_date' : self.getStopDate(),
'target_start_date' : self.getTargetStartDate(), 'target_quantity' : self.getNetConvertedTargetQuantity(),
'target_stop_date' : self.getTargetStopDate(), 'target_start_date' : self.getTargetStartDate(),
'price' : self.getPrice(), 'target_stop_date' : self.getTargetStopDate(),
'total_price' : self.getTotalPrice(), 'price' : self.getPrice(),
'target_total_price' : self.getTargetTotalPrice(), 'total_price' : self.getTotalPrice(),
'has_cell_content' : 0, 'target_total_price' : self.getTargetTotalPrice(),
'accountable' : self.isAccountable(), 'has_cell_content' : 0,
'orderable' : self.isOrderable(), 'accountable' : self.isAccountable(),
'deliverable' : self.isDeliverable(), 'orderable' : self.isOrderable(),
'variation_text' : self.getVariationText(), 'deliverable' : self.isDeliverable(),
'inventory' : self.getInventoriatedQuantity(), 'variation_text' : self.getVariationText(),
'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