[MERGE] forward port of branch 8.0 up to 262eb66
authorChristophe Simonis <chs@odoo.com>
Tue, 21 Oct 2014 12:59:56 +0000 (14:59 +0200)
committerChristophe Simonis <chs@odoo.com>
Tue, 21 Oct 2014 12:59:56 +0000 (14:59 +0200)
18 files changed:
1  2 
addons/account/res_config.py
addons/mrp/mrp.py
addons/point_of_sale/point_of_sale.py
addons/point_of_sale/report/pos_order_report.py
addons/point_of_sale/static/src/js/models.js
addons/project/report/project_report.py
addons/purchase/purchase.py
addons/sale/wizard/sale_make_invoice_advance.py
addons/web/controllers/main.py
addons/website/models/ir_qweb.py
addons/website/static/src/js/website.editor.js
addons/website/views/snippets.xml
addons/website_forum/controllers/main.py
addons/website_forum/models/forum.py
addons/website_forum/views/website_forum.xml
addons/website_sale/views/views.xml
doc/conf.py
openerp/addons/base/res/res_partner.py

Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -357,14 -315,11 +358,14 @@@ class Post(osv.Model)
              context = {}
          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
+         post = self.browse(cr, uid, post_id, context=context)
 +        # 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:
+         if not post.parent_id and not post.can_ask:
              raise KarmaError('Not enough karma to create a new question')
-         elif not post.parent_id and not post.can_answer:
+         elif post.parent_id and not post.can_answer:
              raise KarmaError('Not enough karma to answer to a question')
          # messaging and chatter
          base_url = self.pool['ir.config_parameter'].get_param(cr, uid, 'web.base.url')
                      <t t-raw="0"/>
                  </div>
                  <div class="col-sm-3" id="right-column">
-                     <div t-if="not header.get('ask_hide')" class="btn-group btn-block mb16">
 -                    <a t-if="not header.get('ask_hide')"
 -                       t-attf-class="btn btn-primary btn-lg btn-block mb16 #{user.karma &gt;= forum.karma_ask and '' or 'karma_required'}"
 -                       t-attf-href="/forum/#{slug(forum)}/ask"
 -                       t-attf-data-karma="#{forum.karma_ask}">Ask a Question</a>
++                    <div t-if="not header.get('ask_hide')" t-attf-class="btn-group btn-block mb16 #{user.karma &gt;= forum.karma_ask and '' or 'karma_required'}" t-attf-data-karma="#{forum.karma_ask}">
 +                        <a type="button" class="btn btn-primary btn-lg col-sm-10" t-attf-href="/forum/#{slug(forum)}/#{forum.default_allow}">
 +                            <t t-if="forum.default_allow == 'ask_question'">Ask a Question</t>
 +                            <t t-if="forum.default_allow == 'post_link'">Submit a Post</t>
 +                            <t t-if="forum.default_allow == 'post_discussion'">New Discussion</t>
 +                        </a>
 +                        <button type="button" class="btn btn-primary btn-lg col-sm-2 dropdown-toggle" data-toggle="dropdown">
 +                            <span class="caret"></span>
 +                            <span class="sr-only">Select Post</span>
 +                        </button>
 +                        <ul class="dropdown-menu" role="menu">
 +                            <li t-if="forum.allow_link"><a t-attf-href="/forum/#{slug(forum)}/post_link">Submit a Post</a></li>
 +                            <li t-if="forum.allow_question"><a t-attf-href="/forum/#{slug(forum)}/ask_question">Ask a Question</a></li>
 +                            <li t-if="forum.allow_discussion"><a t-attf-href="/forum/#{slug(forum)}/post_discussion">Launch a Discussion</a></li>
 +                        </ul>
 +                    </div>
                      <div class="panel panel-default">
                          <div class="panel-heading">
                              <h3 class="panel-title">Keep Informed</h3>
                  <t t-esc="question_content"/>
              </textarea>
              <br/>
 -            <input type="text" name="question_tags" placeholder="Tags" class="form-control load_tags"/>
 +            <input type="text" name="post_tags" placeholder="Tags" class="form-control load_tags"/>
              <br/>
-             <button class="btn btn-primary" id="btn_ask_your_question">Post Your Question</button>
+             <button t-attf-class="btn btn-primary #{(user.karma &lt;= forum.karma_ask) and 'karma_required' or ''}"
+                 id="btn_ask_your_question" t-att-data-karma="forum.karma_ask">Post Your Question</button>
          </form>
 -        <script type="text/javascript">
 -            CKEDITOR.replace("content");
 -        </script>
      </t>
  </template>
  
          - no need to answer the same question twice. Also, please <b>don't forget to vote</b>
          - it really helps to select the best questions and answers!
      </p>
 -    <form t-attf-action="/forum/#{ slug(forum) }/post/#{slug(question)}/new" method="post" role="form">
 +    <form t-attf-action="/forum/#{ slug(forum) }/#{slug(question)}/reply" method="post" role="form">
          <input type="hidden" name="karma" t-attf-value="#{user.karma}" id="karma"/>
 -        <textarea name="content" class="form-control load_editor" required="True"/>
 +        <textarea name="content" t-attf-id="content-#{str(question.id)}" class="form-control load_editor" required="True"/>
-         <button class="btn btn-primary mt16" id="btn_ask_your_question">Post Your Reply</button>
+         <button t-attf-class="btn btn-primary mt16 #{not question.can_answer and 'karma_required' or ''}"
 -                id="btn_ask_your_question" t-att-data-karma="question.karma_answer">Post Your Answer</button>
++                id="btn_ask_your_question" t-att-data-karma="question.karma_answer">Post Your Reply</button>
      </form>
 -    <script type="text/javascript">
 -        CKEDITOR.replace("content");
 -    </script>
  </template>
  
  <template id="vote">
                              </t>
                          </div>
                          <ul class="list-inline" id="options">
 -                            <li>
 +                            <li t-if="question.type == 'question'">
-                                 <a style="cursor: pointer" data-toggle="collapse"
+                                 <a style="cursor: pointer" t-att-data-toggle="question.can_comment and 'collapse' or ''"
                                      t-attf-class="fa fa-comment-o #{not question.can_comment and 'karma_required text-muted' or ''}"
                                      t-attf-data-karma="#{not question.can_comment and question.karma_comment or 0}"
                                      t-attf-data-target="#comment#{ question._name.replace('.','') + '-' + str(question.id) }">
              </div>
          </div>
          <hr/>
 +        <div t-foreach="question.child_ids" t-as="post_answer" class="mt16 mb32">
 +            <t t-call="website_forum.post_answers">
 +                <t t-set="answer" t-value="post_answer"/>
 +            </t>
 +        </div>
 +        <div t-if="question.type != 'question' or question.type == 'question' and 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.type == 'question' and question.uid_has_answered" class="mb16">
 +            <a class="btn btn-primary" t-attf-href="/forum/#{slug(forum)}/question/#{slug(question)}/edit_answer">Edit Your Previous Answer</a>
 +            <span class="text-muted">(only one answer per question is allowed)</span>
 +        </div>
 +    </t>
 +</template>
  
 -        <div t-foreach="question.child_ids" t-as="answer" class="mt16 mb32">
 -            <a t-attf-id="answer-#{str(answer.id)}"/>
 -            <div t-attf-class="forum_answer row" t-attf-id="answer_#{answer.id}" >
 -                <div class="col-md-2 hidden-xs text-center">
 +<template id="post_answers">
 +    <a t-attf-id="answer-#{str(answer.id)}"/>
 +    <div t-attf-class="forum_answer row" t-attf-id="answer_#{answer.id}" >
 +        <div class="col-md-2 hidden-xs text-center">
 +            <t t-call="website_forum.vote">
 +                <t t-set="post" t-value="answer"/>
 +            </t>
 +            <div t-if="question.type == 'question'" class="text-muted mt8">
 +                <a t-attf-class="accept_answer fa fa-2x fa-check-circle no-decoration #{answer.is_correct and 'oe_answer_true' or 'oe_answer_false'} #{not answer.can_accept and 'karma_required' or ''}"
 +                    t-attf-data-karma="#{answer.karma_accept}"
 +                    t-attf-data-href="/forum/#{slug(question.forum_id)}/post/#{slug(answer)}/toggle_correct"/>
 +            </div>
 +        </div>
 +        <div class="col-md-10 clearfix">
 +            <t t-raw="answer.content"/>
 +            <div class="mt16">
 +                <ul class="list-inline pull-right">
 +                    <li t-if="question.type == 'question'">
 +                        <a t-attf-class="fa fa-comment-o #{not answer.can_comment and 'karma_required text-muted' or ''}"
 +                            t-attf-data-karma="#{not answer.can_comment and answer.karma_comment or 0}"
-                             style="cursor: pointer" data-toggle="collapse"
++                            style="cursor: pointer" t-att-data-toggle="answer.can_comment and 'collapse' or ''"
 +                            t-attf-data-target="#comment#{ answer._name.replace('.','') + '-' + str(answer.id) }"> Comment
 +                        </a>
 +                    </li>
 +                    <li t-if="question.type != 'question' and not answer.parent_id or answer.parent_id and not answer.parent_id.parent_id">
 +                        <a t-attf-class="fa fa-comment-o #{not answer.can_comment and 'karma_required text-muted' or ''}"
 +                            t-attf-data-karma="#{not answer.can_comment and answer.karma_comment or 0}"
 +                            style="cursor: pointer" data-toggle="collapse"
 +                            t-attf-data-target="#reply#{ answer._name.replace('.','') + '-' + str(answer.id) }"> Reply
 +                        </a>
 +                    </li>
 +                    <li>
 +                        <t t-call="website_forum.link_button">
 +                            <t t-set="url" t-value="'/forum/' + slug(forum) + '/post/' + slug(answer) + '/edit'"/>
 +                            <t t-set="label" t-value="'Edit'"/>
 +                            <t t-set="classes" t-value="'fa fa-edit'"/>
 +                            <t t-set="karma" t-value="not answer.can_edit and answer.karma_edit or 0"/>
 +                        </t>
 +                    </li>
 +                    <li>
 +                        <t t-call="website_forum.link_button">
 +                            <t t-set="url" t-value="'/forum/' + slug(forum) + '/post/' + slug(answer) + '/delete'"/>
 +                            <t t-set="label" t-value="'Delete'"/>
 +                            <t t-set="classes" t-value="'fa-trash-o'"/>
 +                            <t t-set="karma" t-value="not answer.can_unlink and answer.karma_unlink or 0"/>
 +                        </t>
 +                    </li>
 +                    <li t-if="question.type == 'question'">
 +                        <t t-call="website_forum.link_button">
 +                            <t t-set="url" t-value="'/forum/' + slug(forum) + '/post/' + slug(answer) + '/convert_to_comment'"/>
 +                            <t t-set="label" t-value="'Convert as a comment'"/>
 +                            <t t-set="classes" t-value="'fa-magic'"/>
 +                            <t t-set="karma" t-value="not answer.can_comment_convert and answer.karma_comment_convert or 0"/>
 +                        </t>
 +                    </li>
 +                </ul>
 +                <img class="pull-left img img-circle img-avatar" t-attf-src="/forum/user/#{answer.create_uid.id}/avatar"/>
 +                <div>
 +                    <a t-attf-href="/forum/#{ slug(forum) }/user/#{ answer.create_uid.id }"
 +                        t-field="answer.create_uid"
 +                        t-field-options='{"widget": "contact", "country_image": true, "fields": ["name", "country_id"]}'
 +                        style="display: inline-block;"/>
 +                    <div t-field="answer.create_uid" t-field-options='{"widget": "contact", "badges": true, "fields": ["karma"]}'/>
 +                    <span class="text-muted">Answered on <span t-field="answer.create_date" t-field-options='{"format":"short"}'/></span>
 +                </div>
 +                <div class="visible-xs text-center">
                      <t t-call="website_forum.vote">
                          <t t-set="post" t-value="answer"/>
                      </t>
Simple merge
diff --cc doc/conf.py
Simple merge
@@@ -233,8 -233,9 +233,9 @@@ class res_partner(osv.Model, format_add
          'date': fields.date('Date', select=1),
          'title': fields.many2one('res.partner.title', 'Title'),
          'parent_id': fields.many2one('res.partner', 'Related Company', select=True),
+         'parent_name': fields.related('parent_id', 'name', type='char', readonly=True, string='Parent name'),
          'child_ids': fields.one2many('res.partner', 'parent_id', 'Contacts', domain=[('active','=',True)]), # force "active_test" domain to bypass _search() override
 -        'ref': fields.char('Contact Reference', select=1),
 +        'ref': fields.char('Internal Reference', select=1),
          'lang': fields.selection(_lang_get, 'Language',
              help="If the selected language is loaded in the system, all documents related to this contact will be printed in this language. If not, it will be English."),
          'tz': fields.selection(_tz_get,  'Timezone', size=64,