diff --git a/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/SaleSupplyLine_asPredicate.py b/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/SaleSupplyLine_asPredicate.py index a25b8cbd48147885de4638d63704e89f073ddf09..b04269810d2bf8cbadcac95e56cf2b277198bd3c 100644 --- a/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/SaleSupplyLine_asPredicate.py +++ b/master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_accounting/SaleSupplyLine_asPredicate.py @@ -1,11 +1,10 @@ -supply = context.getParentValue() +if (not context.hasBasePrice()) or (not context.getPriceCurrency()) or (not context.getResource()) or (not context.getQuantityUnit()): + # Meaningless path if no resource/price_currency/base_price/quantity_unit + return None -if context.getPortalType() == 'Sale Supply Line': - # If resource has variation, do not use the Line as a predicate - if context.getVariationRangeBaseCategoryList(): - return None +supply = context.getParentValue() -base_category_tuple = ['resource', 'price_currency'] +base_category_tuple = ['resource', 'price_currency', 'quantity_unit'] if context.getPortalType() == 'Sale Supply Cell': base_category_tuple.extend(supply.getVariationRangeBaseCategoryList()) supply = supply.getParentValue() @@ -14,7 +13,6 @@ if (supply.getPortalType() != 'Sale Supply') or (supply.getValidationState() != # If this supply line is not in a validated Sale Supply, it does not apply. return None - if context.getSourceSection(): base_category_tuple.append('source_section') if context.getDestinationSection(): diff --git a/master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSSaleSupply.py b/master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSSaleSupply.py index 350906abf51f45be1cf862c2935991dc1df44599..53220991b2d4c32703bd588f8f240e086643fa9d 100644 --- a/master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSSaleSupply.py +++ b/master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSSaleSupply.py @@ -21,7 +21,8 @@ class TestSlapOSSaleSupply(SlapOSTestCaseMixin): # - one with 2 releases and 2 types simple_product = self.portal.software_product_module.newContent( portal_type="Software Product", - title="Simple Product" + title="Simple Product", + quantity_unit='time/month', ) simple_product.newContent( portal_type="Software Product Type Variation", @@ -34,7 +35,8 @@ class TestSlapOSSaleSupply(SlapOSTestCaseMixin): complex_product = self.portal.software_product_module.newContent( portal_type="Software Product", - title="Complex Product" + title="Complex Product", + quantity_unit='time/month', ) complex_product.newContent( portal_type="Software Product Type Variation", @@ -101,6 +103,7 @@ class TestSlapOSSaleSupply(SlapOSTestCaseMixin): title="%s without price" % software_product.getTitle(), portal_type="Sale Supply Line", resource_value=software_product, + quantity_unit=software_product.getQuantityUnit(), ) sale_supply_line_list.append(sale_supply_line) @@ -110,13 +113,15 @@ class TestSlapOSSaleSupply(SlapOSTestCaseMixin): portal_type="Sale Supply Line", resource_value=software_product, base_price=base_price, + quantity_unit=software_product.getQuantityUnit(), ) sale_supply_line_list.append(sale_supply_line) sale_supply_line = sale_supply.newContent( title="%s with variation" % software_product.getTitle(), portal_type="Sale Supply Line", - resource_value=software_product + resource_value=software_product, + quantity_unit=software_product.getQuantityUnit(), ) sale_supply_line_list.append(sale_supply_line) base_price += 1 @@ -162,6 +167,7 @@ class TestSlapOSSaleSupply(SlapOSTestCaseMixin): portal_type='Movement', temp_object=1, resource_value=software_product, + quantity_unit=software_product.getQuantityUnit(), software_type_value=software_type, software_release_value=software_release, start_date=start_date,