Commit eaaa7a81 authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: do not aply trade condition if source/destination projects...

slapos_accounting: do not aply trade condition if source/destination projects are different from order
parent 6740ab10
...@@ -11,6 +11,8 @@ trade_condition_list = order.getSpecialiseValueList( ...@@ -11,6 +11,8 @@ trade_condition_list = order.getSpecialiseValueList(
all_category_list = ('source_section', 'source', 'source_project', all_category_list = ('source_section', 'source', 'source_project',
'destination_section', 'destination', 'destination_project', 'destination_section', 'destination', 'destination_project',
'currency') 'currency')
matching_category_list = ('source_project', 'destination_project')
tested_base_category_list = [ ] tested_base_category_list = [ ]
for base_category in all_category_list: for base_category in all_category_list:
if context.getProperty(base_category): if context.getProperty(base_category):
...@@ -61,6 +63,11 @@ def filter_method(trade_condition_list): ...@@ -61,6 +63,11 @@ def filter_method(trade_condition_list):
filtered_trade_condition_list = [] filtered_trade_condition_list = []
for trade_condition in trade_condition_list: for trade_condition in trade_condition_list:
matching = True matching = True
for base_category in matching_category_list:
if order.getProperty(base_category) != trade_condition.getProperty(base_category):
matching = False
break
for base_category in all_category_list: for base_category in all_category_list:
if order.getProperty(base_category) and trade_condition.getProperty(base_category): if order.getProperty(base_category) and trade_condition.getProperty(base_category):
if trade_condition.getProperty(base_category) != order.getProperty(base_category): if trade_condition.getProperty(base_category) != order.getProperty(base_category):
...@@ -84,6 +91,8 @@ while count > 0 and len(trade_condition_list) == 0: ...@@ -84,6 +91,8 @@ while count > 0 and len(trade_condition_list) == 0:
} }
if order.hasDestinationProject(): if order.hasDestinationProject():
filter_kw['destination_project__uid'] = order.getDestinationProjectUid() filter_kw['destination_project__uid'] = order.getDestinationProjectUid()
if order.hasSourceProject():
filter_kw['source_project__uid'] = order.getSourceProjectUid()
trade_condition_list = context.portal_domains.searchPredicateList( trade_condition_list = context.portal_domains.searchPredicateList(
predicate_context, predicate_context,
......
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