Commit fba41737 authored by Romain Courteaud's avatar Romain Courteaud

TOSQUASH? slapos_accounting: no need to rely on the catalog to validate the trade condition

slapos_accounting: factorise code

slapos_wechat: use reference sale trade condition

slapos_erp5: check sale trade condition reference
parent 9777a748
portal = context.getPortalObject()
root_trade_condition_reference_list = [
"slapos_aggregated_trade_condition",
"slapos_aggregated_subscription_trade_condition",
# Valid trade condition for payments
"slapos_manual_accounting_trade_condition"
]
root_trade_condition_list = portal.portal_catalog(
portal_type="Sale Trade Condition",
reference=root_trade_condition_reference_list,
validation_state="validated",
)
specialise_uid_list = [x.getUid() for x in root_trade_condition_list]
if context.getSpecialiseUid() in specialise_uid_list:
return True
return context.getSpecialiseUid() in [
i.uid for i in portal.ERP5Site_searchRelatedInheritedSpecialiseList(
portal_type="Sale Trade Condition",
specialise_uid=specialise_uid_list,
validation_state="validated")]
return context.Base_useSaleTradeConditionReference(root_trade_condition_reference_list)
portal_type = 'Sale Trade Condition'
if same_type(reference_list, ''):
reference_list = [reference_list]
specialise_list = [context.getSpecialiseValue(portal_type=portal_type)]
while specialise_list:
trade_condition = specialise_list.pop()
if (trade_condition is None) or (trade_condition.getValidationState() != 'validated'):
continue
if trade_condition.getReference() in reference_list:
return True
parent_trade_condition = trade_condition.getSpecialiseValue(portal_type=portal_type)
if parent_trade_condition is not None:
specialise_list.append(parent_trade_condition)
return False
<?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>reference_list</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_useSaleTradeConditionReference</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -7,7 +7,7 @@
</role>
<role id='Auditor'>
<property id='title'>Subscription Customer</property>
<property id='condition'>python: here.getSpecialise() in ('sale_trade_condition_module/slapos_subscription_trade_condition', 'sale_trade_condition_module/slapos_aggregated_trade_condition', 'sale_trade_condition_module/slapos_aggregated_subscription_trade_condition')</property>
<property id='condition'>python: here.Base_useSaleTradeConditionReference(('slapos_subscription_trade_condition', 'slapos_aggregated_trade_condition', 'slapos_aggregated_subscription_trade_condition'))</property>
<property id='base_category_script'>ERP5Type_getSecurityCategoryFromContent</property>
<multi_property id='categories'>local_role_group/user</multi_property>
<multi_property id='base_category'>destination_decision</multi_property>
......
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