From feb2dff05771c93e5c62ad1b1495bafaee832b29 Mon Sep 17 00:00:00 2001 From: Jaysinh Shukla Date: Wed, 16 Jul 2014 16:48:23 +0530 Subject: [PATCH] [FIX] website_forum: Preventing user from posting answers on [Close] and [Deleted] questions. Solving issue of Red background when question is deleted --- addons/website_forum/models/forum.py | 3 +++ addons/website_forum/views/website_forum.xml | 21 ++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/addons/website_forum/models/forum.py b/addons/website_forum/models/forum.py index 891ce3b982d..d5068382c1f 100644 --- a/addons/website_forum/models/forum.py +++ b/addons/website_forum/models/forum.py @@ -315,6 +315,9 @@ class Post(osv.Model): create_context = dict(context, mail_create_nolog=True) post_id = super(Post, self).create(cr, uid, vals, context=create_context) post = self.browse(cr, SUPERUSER_ID, post_id, context=context) # SUPERUSER_ID to avoid read access rights issues when creating + # deleted or closed questions + if post.parent_id and (post.parent_id.state == 'close' or post.parent_id.active == False): + osv.except_osv(_('Error !'), _('Posting answer on [Deleted] or [Closed] question is prohibited')) # karma-based access if post.parent_id and not post.can_ask: raise KarmaError('Not enough karma to create a new question') diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml index 7fafd93cc7b..761ef8e8839 100644 --- a/addons/website_forum/views/website_forum.xml +++ b/addons/website_forum/views/website_forum.xml @@ -455,7 +455,7 @@