Commit 4536c013 authored by Nicolas Dumazet's avatar Nicolas Dumazet

test&implement TransformedResource.getAggregatedAmountList(a) if a.quantity <> 1


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33746 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c63b1ea5
......@@ -263,6 +263,15 @@ class TransformedResource(Predicate, XMLObject, XMLMatrix, Amount):
except ValueError:
error_string += 'Quantity is not a float.'
# If IAmount specifies that 4 resources are needed, all quantities
# need to be multiplicated by 4...
context_quantity = None
quantity_getter = getattr(context, "getQuantity", None)
if quantity_getter is not None:
context_quantity = quantity_getter()
if context_quantity is None:
raise KeyError("No quantity defined on context")
quantity *= float(context_quantity)
# Get the variation category list
variation_category_list_defined_by = None
......
......@@ -242,6 +242,7 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase):
len(fabric_line.getCellKeyList(base_id='quantity'))
)
swimsuit_quantity = 4.0
from Products.ERP5Type.Document import newTempAmount
n = 1
# Check that getAggregatedAmount returns the expected results, a.k.a.
......@@ -251,7 +252,7 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase):
# id does not matter, just make it unique
temp_amount = newTempAmount(transformation, "foo_%s_%s" % (size, colour))
temp_amount.edit(
quantity = 1.0,
quantity = swimsuit_quantity,
variation_category_list = [size, colour],
resource = swimsuit.getRelativeUrl(),
)
......@@ -262,12 +263,12 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase):
resource = amount.getResource()
if resource == fabric.getRelativeUrl():
self.assertEquals(amount.getVariationCategoryList(), [colour])
self.assertEquals(amount.getQuantity(), i+1)
self.assertEquals(amount.getQuantity(), (i+1)*swimsuit_quantity)
elif resource == button.getRelativeUrl():
self.assertEquals(amount.getVariationCategoryList(), [size])
self.assertEquals(amount.getQuantity(), button_number)
self.assertEquals(amount.getQuantity(), button_number*swimsuit_quantity)
elif resource == "operation/sewing":
self.assertEquals(amount.getQuantity(), n)
self.assertEquals(amount.getQuantity(), n*swimsuit_quantity)
else:
self.fail("Invalid Resource: %s" % resource)
n += 1
......
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