Commit 4b65e8d7 authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: allow Supply Line to define price even if resource has variations

Force quantity unit to match (no convertion for now)
parent fc18ba29
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():
......
......@@ -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,
......
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