Index: /main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
===================================================================
--- /main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py	(revision 12144)
+++ /main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py	(revision 12145)
@@ -31,9 +31,11 @@
 from zope.component import createObject, queryUtility, getUtility
 from zope.component.hooks import setSite, clearSite
+from zope.schema.interfaces import ConstraintNotSatisfied
 from zope.catalog.interfaces import ICatalog
 from zope.security.interfaces import Unauthorized
 from zope.securitypolicy.interfaces import IPrincipalRoleManager
 from zope.testbrowser.testing import Browser
-from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
+from hurry.workflow.interfaces import (
+    IWorkflowInfo, IWorkflowState, InvalidTransitionError)
 from waeup.ikoba.testing import FunctionalLayer, FunctionalTestCase
 from waeup.ikoba.app import Company
@@ -1209,2 +1211,19 @@
         print "Sample contract_slip.pdf written to %s" % path
 
+    def test_contract_approval(self):
+        # This is not a UI test. It just tests the approval
+        # of contracts.
+        self.assertRaises(ConstraintNotSatisfied,
+            self.contract.document_object, self.document)
+        # Document must be at least submitted
+        IWorkflowState(self.document).setState('submitted')
+        self.contract.document_object = self.document
+        IWorkflowState(self.contract).setState('submitted')
+        self.assertRaises(InvalidTransitionError,
+            IWorkflowInfo(self.contract).fireTransition, 'approve')
+        # Document must be verified for the approval of contracts
+        IWorkflowState(self.document).setState('verified')
+        IWorkflowInfo(self.contract).fireTransition('approve')
+        self.assertEqual(IWorkflowState(self.contract).getState(), 'approved')
+        return
+
Index: /main/waeup.ikoba/trunk/src/waeup/ikoba/customers/workflow.py
===================================================================
--- /main/waeup.ikoba/trunk/src/waeup/ikoba/customers/workflow.py	(revision 12144)
+++ /main/waeup.ikoba/trunk/src/waeup/ikoba/customers/workflow.py	(revision 12145)
@@ -22,5 +22,6 @@
 from zope.component import getUtility
 from hurry.workflow.workflow import Transition, WorkflowState, NullCondition
-from hurry.workflow.interfaces import IWorkflowState, IWorkflowTransitionEvent
+from hurry.workflow.interfaces import (
+    IWorkflowState, IWorkflowTransitionEvent, InvalidTransitionError)
 from waeup.ikoba.interfaces import (
     IObjectHistory, IIkobaWorkflowInfo, IIkobaUtils,
@@ -28,5 +29,6 @@
     SUBMITTED, VERIFIED, REJECTED, EXPIRED)
 from waeup.ikoba.interfaces import MessageFactory as _
-from waeup.ikoba.workflow import IkobaWorkflow, IkobaWorkflowInfo
+from waeup.ikoba.workflow import (
+    IkobaWorkflow, IkobaWorkflowInfo)
 from waeup.ikoba.customers.interfaces import (
     ICustomer, ICustomersUtils,
@@ -238,8 +240,17 @@
 
 @grok.subscribe(IContract, IWorkflowTransitionEvent)
-def handle_document_transition_event(obj, event):
-    """Append message to contract history and log file and update
+def handle_contract_transition_event(obj, event):
+    """Append message to contract history and log file, also update
     last_transition_date when transition happened.
-    """
+
+    Undo the approval of contract and raise an exception if contract
+    does not meet the requirements for approval.
+    """
+    if event.transition.destination == APPROVED:
+        if not obj.is_approvable:
+            # Undo transition and raise an exception.
+            IWorkflowState(obj).setState(event.transition.source)
+            raise InvalidTransitionError(
+                "Documents must be verified first.")
     msg = event.transition.user_data['msg']
     history = IObjectHistory(obj)
