diff --git a/product/ERP5/Document/Measure.py b/product/ERP5/Document/Measure.py index df4e8fb6b27fe0499ba081a121a5b80ca7a9f7b3..7a1f9e1b36dddca48ca68c3192e717286b728407 100644 --- a/product/ERP5/Document/Measure.py +++ b/product/ERP5/Document/Measure.py @@ -32,6 +32,13 @@ from Products.ERP5Type.Permissions import AccessContentsInformation from Products.ERP5Type.XMLMatrix import XMLMatrix from Products.ERP5.Variated import Variated + +def getQuantity(quantity_unit_value): + quantity = quantity_unit_value.getProperty('quantity') + if quantity is not None: + return float(quantity) + + class Measure(XMLMatrix): """ A Measure @@ -132,7 +139,7 @@ class Measure(XMLMatrix): metric_type = self.getMetricType() if quantity_unit is not None and metric_type and \ quantity_unit.getParentId() == metric_type.split('/', 1)[0]: - return float(quantity_unit.getProperty('quantity')) + return getQuantity(quantity_unit) security.declareProtected(AccessContentsInformation, 'getConvertedQuantity') def getConvertedQuantity(self, variation_list=()): @@ -190,7 +197,7 @@ class Measure(XMLMatrix): if quantity is not None: quantity *= quantity_unit if (not default or quantity == - float(resource.getQuantityUnitValue().getProperty('quantity'))): + getQuantity(resource.getQuantityUnitValue())): return (uid, resource_uid, '^', metric_type_uid, quantity), return () diff --git a/product/ERP5/Document/Resource.py b/product/ERP5/Document/Resource.py index 14017d4261329bb58a07e8c1032f6602c7419e3b..b9fd9d6aa6adeb0eb5a93a6d57da179c4ec1b3ad 100644 --- a/product/ERP5/Document/Resource.py +++ b/product/ERP5/Document/Resource.py @@ -887,11 +887,11 @@ class Resource(XMLMatrix, Variated): # At this point, we know there is no default measure and we must add # a row for the management unit, with the resource's uid as uid, and # a generic metric_type. - quantity = float(quantity_unit_value.getProperty('quantity')) + quantity = quantity_unit_value.getProperty('quantity') metric_type_uid = self.getPortalObject().portal_categories \ .getCategoryUid(metric_type, 'metric_type') if quantity and metric_type_uid: uid = self.getUid() - insert_list += (uid, uid, '^', metric_type_uid, quantity), + insert_list += (uid, uid, '^', metric_type_uid, float(quantity)), return insert_list