Commit a5581cd5 authored by Jérome Perrin's avatar Jérome Perrin

invoicing: scripts to get dynamic accounting trade model paths

parent 25e4a08a
category_list = context.TradeModelPath_getAccountingDynamicDestinationCategoryListWithoutAnalytic(movement)
function = movement.getDestinationFunction(
base=True) or context.getDestinationFunction(base=True)
if function:
category_list.append(function)
funding = movement.getDestinationFunding(
base=True) or context.getDestinationFunding(base=True)
if funding:
category_list.append(funding)
project = movement.getDestinationProject(
base=True) or context.getDestinationProject(base=True)
if project:
category_list.append(project)
return category_list
<?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>movement</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TradeModelPath_getAccountingDynamicDestinationCategoryListWithAnalytic</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
category_list = [
c for c in [
movement.getDestinationSection(base=True),
movement.getDestinationPayment(base=True)
] if c
]
account = movement.getDestinationAccount() or context.getDestination()
if not account:
# try to find from predicates
resource = movement.getResourceValue()
if resource is not None:
account = next(
(
predicate.getDestinationAccount()
for predicate in portal.portal_domains.searchPredicateList(
context=movement,
portal_type='Purchase Supply Line',
)
if predicate.getDestinationAccount()), None)
if account:
category_list.append('destination/%s' % account)
return category_list
<?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>movement</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TradeModelPath_getAccountingDynamicDestinationCategoryListWithoutAnalytic</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
category_list = context.TradeModelPath_getAccountingDynamicSourceCategoryListWithoutAnalytic(movement)
function = movement.getSourceFunction(base=True) or context.getSourceFunction(
base=True)
if function:
category_list.append(function)
funding = movement.getSourceFunding(base=True) or context.getSourceFunding(
base=True)
if funding:
category_list.append(funding)
project = movement.getSourceProject(base=True) or context.getSourceProject(
base=True)
if project:
category_list.append(project)
return category_list
<?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>movement</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TradeModelPath_getAccountingDynamicSourceCategoryListWithAnalytic</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
category_list = [
c for c in [
movement.getSourceSection(base=True),
movement.getSourcePayment(base=True)
] if c
]
account = movement.getSourceAccount() or context.getSource()
if not account:
# try to find from predicates
resource = movement.getResourceValue()
if resource is not None:
account = next(
(
predicate.getSourceAccount()
for predicate in portal.portal_domains.searchPredicateList(
context=movement,
portal_type='Sale Supply Line',
)
if predicate.getSourceAccount()), None)
if account:
category_list.append('source/%s' % account)
return category_list
<?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>movement</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TradeModelPath_getAccountingDynamicSourceCategoryListWithoutAnalytic</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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