Commit c4ba8b9a authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: order Supply Predicate matching

parent 4b65e8d7
......@@ -6,11 +6,13 @@ def sort_key_method(e):
having source_function only
others
"""
return 0
parent = e.getParentValue()
if parent.getPortalType().endswith('Line'):
parent = parent.getParentValue()
return 0 - 1 * int(parent.hasSourceFunction()) - 2 * int(parent.hasGroup())
minus = 0
else:
minus = -0.5
return 0 - 1 * int(parent.hasDestination()) + minus
def filter_method(currency, destination_project, group):
def filter_by_source_function_and_group(l):
......@@ -38,6 +40,7 @@ def filter_method(currency, destination_project, group):
#if parent.getGroup() not in (None, group):
# continue
ret.append(i)
return ret
return filter_by_source_function_and_group
source = context.getSourceValue()
......@@ -47,13 +50,6 @@ else:
group = source.getGroup()
kw['filter_method'] = filter_method(context.getPriceCurrency(), context.getDestinationProject(), group)
"""
def filter_couscous(predicate_list):
raise NotImplementedError(predicate_list)
return predicate_list
kw['filter_method'] = filter_couscous
"""
kw['sort_key_method'] = sort_key_method
resource = context.getResourceValue()
......@@ -63,7 +59,6 @@ if resource is not None:
if product_line:
kw['categories'] = kw.get('categories', []) + ['product_line/%s' % product_line]
#raise NotImplementedError(str(kw))
return resource.getPriceCalculationOperandDict(
default=default, context=context, **kw)
......
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