From 01cacb4b671b2363320fa565ddb5ec962254c9ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com> Date: Tue, 20 Nov 2007 10:54:01 +0000 Subject: [PATCH] Don't check accounting period dates if no accounts are defined for this side git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17698 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../scripts/validateTransaction.xml | 30 ++++++++++++++++--- bt5/erp5_accounting/bt/revision | 2 +- 2 files changed, 27 insertions(+), 5 deletions(-) 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 7d22e0d57a..c1efa26315 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 @@ -104,18 +104,29 @@ if not currency :\n if not transaction.getStartDate() and transaction.getStopDate():\n transaction.setStartDate(transaction.getStopDate())\n \n + \n +transaction_line_list = transaction.getMovementList(\n + portal_type=transaction.getPortalAccountingMovementTypeList())\n if not transaction.getStartDate() :\n raise ValidationFailed(N_(\'Date is not Defined\'))\n else:\n if not skip_period_validation :\n # check the date is in an opened period\n if source_section is not None:\n + # if we don\'t have any accounts on this side, we don\'t enforce date\n + # checks\n valid_date = False\n + no_accounts = True\n + for line in transaction_line_list:\n + if line.getSource():\n + no_accounts = False\n + if no_accounts:\n + valid_date = True\n transaction_date = transaction.getStartDate().earliestTime()\n openned_accounting_period_list = source_section.searchFolder(\n portal_type="Accounting Period",\n # planned is for b/w compatibility\n - simulation_state=("planned", \'started\'))\n + simulation_state=(\'planned\', \'started\'))\n if not len(source_section.contentValues(\n filter=dict(portal_type="Accounting Period"))):\n # if the entity doesn\'t have any accounting period, we can\n @@ -131,11 +142,19 @@ else:\n "for source section"))\n # do the same for destination section \n if destination_section is not None:\n + # if we don\'t have any accounts on this side, we don\'t enforce date\n + # checks\n valid_date = False\n + no_accounts = True\n + for line in transaction_line_list:\n + if line.getDestination():\n + no_accounts = False\n + if no_accounts:\n + valid_date = True\n transaction_date = transaction.getStopDate().earliestTime()\n openned_accounting_period_list = destination_section.searchFolder(\n portal_type = "Accounting Period",\n - simulation_state = (\'planned\', \'started\'))\n + simulation_state=(\'planned\', \'started\'))\n if not len(destination_section.contentValues(\n filter=dict(portal_type="Accounting Period"))):\n valid_date = True\n @@ -223,14 +242,17 @@ else:\n <string>None</string> <string>destination_section</string> <string>currency</string> + <string>transaction_line_list</string> <string>False</string> <string>valid_date</string> + <string>True</string> + <string>no_accounts</string> + <string>_getiter_</string> + <string>line</string> <string>transaction_date</string> <string>openned_accounting_period_list</string> <string>len</string> <string>dict</string> - <string>True</string> - <string>_getiter_</string> <string>apd</string> </tuple> </value> diff --git a/bt5/erp5_accounting/bt/revision b/bt5/erp5_accounting/bt/revision index eb1f49486a..03164581e1 100644 --- a/bt5/erp5_accounting/bt/revision +++ b/bt5/erp5_accounting/bt/revision @@ -1 +1 @@ -500 \ No newline at end of file +503 \ No newline at end of file -- 2.30.9