From d5bcc4176666f15c48665b3b9db5b471c5bd5e6f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Mon, 8 Dec 2008 12:33:01 +0000
Subject: [PATCH] Implement "delete bug lines after cloning a bug"
 https://svn.erp5.org/?view=rev&revision=24758 in the class, because the user
 may not have permissions to use manage_delObjects Add test this time

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24830 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5/Document/Bug.py  | 7 +++++++
 product/ERP5/tests/testBug.py | 4 +++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/product/ERP5/Document/Bug.py b/product/ERP5/Document/Bug.py
index f78ef3bf57..4a010de9af 100644
--- a/product/ERP5/Document/Bug.py
+++ b/product/ERP5/Document/Bug.py
@@ -57,6 +57,7 @@ class Bug(Ticket):
                       , PropertySheet.Movement
                       , PropertySheet.Bug
                       )
+
     def SearchableText(self):
       """ Used by the catalog for basic full text indexing """
       full_text = []
@@ -67,3 +68,9 @@ class Bug(Ticket):
                                   self.getDescription(),
                                   ' '.join(full_text))
 
+    def manage_afterClone(self, item):
+      Ticket.manage_afterClone(self, item)
+      # delete existing bug lines
+      self.manage_delObjects(list(self.contentIds(
+                              filter=dict(portal_type='Bug Line'))))
+
diff --git a/product/ERP5/tests/testBug.py b/product/ERP5/tests/testBug.py
index 6ede0fe753..e177010aab 100644
--- a/product/ERP5/tests/testBug.py
+++ b/product/ERP5/tests/testBug.py
@@ -304,9 +304,10 @@ class TestBug(ERP5TypeTestCase):
       Create a dummy bug
     """
     bug_to_clone = sequence.get('bug')
+    self.assertNotEquals(len(bug_to_clone.contentValues()), 0)
     bug = bug_to_clone.Base_createCloneDocument(batch_mode=1)
     self.assertEquals("#%s" % bug.getId(), bug.getReference())
-    #self.assertEquals(bug_message.getSourceTradeValue().getTitle(), 'dummy')
+    self.assertEquals(len(bug.contentValues()), 0)
 
   def stepOpenBug(self, sequence=None, sequence_list=None, **kw):
     """
@@ -501,6 +502,7 @@ class TestBug(ERP5TypeTestCase):
     sequence_list = SequenceList()
     step_list = [ 'stepCreateBug',
                   'stepCheckBugInit',
+                  'stepOpenBug',
                   'stepCloneAndCheckBug'
                 ]
     sequence_string = ' '.join(step_list)
-- 
2.30.9