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

nobody at svn.erp5.org nobody at svn.erp5.org
Sun Sep 17 20:51:24 CEST 2006


Author: jerome
Date: Sun Sep 17 20:51:16 2006
New Revision: 10059

URL: http://svn.erp5.org?rev=10059&view=rev
Log:
accounting transaction with categories are no longer considered as valid.


Modified:
    erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransaction.xml
    erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransactionLines.xml
    erp5/trunk/bt5/erp5_accounting/bt/revision
    erp5/trunk/products/ERP5/tests/testAccounting.py

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=10059&r1=10058&r2=10059&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 Sun Sep 17 20:51:16 2006
@@ -87,24 +87,17 @@
   skip_period_validation = 1\n
 \n
 # do we have to care about destination section ?\n
-check_destination = (transaction.getPortalType() in transaction.getPortalInvoiceTypeList())\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\', \'Category\'])\n
-if source_section is not None and \\\n
-            source_section.getPortalType() == \'Category\' :\n
-  source_section = source_section.getMappingRelatedValue(\n
-            portal_type = \'Organisation\')\n
+                       portal_type=[\'Organisation\', \'Person\'])\n
 if source_section is None:\n
   raise ValidationFailed(\'Source Section is not Defined.\')\n
 \n
 destination_section = transaction.getDestinationSectionValue(\n
-       portal_type = [\'Organisation\', \'Person\', \'Category\'])\n
-if destination_section is not None and \\\n
-       destination_section.getPortalType() == \'Category\' :\n
-  destination_section = destination_section.getMappingRelatedValue(\n
-            portal_type = \'Organisation\')\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
   raise ValidationFailed(\'Destination Section is not Defined.\')\n

Modified: erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransactionLines.xml
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransactionLines.xml?rev=10059&r1=10058&r2=10059&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransactionLines.xml (original)
+++ erp5/trunk/bt5/erp5_accounting/WorkflowTemplateItem/portal_workflow/accounting_workflow/scripts/validateTransactionLines.xml Sun Sep 17 20:51:16 2006
@@ -76,6 +76,8 @@
 \n
 SOURCE, DESTINATION = (\'source\', \'destination\')\n
 transaction = state_change[\'object\']\n
+portal = transaction.getPortalObject()\n
+valid_section_portal_type_list = [\'Person\', \'Organisation\']\n
 N_ = lambda msg, **kw: Message(\'erp5_ui\', msg, **kw)\n
 \n
 # first of all, validate the transaction itself\n
@@ -83,9 +85,9 @@
 \n
 # Get sections.\n
 source_section = transaction.getSourceSectionValue(\n
-                        portal_type=[\'Person\', \'Organisation\'])\n
+                           portal_type=valid_section_portal_type_list)\n
 destination_section = transaction.getDestinationSectionValue(\n
-                        portal_type=[\'Person\', \'Organisation\'])\n
+                           portal_type=valid_section_portal_type_list)\n
 \n
 # do we want to check validity for destination as well?\n
 check_for_destination = 0\n
@@ -131,12 +133,16 @@
     for side in (SOURCE, DESTINATION) :\n
       if side == SOURCE:\n
         account = transaction_line.getSourceValue(portal_type=\'Account\')\n
-        payment          = transaction_line.getSourcePaymentValue()\n
-        third_party      = transaction_line.getDestinationSectionValue()\n
+        payment = transaction_line.getSourcePaymentValue(\n
+                           portal_type=portal.getPortalPaymentNodeTypeList())\n
+        third_party = transaction_line.getDestinationSectionValue(\n
+                           portal_type=valid_section_portal_type_list)\n
       else:\n
         account = transaction_line.getDestinationValue(portal_type=\'Account\')\n
-        payment          = transaction_line.getDestinationPaymentValue()\n
-        third_party      = transaction_line.getSourceSectionValue()\n
+        payment = transaction_line.getDestinationPaymentValue(\n
+                           portal_type=portal.getPortalPaymentNodeTypeList())\n
+        third_party = transaction_line.getSourceSectionValue(\n
+                           portal_type=valid_section_portal_type_list)\n
 \n
       if account is None:\n
         continue\n
@@ -304,8 +310,10 @@
                             <string>DESTINATION</string>
                             <string>_getitem_</string>
                             <string>transaction</string>
+                            <string>_getattr_</string>
+                            <string>portal</string>
+                            <string>valid_section_portal_type_list</string>
                             <string>N_</string>
-                            <string>_getattr_</string>
                             <string>container</string>
                             <string>source_section</string>
                             <string>destination_section</string>

Modified: erp5/trunk/bt5/erp5_accounting/bt/revision
URL: http://svn.erp5.org/erp5/trunk/bt5/erp5_accounting/bt/revision?rev=10059&r1=10058&r2=10059&view=diff
==============================================================================
--- erp5/trunk/bt5/erp5_accounting/bt/revision (original)
+++ erp5/trunk/bt5/erp5_accounting/bt/revision Sun Sep 17 20:51:16 2006
@@ -1,1 +1,1 @@
-41
+46

Modified: erp5/trunk/products/ERP5/tests/testAccounting.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testAccounting.py?rev=10059&r1=10058&r2=10059&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testAccounting.py (original)
+++ erp5/trunk/products/ERP5/tests/testAccounting.py Sun Sep 17 20:51:16 2006
@@ -1303,6 +1303,20 @@
       stepValidateRemoveEmptyLines
     """, quiet=quiet)
 
+  def test_AccountingTransactionValidationRefusedWithCategoriesAsSections(self,
+                                        quiet=QUIET, run=RUN_ALL_TESTS):
+    """Validating a transaction with categories as sections is refused.
+    See http://wiki.erp5.org/Discussion/AccountingProblems """
+    category = self.vendor.getGroupValue()
+    self.assertNotEquals(category, None)
+    transaction = self.createAccountingTransaction(
+                                    source_section_value=category)
+    self.assertRaises(ValidationFailed, self.getWorkflowTool().doActionFor,
+                      transaction, 'stop_action')
+    transaction = self.createAccountingTransaction(
+                                    destination_section_value=category)
+    self.assertRaises(ValidationFailed, self.getWorkflowTool().doActionFor,
+                      transaction, 'stop_action')
 
 if __name__ == '__main__':
   framework()




More information about the Erp5-report mailing list