From 084adda5301610bc551ddb18322b968d8b2e6aad Mon Sep 17 00:00:00 2001 From: Jean-Paul Smets <jp@nexedi.com> Date: Tue, 27 Jan 2004 14:46:07 +0000 Subject: [PATCH] improved handling of indexing git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@355 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/Document/Amount.py | 22 +++++--- product/ERP5/Document/AppliedRule.py | 1 + product/ERP5/Document/SimulationMovement.py | 61 +++++++++++---------- 3 files changed, 47 insertions(+), 37 deletions(-) diff --git a/product/ERP5/Document/Amount.py b/product/ERP5/Document/Amount.py index 2292f1f09c..96e6a8cda2 100755 --- a/product/ERP5/Document/Amount.py +++ b/product/ERP5/Document/Amount.py @@ -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') diff --git a/product/ERP5/Document/AppliedRule.py b/product/ERP5/Document/AppliedRule.py index c4dea1f6fe..d9e6fa5250 100755 --- a/product/ERP5/Document/AppliedRule.py +++ b/product/ERP5/Document/AppliedRule.py @@ -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(), diff --git a/product/ERP5/Document/SimulationMovement.py b/product/ERP5/Document/SimulationMovement.py index 2982153010..607b53c57b 100755 --- a/product/ERP5/Document/SimulationMovement.py +++ b/product/ERP5/Document/SimulationMovement.py @@ -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()) -- 2.30.9