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')
<!-- Specific Post Layout -->
<template id="post_description_full" name="Question Navigation">
<t t-call="website_forum.header">
- <div t-attf-class="question #{not question.active and 'alert alert-danger' or ''}">
+ <div t-attf-class="question">
<div class="col-md-2 hidden-xs text-center">
<t t-call="website_forum.vote">
<t t-set="post" t-value="question"/>
t-attf-class="favourite_question no-decoration fa fa-2x fa-star #{question.user_favourite and 'forum_favourite_question' or ''}"/>
</div>
</div>
- <div class="col-md-10">
+ <div t-attf-class="col-md-10 #{not question.active and 'alert alert-danger' or ''}">
<h1 class="mt0">
<a t-attf-href="/forum/#{ slug(forum) }/question/#{ slug(question) }" t-field="question.name"/>
<span t-if="not question.active"><b> [Deleted]</b></span>
</div>
</div>
</div>
- <div t-if="not question.uid_has_answered">
+ <div t-if="not question.uid_has_answered and question.state != 'close' and question.active != False">
<t t-call="website_forum.post_answer"/>
</div>
<div t-if="question.uid_has_answered" class="mb16">
class="close comment_delete">&times;</button>
<span t-field="message.body"/>
<t t-set="required_karma" t-value="message.author_id.id == user.partner_id.id and object.forum_id.karma_comment_convert_own or object.forum_id.karma_comment_convert_all"/>
- <t t-call="website_forum.link_button">
- <t t-set="url" t-value="'/forum/' + slug(forum) + '/post/' + slug(object) + '/comment/' + slug(message) + '/convert_to_answer'"/>
- <t t-set="label" t-value="'Convert as an answer'"/>
- <t t-set="karma" t-value="user.karma<required_karma and required_karma or 0"/>
- <t t-set="classes" t-value="'fa-magic pull-right'"/>
+ <t t-if="(object.parent_id and object.parent_id.state != 'close' and object.parent_id.active != False) or (not object.parent_id and object.state != 'close' and object.active != False)">
+ <t t-set="allow_post_comment" t-value="True" />
+ </t>
+ <t t-if="allow_post_comment">
+ <t t-call="website_forum.link_button" >
+ <t t-set="url" t-value="'/forum/' + slug(forum) + '/post/' + slug(object) + '/comment/' + slug(message) + '/convert_to_answer'"/>
+ <t t-set="label" t-value="'Convert as an answer'"/>
+ <t t-set="karma" t-value="user.karma<required_karma and required_karma or 0"/>
+ <t t-set="classes" t-value="'fa-magic pull-right'"/>
+ </t>
</t>
<a t-attf-href="/forum/#{slug(forum)}/partner/#{message.author_id.id}"
t-field="message.author_id" t-field-options='{"widget": "contact", "country_image": true, "fields": ["name", "country_id"]}'