Commit 069abc69 authored by Arnaud Fontaine's avatar Arnaud Fontaine

WIP

parent 2898b9cc
from Products.CMFActivity.ActiveResult import ActiveResult
portal = context.getPortalObject()
active_process = portal.restrictedTraverse(active_process)
this_journal_active_process = portal.restrictedTraverse(this_journal_active_process)
# XXX we need proxy role for this
result_list = this_journal_active_process.getResultList()
if result_list:
journal_fragment = context.AccountingTransactionModule_viewJournalAsFECExtendedXML(
journal_code=journal_code,
journal_lib=journal_lib,
result_list=result_list)
active_process.postResult(ActiveResult(detail=journal_fragment.encode('utf8').encode('zlib')))
# delete no longer needed active process
this_journal_active_process.getParentValue().manage_delObjects(ids=[this_journal_active_process.getId()])
<?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>journal_code, journal_lib, active_process, this_journal_active_process</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingTransactionModule_aggregateFrenchAccountingTransactionFileExtendedForOneJournal</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
import random
portal = context.getPortalObject()
at_date = at_date.latestTime()
......@@ -13,21 +12,96 @@ active_process = portal.portal_activities.newActiveProcess()
priority = 4
for portal_type in portal.getPortalAccountingTransactionTypeList():
# XXX we need proxy role for that
this_portal_type_active_process = portal.portal_activities.newActiveProcess()
context.AccountingTransactionModule_viewFrenchAccountingTransactionFileExtendedForPortalType(
portal_type,
section_uid_list,
from_date,
at_date,
simulation_state,
ledger,
active_process.getRelativeUrl(),
this_portal_type_active_process.getRelativeUrl(),
tag,
aggregate_tag,
priority)
#### AccountingTransactionModule_viewFrenchAccountingTransactionFileForPortalType
kind = 'portal_type'
#kind = 'ledger'
#kind = 'portal_type_ledger'
# XXX we need proxy role for that
this_journal_active_process = portal.portal_activities.newActiveProcess().getRelativeUrl()
method_kw = {
'active_process': this_journal_active_process,
'section_uid_list': section_uid_list,
}
activate_kw = {
'tag': tag,
'priority': priority,
}
## search_kw
search_kw = {
'simulation_state': simulation_state,
'accounting_transaction.section_uid': section_uid_list,
'operation_date': {'query': (from_date, at_date), 'range': 'minngt' },
}
category_tool = portal.portal_categories
ledger_obj_list = []
if ledger is not None:
if not (isinstance(ledger, list) or isinstance(ledger, tuple)):
ledger = (ledger,)
for item in ledger:
ledger_obj_list.append(category_tool.ledger.restrictedTraverse(item))
# (journal_code, journal_lib, search_kw)
journal_search_kw_list = []
if kind == 'ledger':
if not ledger_obj_list:
for ledger_relative_url, _ in context.AccountingTransactionModule_getLedgerItemList():
ledger_obj_list.append(category_tool.ledger.restrictedTraverse(ledger_relative_url))
search_kw['portal_type'] = portal.getPortalAccountingTransactionTypeList()
for ledger_obj in ledger_obj_list:
ledger_search_kw = search_kw.copy()
ledger_search_kw['default_ledger_uid'] = ledger_obj.getUid()
journal_search_kw_list.append((ledger_obj.getReference(), ledger_obj.getReference(), ledger_search_kw))
elif kind == 'portal_type_ledger':
if not ledger_obj_list:
for ledger_relative_url, _ in context.AccountingTransactionModule_getLedgerItemList():
ledger_obj_list.append(category_tool.ledger.restrictedTraverse(ledger_relative_url))
for ledger_obj in ledger_obj_list:
portal_type_ledger_search_kw = search_kw.copy()
portal_type_ledger_search_kw['default_ledger_uid'] = ledger_obj.getUid()
for portal_type in portal.getPortalAccountingTransactionTypeList():
portal_type_ledger_search_kw['portal_type'] = portal_type
portal_type_obj = portal.portal_types[portal_type]
journal_search_kw_list.append(("%s: %s" % (portal_type.getCompactTranslatedTitle(), ledger_obj.getReference()),
"%s: %s" % (portal_type.getTranslatedTitle(), ledger_obj.getReference()),
portal_type_ledger_search_kw))
# kind == 'portal_type'
else:
if ledger_obj_list:
search_kw['default_ledger_uid'] = [ ledger_obj.getUid() for ledger_obj in ledger_obj_list ]
for portal_type in portal.getPortalAccountingTransactionTypeList():
portal_type_obj = portal.portal_types[portal_type]
portal_type_search_kw = search_kw.copy()
portal_type_search_kw['portal_type'] = portal_type
journal_search_kw_list.append((portal_type_obj.getCompactTranslatedTitle(), portal_type_obj.getTranslatedTitle(), portal_type_search_kw))
## search_kw
for journal_code, journal_lib, search_kw in journal_search_kw_list:
portal.portal_catalog.searchAndActivate(
method_id='AccountingTransaction_postFECExtendedResult',
method_kw=method_kw,
activate_kw=activate_kw,
**search_kw)
context.activate(
tag=aggregate_tag,
after_tag=tag,
activity='SQLQueue').AccountingTransactionModule_aggregateFrenchAccountingTransactionFileExtendedForOneJournal(
journal_code,
journal_lib,
active_process=active_process.getRelativeUrl(),
this_journal_active_process=this_journal_active_process)
#### AccountingTransactionModule_viewFrenchAccountingTransactionFileExtendedForPortalType
context.activate(after_tag=(tag, aggregate_tag)).AccountingTransactionModule_aggregateFrenchAccountingTransactionFile(
at_date,
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<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_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/xml</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AccountingTransactionModule_viewJournalAsFECExtendedXML</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<journal xmlns:tal="http://xml.zope.org/namespaces/tal">
<JournalCode tal:content="options/journal_code"></JournalCode>
<JournalLib tal:content="options/journal_lib"></JournalLib>
<tal:block tal:repeat="result options/result_list"><tal:block tal:replace="structure python: result.detail.decode('zlib')"/></tal:block>
</journal>
\ No newline at end of file
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