Index: main/waeup.ikoba/trunk/src/waeup/ikoba/customers/batching.py
===================================================================
--- main/waeup.ikoba/trunk/src/waeup/ikoba/customers/batching.py	(revision 12246)
+++ main/waeup.ikoba/trunk/src/waeup/ikoba/customers/batching.py	(revision 12250)
@@ -381,5 +381,5 @@
 
     location_fields = []
-    additional_fields = ['document_id', 'class_name']
+    additional_fields = ['class_name']
     additional_headers = ['class_name']
 
@@ -422,4 +422,8 @@
         document_id = row['document_id'].strip('#')
         parent[document_id] = obj
+        # Reset _curr_doc_id if document_id has been imported
+        site = grok.getSite()
+        if row.get('document_id', None) not in (None, IGNORE_MARKER):
+            site._curr_doc_id -= 1
         return
 
@@ -445,4 +449,12 @@
             if class_name != self.factory_name.strip('waeup.'):
                 errs.append(('class_name','wrong processor'))
+        try:
+            # Correct doc_id counter. As the IConverter for documents
+            # creates document objects that are not used afterwards, we
+            # have to fix the site-wide doc_id counter.
+            site = grok.getSite()
+            site._curr_doc_id -= 1
+        except (KeyError, TypeError, AttributeError):
+                pass
         # We have to check document_id.
         document_id = row.get('document_id', None)
@@ -478,5 +490,5 @@
 
     location_fields = []
-    additional_fields = ['contract_id', 'class_name']
+    additional_fields = ['class_name']
     additional_headers = ['class_name']
 
@@ -519,4 +531,8 @@
         contract_id = row['contract_id'].strip('#')
         parent[contract_id] = obj
+        # Reset _curr_con_id if contract_id has been imported
+        site = grok.getSite()
+        if row.get('contract_id', None) not in (None, IGNORE_MARKER):
+            site._curr_con_id -= 1
         return
 
@@ -542,4 +558,12 @@
             if class_name != self.factory_name.strip('waeup.'):
                 errs.append(('class_name','wrong processor'))
+        try:
+            # Correct con_id counter. As the IConverter for contracts
+            # creates contract objects that are not used afterwards, we
+            # have to fix the site-wide con_id counter.
+            site = grok.getSite()
+            site._curr_con_id -= 1
+        except (KeyError, TypeError, AttributeError):
+                pass
         # We have to check contract_id.
         contract_id = row.get('contract_id', None)
Index: main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py
===================================================================
--- main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py	(revision 12246)
+++ main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_batching.py	(revision 12250)
@@ -322,4 +322,5 @@
 
     def test_addEntry(self):
+        self.assertEqual(self.app._curr_doc_id, 102)
         self.assertEqual(len(self.customer['documents'].keys()),1)
         document1 = createObject(u'waeup.CustomerSampleDocument')
@@ -330,8 +331,9 @@
         self.assertEqual(len(self.customer['documents'].keys()),2)
         self.assertEqual(self.customer['documents']['d234'].document_id, 'd234')
-        document2 = createObject(u'waeup.CustomerSampleDocument')
-        document1.document_id = 'nonsense'
+        # _curr_doc_id hasn't changed
+        self.assertEqual(self.app._curr_doc_id, 102)
 
     def test_checkConversion(self):
+        self.assertEqual(self.app._curr_doc_id, 102)
         errs, inv_errs, conv_dict = self.processor.checkConversion(
             dict(document_id='d126', class_name='CustomerSampleDocument'))
@@ -347,4 +349,6 @@
             mode='update'))
         self.assertEqual(len(errs),1)
+        # _curr_doc_id hasn't changed
+        self.assertEqual(self.app._curr_doc_id, 102)
 
     def test_import(self):
@@ -455,4 +459,5 @@
 
     def test_addEntry(self):
+        self.assertEqual(self.app._curr_con_id, 102)
         self.assertEqual(len(self.customer['contracts'].keys()),1)
         contract1 = createObject(u'waeup.SampleContract')
@@ -463,8 +468,9 @@
         self.assertEqual(len(self.customer['contracts'].keys()),2)
         self.assertEqual(self.customer['contracts']['c234'].contract_id, 'c234')
-        contract2 = createObject(u'waeup.SampleContract')
-        contract1.contract_id = 'nonsense'
+        # _curr_con_id hasn't changed
+        self.assertEqual(self.app._curr_con_id, 102)
 
     def test_checkConversion(self):
+        self.assertEqual(self.app._curr_con_id, 102)
         errs, inv_errs, conv_dict = self.processor.checkConversion(
             dict(contract_id='c126', class_name='SampleContract',
@@ -477,4 +483,6 @@
             dict(contract_id='c127', class_name='WrongContract'))
         self.assertEqual(len(errs),1)
+        # _curr_con_id hasn't changed
+        self.assertEqual(self.app._curr_con_id, 102)
 
     def test_import(self):
