Commit 48e45be5 authored by Julien Muchembled's avatar Julien Muchembled

Fix testInventoryAPI.TestUnitConversion (broken by r21303).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21315 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 30a86602
...@@ -32,6 +32,13 @@ from Products.ERP5Type.Permissions import AccessContentsInformation ...@@ -32,6 +32,13 @@ from Products.ERP5Type.Permissions import AccessContentsInformation
from Products.ERP5Type.XMLMatrix import XMLMatrix from Products.ERP5Type.XMLMatrix import XMLMatrix
from Products.ERP5.Variated import Variated 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): class Measure(XMLMatrix):
""" """
A Measure A Measure
...@@ -132,7 +139,7 @@ class Measure(XMLMatrix): ...@@ -132,7 +139,7 @@ class Measure(XMLMatrix):
metric_type = self.getMetricType() metric_type = self.getMetricType()
if quantity_unit is not None and metric_type and \ if quantity_unit is not None and metric_type and \
quantity_unit.getParentId() == metric_type.split('/', 1)[0]: quantity_unit.getParentId() == metric_type.split('/', 1)[0]:
return float(quantity_unit.getProperty('quantity')) return getQuantity(quantity_unit)
security.declareProtected(AccessContentsInformation, 'getConvertedQuantity') security.declareProtected(AccessContentsInformation, 'getConvertedQuantity')
def getConvertedQuantity(self, variation_list=()): def getConvertedQuantity(self, variation_list=()):
...@@ -190,7 +197,7 @@ class Measure(XMLMatrix): ...@@ -190,7 +197,7 @@ class Measure(XMLMatrix):
if quantity is not None: if quantity is not None:
quantity *= quantity_unit quantity *= quantity_unit
if (not default or quantity == if (not default or quantity ==
float(resource.getQuantityUnitValue().getProperty('quantity'))): getQuantity(resource.getQuantityUnitValue())):
return (uid, resource_uid, '^', metric_type_uid, quantity), return (uid, resource_uid, '^', metric_type_uid, quantity),
return () return ()
......
...@@ -887,11 +887,11 @@ class Resource(XMLMatrix, Variated): ...@@ -887,11 +887,11 @@ class Resource(XMLMatrix, Variated):
# At this point, we know there is no default measure and we must add # 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 row for the management unit, with the resource's uid as uid, and
# a generic metric_type. # a generic metric_type.
quantity = float(quantity_unit_value.getProperty('quantity')) quantity = quantity_unit_value.getProperty('quantity')
metric_type_uid = self.getPortalObject().portal_categories \ metric_type_uid = self.getPortalObject().portal_categories \
.getCategoryUid(metric_type, 'metric_type') .getCategoryUid(metric_type, 'metric_type')
if quantity and metric_type_uid: if quantity and metric_type_uid:
uid = self.getUid() uid = self.getUid()
insert_list += (uid, uid, '^', metric_type_uid, quantity), insert_list += (uid, uid, '^', metric_type_uid, float(quantity)),
return insert_list return insert_list
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