[Erp5-report] r32160 nicolas.dumazet - in /erp5/trunk/products/ERP5: Tool/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Feb 2 06:24:28 CET 2010
Author: nicolas.dumazet
Date: Tue Feb 2 06:24:26 2010
New Revision: 32160
URL: http://svn.erp5.org?rev=32160&view=rev
Log:
inventory API: allow to omit metric_type parameter in inventory
queries. Default metric type is used instead
Modified:
erp5/trunk/products/ERP5/Tool/SimulationTool.py
erp5/trunk/products/ERP5/tests/testInventoryAPI.py
Modified: erp5/trunk/products/ERP5/Tool/SimulationTool.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Tool/SimulationTool.py?rev=32160&r1=32159&r2=32160&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Tool/SimulationTool.py [utf8] (original)
+++ erp5/trunk/products/ERP5/Tool/SimulationTool.py [utf8] Tue Feb 2 06:24:26 2010
@@ -1033,21 +1033,25 @@
result_column_id_dict = {}
+ metric_type = kw.pop('metric_type', None)
quantity_unit = kw.pop('quantity_unit', None)
quantity_unit_uid = None
+
if quantity_unit is not None:
if isinstance(quantity_unit, str):
quantity_unit_uid = getCategory(quantity_unit, 'quantity_unit')
if quantity_unit_uid is not None:
result_column_id_dict['converted_quantity'] = None
+ if metric_type is None:
+ # use the default metric type
+ metric_type = quantity_unit.split("/", 1)[0]
elif isinstance(quantity_unit, int) or isinstance(quantity_unit, float):
# quantity_unit used to be a numerical parameter..
raise ValueError('Numeric values for quantity_unit are not supported')
convert_quantity_result = False
- metric_type = kw.pop('metric_type', None)
if metric_type is not None:
metric_type_uid = getCategory(metric_type, 'metric_type')
Modified: erp5/trunk/products/ERP5/tests/testInventoryAPI.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testInventoryAPI.py?rev=32160&r1=32159&r2=32160&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testInventoryAPI.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testInventoryAPI.py [utf8] Tue Feb 2 06:24:26 2010
@@ -2513,6 +2513,16 @@
self.assertEquals(13 * .056 - 2 * .043,
self.convertedSimulation('mass/nutr/lipid'))
+ def testInventoryNoMetricType(self):
+ """
+ providing only the quantity_unit argument should also work,
+ and the standard metric type is used
+ """
+ self.assertEquals((11 * 123 - 789) / 1e6,
+ self.getSimulationTool().getInventory(
+ node_uid=self.node.getUid(),
+ quantity_unit="mass/t"))
+
class TestUnitConversionDefinition(BaseTestUnitConversion):
QUANTITY_UNIT_DICT = {
# base: (reference, dict_of_others)
More information about the Erp5-report
mailing list