[Erp5-report] r17344 - in /erp5/trunk/bt5/erp5_accounting: WorkflowTemplateItem/portal_work...

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Nov 1 19:04:44 CET 2007


Author: jerome
Date: Thu Nov  1 19:04:43 2007
New Revision: 17344

URL: http://svn.erp5.org?rev=17344&view=rev
Log:
validateTransaction:  always check date for destination section
Delivery_Build: don't use context.log (this is especially bad in workflow scripts)

Modified:
    erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/Delivery_Build.xml
    erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml
    erp5/trunk/bt5/erp5_accounting/bt/revision

Modified: erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/Delivery_Build.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/Delivery_Build.xml?rev=17344&r1=17343&r2=17344&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/Delivery_Build.xml (original)
+++ erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/Delivery_Build.xml Thu Nov  1 19:04:43 2007
@@ -3,11 +3,8 @@
   <record id="1" aka="AAAAAAAAAAE=">
     <pickle>
       <tuple>
-        <tuple>
-          <string>Products.PythonScripts.PythonScript</string>
-          <string>PythonScript</string>
-        </tuple>
-        <none/>
+        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+        <tuple/>
       </tuple>
     </pickle>
     <pickle>
@@ -71,7 +68,7 @@
             <value> <string>"""\n
   Builds the delivery.\n
 """\n
-\n
+from Products.ERP5Type.Log import log\n
 delivery = sci[\'object\']\n
 delivery_portal_type = delivery.getPortalType()\n
 portal_deliveries = sci.getPortal().portal_deliveries\n
@@ -84,8 +81,8 @@
 if builder_by_ptype.has_key(delivery_portal_type) :\n
   builder = getattr(portal_deliveries, builder_by_ptype[delivery_portal_type], None)\n
   if builder is None :\n
-    context.log(\'accounting_workflow/scripts/Delivery_build\',\n
-                \'unable to build : no builder in %s\' % builder_by_ptype[delivery_portal_type])\n
+    log(\'erp5_accounting\',\n
+        \'unable to build : no builder in %s\' % builder_by_ptype[delivery_portal_type])\n
     return\n
 \n
   ### Kev patch: Generate pay sheet accounting lines (inspired by order_workflow)\n
@@ -174,6 +171,8 @@
                         <value>
                           <tuple>
                             <string>sci</string>
+                            <string>Products.ERP5Type.Log</string>
+                            <string>log</string>
                             <string>_getitem_</string>
                             <string>delivery</string>
                             <string>_getattr_</string>
@@ -183,7 +182,6 @@
                             <string>getattr</string>
                             <string>None</string>
                             <string>builder</string>
-                            <string>context</string>
                             <string>PRIORITY</string>
                             <string>pay_sheet</string>
                             <string>previous_tag</string>

Modified: erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml?rev=17344&r1=17343&r2=17344&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml (original)
+++ erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml Thu Nov  1 19:04:43 2007
@@ -3,11 +3,8 @@
   <record id="1" aka="AAAAAAAAAAE=">
     <pickle>
       <tuple>
-        <tuple>
-          <string>Products.PythonScripts.PythonScript</string>
-          <string>PythonScript</string>
-        </tuple>
-        <none/>
+        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
+        <tuple/>
       </tuple>
     </pickle>
     <pickle>
@@ -86,10 +83,6 @@
 if transition.id in (\'plan_action\', \'confirm_action\') :\n
   skip_period_validation = 1\n
 \n
-# do we have to care about destination section ?\n
-check_destination = (transaction.getPortalType() in\n
-                     transaction.getPortalInvoiceTypeList())\n
-\n
 # Get sections and a currency.\n
 source_section = transaction.getSourceSectionValue(\n
                        portal_type=[\'Organisation\', \'Person\'])\n
@@ -99,7 +92,8 @@
 destination_section = transaction.getDestinationSectionValue(\n
                 portal_type=[\'Organisation\', \'Person\'])\n
 # if it\'s not an invoice, then we can validate without destination\n
-if destination_section is None and check_destination :\n
+if destination_section is None and \\\n
+    transaction.getPortalType() in transaction.getPortalInvoiceTypeList():\n
   raise ValidationFailed(N_(\'Destination Section is not Defined.\'))\n
 \n
 currency = transaction.getResource(portal_type = \'Currency\')\n
@@ -114,40 +108,42 @@
   raise ValidationFailed(N_(\'Date is not Defined\'))\n
 else:\n
   if not skip_period_validation :\n
-    valid_date = False\n
     # check the date is in an opened period\n
-    transaction_date = transaction.getStartDate().earliestTime()\n
-\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
-    if len(openned_accounting_period_list) == 0 :\n
-      # if the entity doesn\'t have any accounting period, we can\n
-      # consider that they do not want to use accounting periods or\n
-      # we do not account from their side.\n
-      valid_date = True\n
-    for apd in openned_accounting_period_list:\n
-      apd = apd.getObject()\n
-      if apd.getStartDate().Date() <= transaction_date.Date() <= apd.getStopDate().Date():\n
+    if source_section is not None:\n
+      valid_date = False\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
+      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
+        # consider that they do not want to use accounting periods or\n
+        # we do not account from their side.\n
         valid_date = True\n
-    if not valid_date :\n
-      raise ValidationFailed(N_("Date is not in an opened Accounting Period "\n
-                                "for source section"))\n
+      for apd in openned_accounting_period_list:\n
+        apd = apd.getObject()\n
+        if apd.getStartDate().Date() <= transaction_date.Date() <= apd.getStopDate().Date():\n
+          valid_date = True\n
+      if not valid_date:\n
+        raise ValidationFailed(N_("Date is not in an opened Accounting Period "\n
+                                  "for source section"))\n
     # do the same for destination section \n
-    if check_destination :\n
+    if destination_section is not None:\n
       valid_date = False\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
-      if len(openned_accounting_period_list) == 0:\n
+      if not len(destination_section.contentValues(\n
+               filter=dict(portal_type="Accounting Period"))):\n
         valid_date = True\n
       for apd in openned_accounting_period_list:\n
         apd = apd.getObject()\n
         if apd.getStartDate().Date() <= transaction_date.Date() <= apd.getStopDate().Date():\n
           valid_date = True\n
-      if not valid_date :\n
+      if not valid_date:\n
         raise ValidationFailed(N_("Date is not in an opened Accounting Period "\n
                                   "for destination section"))\n
 
@@ -223,7 +219,6 @@
                             <string>_getattr_</string>
                             <string>skip_period_validation</string>
                             <string>transition</string>
-                            <string>check_destination</string>
                             <string>source_section</string>
                             <string>None</string>
                             <string>destination_section</string>
@@ -233,6 +228,7 @@
                             <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>

Modified: erp5/trunk/bt5/erp5_accounting/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/bt/revision?rev=17344&r1=17343&r2=17344&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/bt/revision (original)
+++ erp5/trunk/bt5/erp5_accounting/bt/revision Thu Nov  1 19:04:43 2007
@@ -1,1 +1,1 @@
-465
+468




More information about the Erp5-report mailing list