[Erp5-report] r18217 - in /erp5/trunk/products/ERP5: PropertySheet/ tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Mon Dec 10 18:44:31 CET 2007


Author: jerome
Date: Mon Dec 10 18:44:30 2007
New Revision: 18217

URL: http://svn.erp5.org?rev=18217&view=rev
Log:
Add constraints for Accounts

Modified:
    erp5/trunk/products/ERP5/PropertySheet/Account.py
    erp5/trunk/products/ERP5/tests/testAccounting.py

Modified: erp5/trunk/products/ERP5/PropertySheet/Account.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/PropertySheet/Account.py?rev=18217&r1=18216&r2=18217&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/PropertySheet/Account.py (original)
+++ erp5/trunk/products/ERP5/PropertySheet/Account.py Mon Dec 10 18:44:30 2007
@@ -42,3 +42,25 @@
  )
 
   _categories = ( 'account_type', 'gap', 'pcg', 'financial_section', )
+
+  _constraints = (
+    { 'id': 'account_type_existance',
+      'description': 'Account Type must be set',
+      'type': 'CategoryMembershipArity',
+      'min_arity': 1,
+      'max_arity': 1,
+      'portal_type': ('Category', ),
+      'base_category' : ('account_type',),
+      'condition' : 'python: object.getValidationState() not'
+                     ' in ("invalidated", "deleted")'
+    },
+    { 'id': 'gap_existance',
+      'description': 'GAP must be set',
+      'type': 'CategoryMembershipArity',
+      'min_arity': 1,
+      'portal_type': ('Category', ),
+      'base_category' : ('gap',),
+      'condition' : 'python: object.getValidationState() not'
+                     ' in ("invalidated", "deleted")'
+    },
+ )

Modified: erp5/trunk/products/ERP5/tests/testAccounting.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testAccounting.py?rev=18217&r1=18216&r2=18217&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testAccounting.py (original)
+++ erp5/trunk/products/ERP5/tests/testAccounting.py Mon Dec 10 18:44:30 2007
@@ -218,6 +218,31 @@
     # some default content created.
     return ('erp5_base', 'erp5_pdm', 'erp5_trade', 'erp5_accounting',
             'erp5_accounting_ui_test')
+
+
+class TestAccounts(AccountingTestCase):
+  """Tests Accounts.
+  """
+  def test_AccountValidation(self):
+    # Accounts need a gap category and an account_type category to be valid
+    account = self.portal.account_module.newContent(portal_type='Account')
+    self.assertEquals(2, len(account.checkConsistency()))
+    account.setAccountType('equity')
+    self.assertEquals(1, len(account.checkConsistency()))
+    account.setGap('my_country/my_accounting_standards/1')
+    self.assertEquals(0, len(account.checkConsistency()))
+    
+  def test_AccountWorkflow(self):
+    account = self.portal.account_module.newContent(portal_type='Account')
+    self.assertEquals('draft', account.getValidationState())
+    doActionFor = self.portal.portal_workflow.doActionFor
+    self.assertRaises(ValidationFailed, doActionFor, account,
+                          'validate_action')
+    account.setAccountType('equity')
+    account.setGap('my_country/my_accounting_standards/1')
+    doActionFor(account, 'validate_action')
+    self.assertEquals('validated', account.getValidationState())
+
 
 
 class TestTransactionValidation(AccountingTestCase):
@@ -2738,6 +2763,7 @@
 def test_suite():
   suite = unittest.TestSuite()
   suite.addTest(unittest.makeSuite(TestAccounting))
+  suite.addTest(unittest.makeSuite(TestAccounts))
   suite.addTest(unittest.makeSuite(TestClosingPeriod))
   suite.addTest(unittest.makeSuite(TestTransactionValidation))
   return suite




More information about the Erp5-report mailing list