Commit 75caeccd authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: configure Sale Supply predicate

parent 6ee74e48
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>*args, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SaleSupplyCell_asPredicate</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
parent = context.getParentValue()
if (parent.getPortalType() != 'Sale Supply') or (parent.getValidationState() != 'validated'):
supply = context.getParentValue()
if context.getPortalType() == 'Sale Supply Line':
# If resource has variation, do not use the Line as a predicate
if context.getVariationRangeBaseCategoryList():
return None
base_category_tuple = ['resource', 'price_currency']
if context.getPortalType() == 'Sale Supply Cell':
base_category_tuple.extend(supply.getVariationRangeBaseCategoryList())
supply = supply.getParentValue()
if (supply.getPortalType() != 'Sale Supply') or (supply.getValidationState() != 'validated'):
# If this supply line is not in a validated Sale Supply, it does not apply.
return None
base_category_tuple = ('resource', 'price_currency')
if context.getSourceSection():
base_category_tuple += ('source_section',)
base_category_tuple.append('source_section')
if context.getDestinationSection():
base_category_tuple += ('destination_section',)
base_category_tuple.append('destination_section')
if context.getSource():
base_category_tuple += ('source',)
base_category_tuple.append('source')
if context.getDestination():
base_category_tuple += ('destination',)
base_category_tuple.append('destination')
if context.getSourceProject():
base_category_tuple += ('source_project',)
base_category_tuple.append('source_project')
if context.getDestinationProject():
base_category_tuple += ('destination_project',)
base_category_tuple.append('destination_project')
#backwards compatibility
mapped_value_property_list = context.getMappedValuePropertyList()
......
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SupplyLine_asPredicate</string> </value>
<value> <string>SaleSupplyLine_asPredicate</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -138,7 +138,7 @@ class TestSlapOSSaleSupply(SlapOSTestCaseMixin):
(destination == sale_supply_cell.getParentValue().getParentValue().getDestinationValue())) and
(start_date == sale_supply_cell.getParentValue().getParentValue().getStartDateRangeMin())
)
assert sale_supply_cell.test(tmp_context) == expected_test_result, """Expected: %s %i
assert sale_supply_cell.test(tmp_context) == expected_test_result, """Expected: %s %i %s
Product: %s %s
Type: %s %s
Release: %s %s
......@@ -146,7 +146,7 @@ Project: %s %s
Destination: %s %s
Date: %s %s
""" % (
expected_test_result, i,
expected_test_result, i, sale_supply_cell.getRelativeUrl(),
software_product.getRelativeUrl(), sale_supply_cell.getResource(),
software_type.getRelativeUrl(), sale_supply_cell.getSoftwareType(),
software_release.getRelativeUrl(), sale_supply_cell.getSoftwareRelease(),
......
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