diff --git a/product/ERP5/Document/Transformation.py b/product/ERP5/Document/Transformation.py index a6ab0775cb974dd04dd4dda6cb94e22f7dfb5aa3..ae4f8562ebccb134ce01579b4742a32605e49104 100644 --- a/product/ERP5/Document/Transformation.py +++ b/product/ERP5/Document/Transformation.py @@ -185,6 +185,20 @@ class Transformation(XMLObject, Predicate, Variated): self._setVariationBaseCategoryList(value) self.reindexObject() + security.declareProtected(Permissions.AccessContentsInformation, + 'getVariationCategoryList') + def getVariationCategoryList(self, **kwd): + """ + Returns the variation categories applicable to the Transformation. + When a resource is defined, it should not return more than what is + set through the Resource. + """ + resource = self.getResourceValue() + if resource is not None: + return resource.getVariationCategoryList(**kwd) + else: + return self.getVariationCategoryList(**kwd) + security.declareProtected(Permissions.AccessContentsInformation, 'getVariationCategoryItemList') def getVariationCategoryItemList(self, base_category_list=(), base=1, diff --git a/product/ERP5/tests/testTransformation.py b/product/ERP5/tests/testTransformation.py index d8370402416d4114e7d5100c274393c129e28aa5..fd74eaa03c42b7af2a8f65a20eefd33db1d5e46a 100644 --- a/product/ERP5/tests/testTransformation.py +++ b/product/ERP5/tests/testTransformation.py @@ -126,6 +126,26 @@ class TestTransformation(TestTransformationMixin, ERP5TypeTestCase): # temp object self.assertTrue(aggregated_amount.isTested()) + def test_variationCategory(self): + swimcap = self.createResource( + 'Swimming Cap', + self.swimsuit_variation_base_category_list, + self.swimsuit_variation_category_list, + ) + transformation = self.createTransformation() + transformation.edit( + title = 'Swimcap Production', + variation_base_category_list = self.swimsuit_variation_base_category_list + ) + transformation.setResourceValue(swimcap) + + transaction.commit() + self.tic() + self.assertEquals( + swimcap.getVariationCategoryList(), + transformation.getVariationCategoryList() + ) + def test_transformedInventory(self): portal = self.getPortal()