From 6549fb6c1236c3e6ad374d26b8ba1820fe5dbcc9 Mon Sep 17 00:00:00 2001 From: Yoshinori Okuji <yo@nexedi.com> Date: Wed, 8 Sep 2010 09:27:16 +0000 Subject: [PATCH] 2010-09-08 yo * Auto-fill mirror accounts, if necessary, before running the accounting transaction constraint. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@38190 20353a03-c40f-0410-a6d1-a30d3c3de9de --- ...ransaction_setDefaultMirrorAccountList.xml | 162 ++++++++++++++++++ .../scripts/validateTransaction.xml | 8 +- bt5/erp5_accounting/bt/change_log | 3 + bt5/erp5_accounting/bt/revision | 2 +- .../bt/template_catalog_search_key_list | 0 5 files changed, 170 insertions(+), 5 deletions(-) create mode 100644 bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_setDefaultMirrorAccountList.xml create mode 100644 bt5/erp5_accounting/bt/template_catalog_search_key_list diff --git a/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_setDefaultMirrorAccountList.xml b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_setDefaultMirrorAccountList.xml new file mode 100644 index 0000000000..56bc95c00c --- /dev/null +++ b/bt5/erp5_accounting/SkinTemplateItem/portal_skins/erp5_accounting/AccountingTransaction_setDefaultMirrorAccountList.xml @@ -0,0 +1,162 @@ +<?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>_body</string> </key> + <value> <string># Auto-fill mirror accounts in transaction lines automatically, if necessary.\n +portal = context.getPortalObject()\n +movement_data_list = []\n +has_source = False\n +has_destination = False\n +for movement in context.contentValues(portal_type=portal.getPortalAccountingMovementTypeList()):\n + source_account = movement.getSourceValue(portal_type=\'Account\')\n + destination_account = movement.getDestinationValue(portal_type=\'Account\')\n + if source_account is not None:\n + has_source = True\n + if destination_account is not None:\n + has_destination = True\n + # Interested in movements which lack one side only.\n + if (source_account is not None) ^ (destination_account is not None):\n + movement_data_list((movement, source_account, destination_account))\n +\n +# If both are true, mirror accounting is used.\n +if has_source and has_destination:\n + for movement, source_account, destination_account in movement_data_list:\n + if source_account is None:\n + account = destination_account\n + base_category = \'source\'\n + else:\n + account = source_account\n + base_category = \'destination\'\n + \n + mirror_account = account.getDefaultDestination()\n + if mirror_account:\n + movement.setProperty(base_category, mirror_account)\n +</string> </value> + </item> + <item> + <key> <string>_code</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>**kw</string> </value> + </item> + <item> + <key> <string>errors</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>func_code</string> </key> + <value> + <object> + <klass> + <global name="FuncCode" module="Shared.DC.Scripts.Signature"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>co_argcount</string> </key> + <value> <int>0</int> </value> + </item> + <item> + <key> <string>co_varnames</string> </key> + <value> + <tuple> + <string>kw</string> + <string>_getattr_</string> + <string>context</string> + <string>portal</string> + <string>movement_data_list</string> + <string>False</string> + <string>has_source</string> + <string>has_destination</string> + <string>_getiter_</string> + <string>movement</string> + <string>source_account</string> + <string>destination_account</string> + <string>None</string> + <string>True</string> + <string>account</string> + <string>base_category</string> + <string>mirror_account</string> + </tuple> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>func_defaults</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>AccountingTransaction_setDefaultMirrorAccountList</string> </value> + </item> + <item> + <key> <string>warnings</string> </key> + <value> + <tuple/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml b/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml index f23a002d24..a8a477719f 100644 --- a/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml +++ b/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml @@ -2,10 +2,7 @@ <ZopeData> <record id="1" aka="AAAAAAAAAAE="> <pickle> - <tuple> - <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> - <tuple/> - </tuple> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> </pickle> <pickle> <dictionary> @@ -68,6 +65,9 @@ transaction = state_change[\'object\']\n if not transaction.getStartDate() and transaction.getStopDate():\n transaction.setStartDate(transaction.getStopDate())\n \n +# XXX auto-fill mirror accounts, if necessary.\n +transaction.AccountingTransaction_setDefaultMirrorAccountList()\n +\n # Check constraints\n transaction.Base_checkConsistency()\n \n diff --git a/bt5/erp5_accounting/bt/change_log b/bt5/erp5_accounting/bt/change_log index 81ada87f3b..6e9ac5cfea 100644 --- a/bt5/erp5_accounting/bt/change_log +++ b/bt5/erp5_accounting/bt/change_log @@ -1,3 +1,6 @@ +2010-09-08 yo +* Auto-fill mirror accounts, if necessary, before running the accounting transaction constraint. + 2010-09-08 yusei Revert my change on AccountingTransactionModule_getJournalSectionLineList at 2010-09-02. diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision index 90dfef9516..a41bc3f36a 100644 --- a/bt5/erp5_accounting/bt/revision +++ b/bt5/erp5_accounting/bt/revision @@ -1 +1 @@ -1349 \ No newline at end of file +1350 \ No newline at end of file diff --git a/bt5/erp5_accounting/bt/template_catalog_search_key_list b/bt5/erp5_accounting/bt/template_catalog_search_key_list new file mode 100644 index 0000000000..e69de29bb2 -- 2.30.9