From 52a76b72ee454c672161a178fa14b34799385532 Mon Sep 17 00:00:00 2001 From: "rpa (Open ERP)" Date: Tue, 20 Apr 2010 11:52:02 +0530 Subject: [PATCH] [IMP]: crm: Improvement for case unlink: Deleting case should also delete its history and logs bzr revid: rpa@tinyerp.com-20100420062202-k1ezgmdft6j1hfd6 --- addons/crm/crm.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/crm/crm.py b/addons/crm/crm.py index adfbf0ca772..afcc2301883 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -432,11 +432,20 @@ class crm_case(osv.osv): """ if not context: context = {} + + hist_obj = self.pool.get('crm.case.history') + log_obj = self.pool.get('crm.case.log') for case in self.browse(cr, uid, ids, context): if (not case.section_id.allow_unlink) and (case.state <> 'draft'): raise osv.except_osv(_('Warning !'), _('You can not delete this case. You should better cancel it.')) + + # Also removing history and logs + history_ids = map(lambda x: x.id, case.history_line) + log_ids = map(lambda x: x.id, case.log_ids) + hist_obj.unlink(cr, uid, history_ids, context=context) + log_obj.unlink(cr, uid, log_ids, context=context) return super(crm_case, self).unlink(cr, uid, ids, context) def stage_next(self, cr, uid, ids, context=None):