Commit 7524d031 authored by Jérome Perrin's avatar Jérome Perrin

accounting transaction with categories are no longer considered as valid.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10059 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 01208848
...@@ -87,24 +87,17 @@ if transition.id in (\'plan_action\', \'confirm_action\') :\n ...@@ -87,24 +87,17 @@ if transition.id in (\'plan_action\', \'confirm_action\') :\n
skip_period_validation = 1\n skip_period_validation = 1\n
\n \n
# do we have to care about destination section ?\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 \n
# Get sections and a currency.\n # Get sections and a currency.\n
source_section = transaction.getSourceSectionValue(\n source_section = transaction.getSourceSectionValue(\n
portal_type = [\'Organisation\', \'Person\', \'Category\'])\n portal_type=[\'Organisation\', \'Person\'])\n
if source_section is not None and \\\n
source_section.getPortalType() == \'Category\' :\n
source_section = source_section.getMappingRelatedValue(\n
portal_type = \'Organisation\')\n
if source_section is None:\n if source_section is None:\n
raise ValidationFailed(\'Source Section is not Defined.\')\n raise ValidationFailed(\'Source Section is not Defined.\')\n
\n \n
destination_section = transaction.getDestinationSectionValue(\n destination_section = transaction.getDestinationSectionValue(\n
portal_type = [\'Organisation\', \'Person\', \'Category\'])\n portal_type=[\'Organisation\', \'Person\'])\n
if destination_section is not None and \\\n
destination_section.getPortalType() == \'Category\' :\n
destination_section = destination_section.getMappingRelatedValue(\n
portal_type = \'Organisation\')\n
# if it\'s not an invoice, then we can validate without destination\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 check_destination :\n
raise ValidationFailed(\'Destination Section is not Defined.\')\n raise ValidationFailed(\'Destination Section is not Defined.\')\n
......
...@@ -76,6 +76,8 @@ from Products.ERP5Type.Message import Message\n ...@@ -76,6 +76,8 @@ from Products.ERP5Type.Message import Message\n
\n \n
SOURCE, DESTINATION = (\'source\', \'destination\')\n SOURCE, DESTINATION = (\'source\', \'destination\')\n
transaction = state_change[\'object\']\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_ = lambda msg, **kw: Message(\'erp5_ui\', msg, **kw)\n
\n \n
# first of all, validate the transaction itself\n # first of all, validate the transaction itself\n
...@@ -83,9 +85,9 @@ container.validateTransaction(state_change)\n ...@@ -83,9 +85,9 @@ container.validateTransaction(state_change)\n
\n \n
# Get sections.\n # Get sections.\n
source_section = transaction.getSourceSectionValue(\n source_section = transaction.getSourceSectionValue(\n
portal_type=[\'Person\', \'Organisation\'])\n portal_type=valid_section_portal_type_list)\n
destination_section = transaction.getDestinationSectionValue(\n destination_section = transaction.getDestinationSectionValue(\n
portal_type=[\'Person\', \'Organisation\'])\n portal_type=valid_section_portal_type_list)\n
\n \n
# do we want to check validity for destination as well?\n # do we want to check validity for destination as well?\n
check_for_destination = 0\n check_for_destination = 0\n
...@@ -131,12 +133,16 @@ if transaction.getPortalType() not in (\'Balance Transaction\',) :\n ...@@ -131,12 +133,16 @@ if transaction.getPortalType() not in (\'Balance Transaction\',) :\n
for side in (SOURCE, DESTINATION) :\n for side in (SOURCE, DESTINATION) :\n
if side == SOURCE:\n if side == SOURCE:\n
account = transaction_line.getSourceValue(portal_type=\'Account\')\n account = transaction_line.getSourceValue(portal_type=\'Account\')\n
payment = transaction_line.getSourcePaymentValue()\n payment = transaction_line.getSourcePaymentValue(\n
third_party = transaction_line.getDestinationSectionValue()\n portal_type=portal.getPortalPaymentNodeTypeList())\n
third_party = transaction_line.getDestinationSectionValue(\n
portal_type=valid_section_portal_type_list)\n
else:\n else:\n
account = transaction_line.getDestinationValue(portal_type=\'Account\')\n account = transaction_line.getDestinationValue(portal_type=\'Account\')\n
payment = transaction_line.getDestinationPaymentValue()\n payment = transaction_line.getDestinationPaymentValue(\n
third_party = transaction_line.getSourceSectionValue()\n portal_type=portal.getPortalPaymentNodeTypeList())\n
third_party = transaction_line.getSourceSectionValue(\n
portal_type=valid_section_portal_type_list)\n
\n \n
if account is None:\n if account is None:\n
continue\n continue\n
...@@ -304,8 +310,10 @@ transaction.AccountingTransaction_deleteEmptyLines(redirect=0)\n ...@@ -304,8 +310,10 @@ transaction.AccountingTransaction_deleteEmptyLines(redirect=0)\n
<string>DESTINATION</string> <string>DESTINATION</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>transaction</string> <string>transaction</string>
<string>N_</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>portal</string>
<string>valid_section_portal_type_list</string>
<string>N_</string>
<string>container</string> <string>container</string>
<string>source_section</string> <string>source_section</string>
<string>destination_section</string> <string>destination_section</string>
......
41 46
\ No newline at end of file \ No newline at end of file
...@@ -1303,6 +1303,20 @@ class TestAccounting(ERP5TypeTestCase): ...@@ -1303,6 +1303,20 @@ class TestAccounting(ERP5TypeTestCase):
stepValidateRemoveEmptyLines stepValidateRemoveEmptyLines
""", quiet=quiet) """, 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__': if __name__ == '__main__':
framework() framework()
......
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