Commit 30833f3d authored by Nicolas Dumazet's avatar Nicolas Dumazet

Fix indexation of default Measures now that quantity_unit is

not anymore acquired by Measures from the Resource


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@37250 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 565801b2
...@@ -168,7 +168,22 @@ class Measure(XMLMatrix): ...@@ -168,7 +168,22 @@ class Measure(XMLMatrix):
Returns the list of rows to insert in the measure table of the catalog. Returns the list of rows to insert in the measure table of the catalog.
Called by Resource.getMeasureRowList. Called by Resource.getMeasureRowList.
""" """
# The only purpose of the defining a default measure explicitly is to
# set a specific metric_type for the management unit.
# Therefore, the measure mustn't be variated and the described quantity
# (quantity * quantity_unit) must match the management unit.
# If the conditions aren't met, return an empty list.
default = self.isDefaultMeasure()
resource = self.getResourceValue()
resource_uid = resource.getUid()
quantity_unit_value = self.getQuantityUnitValue() quantity_unit_value = self.getQuantityUnitValue()
if default and quantity_unit_value is None:
# for default measure candidates, we do not care if the
# quantity is not set: use the resource quantity unit!
quantity_unit_value = resource.getQuantityUnitValue()
metric_type = self.getMetricType() metric_type = self.getMetricType()
if quantity_unit_value is None or not metric_type or \ if quantity_unit_value is None or not metric_type or \
quantity_unit_value.getParentId() != metric_type.split('/', 1)[0]: quantity_unit_value.getParentId() != metric_type.split('/', 1)[0]:
...@@ -187,8 +202,6 @@ class Measure(XMLMatrix): ...@@ -187,8 +202,6 @@ class Measure(XMLMatrix):
return None return None
uid = self.getUid() uid = self.getUid()
resource = self.getResourceValue()
resource_uid = resource.getUid()
metric_type_uid = self.getMetricTypeUid() metric_type_uid = self.getMetricTypeUid()
quantity = self.getQuantity() quantity = self.getQuantity()
...@@ -196,13 +209,6 @@ class Measure(XMLMatrix): ...@@ -196,13 +209,6 @@ class Measure(XMLMatrix):
if quantity_unit is None: if quantity_unit is None:
return () return ()
# The only purpose of the defining a default measure explicitly is to
# set a specific metric_type for the management unit.
# Therefore, the measure mustn't be variated and the described quantity
# (quantity * quantity_unit) must match the management unit.
# If the conditions aren't met, return an empty list.
default = self.isDefaultMeasure()
measure_variation_base_category_list = \ measure_variation_base_category_list = \
self.getMeasureVariationBaseCategoryList() self.getMeasureVariationBaseCategoryList()
if not measure_variation_base_category_list: if not measure_variation_base_category_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