diff options
| author | Jérome Maes <jem@openerp.com> | 2017-01-13 11:01:30 +0100 |
|---|---|---|
| committer | Jérome Maes <jem@openerp.com> | 2017-06-30 11:07:00 +0200 |
| commit | 0339264d11f8392e4b951c4eec15b8ebb080cc19 (patch) | |
| tree | 53dbe978e26209373547d54b0cfe2d13e49abf39 | |
| parent | ccf869a83e061a9bddbe17cb201721bebdd63926 (diff) | |
[IMP] website_*: adapt website modules using frontend chatter
10 files changed, 15 insertions, 120 deletions
diff --git a/addons/website_blog/views/website_blog_templates.xml b/addons/website_blog/views/website_blog_templates.xml index f6f35135484..c2ecb61d5aa 100644 --- a/addons/website_blog/views/website_blog_templates.xml +++ b/addons/website_blog/views/website_blog_templates.xml @@ -299,13 +299,11 @@ </template> <!-- Options: Blog Post: user can reply --> -<template id="opt_blog_post_complete_comment" name="Allow blog post comment" - inherit_id="website_blog.blog_post_complete" active="False" customize_show="True"> +<template id="opt_blog_post_complete_comment" name="Allow blog post comment" inherit_id="website_blog.blog_post_complete" active="False" customize_show="True"> <xpath expr="//div[@class='o_blog_post_complete o_sharing_links']" position="after"> <section id="comments" class="read_width"> <t t-call="website_mail.message_thread"> <t t-set="object" t-value="blog_post"/> - <t t-set="chatter_mode" t-value="'json'"/> </t> </section> </xpath> diff --git a/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml b/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml index d9ff4bd2ca3..c5db1490a02 100644 --- a/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml +++ b/addons/website_crm_partner_assign/views/website_crm_partner_assign_templates.xml @@ -517,7 +517,6 @@ <div class="col-md-10 col-md-offset-1 mt16"> <t t-call="website_mail.message_thread"> <t t-set="object" t-value="lead"/> - <t t-set="chatter_mode" t-value="'json'"/> </t> </div> </div> @@ -800,7 +799,6 @@ <div class="col-md-10 col-md-offset-1 mt16"> <t t-call="website_mail.message_thread"> <t t-set="object" t-value="opportunity"/> - <t t-set="chatter_mode" t-value="'json'"/> </t> </div> </div> diff --git a/addons/website_project/views/project_templates.xml b/addons/website_project/views/project_templates.xml index 412fca0cb8f..0a4f7622795 100644 --- a/addons/website_project/views/project_templates.xml +++ b/addons/website_project/views/project_templates.xml @@ -134,7 +134,6 @@ <div class="col-md-10 col-md-offset-1 mt16"> <t t-call="website_mail.message_thread"> <t t-set="object" t-value="project"/> - <t t-set="chatter_mode" t-value="'json'"/> </t> </div> </div> @@ -254,7 +253,6 @@ <div class="col-md-10 col-md-offset-1 mt16"> <t t-call="website_mail.message_thread"> <t t-set="object" t-value="task"/> - <t t-set="chatter_mode" t-value="'json'"/> </t> </div> </div> diff --git a/addons/website_project_issue/views/project_issue_templates.xml b/addons/website_project_issue/views/project_issue_templates.xml index e83e24fa2bc..686d7f5f428 100644 --- a/addons/website_project_issue/views/project_issue_templates.xml +++ b/addons/website_project_issue/views/project_issue_templates.xml @@ -136,7 +136,6 @@ <div class="col-md-10 col-md-offset-1 mt16"> <t t-call="website_mail.message_thread"> <t t-set="object" t-value="issue"/> - <t t-set="chatter_mode" t-value="'json'"/> </t> </div> </div> diff --git a/addons/website_quote/views/website_quote_templates.xml b/addons/website_quote/views/website_quote_templates.xml index 2c599bd46c8..d9ffd6a5da4 100644 --- a/addons/website_quote/views/website_quote_templates.xml +++ b/addons/website_quote/views/website_quote_templates.xml @@ -443,7 +443,6 @@ <t t-call="website_mail.message_thread"> <t t-set="object" t-value="quotation"/> <t t-set="token_field" t-value="'access_token'"/> - <t t-set="chatter_mode" t-value="'json'"/> </t> </xpath> <xpath expr="//a[@data-target='#modaldecline']" position="before"> diff --git a/addons/website_sale/__manifest__.py b/addons/website_sale/__manifest__.py index 102ed5b4160..abad5ffc189 100644 --- a/addons/website_sale/__manifest__.py +++ b/addons/website_sale/__manifest__.py @@ -10,7 +10,7 @@ Odoo E-Commerce ================== """, - 'depends': ['website', 'sale', 'payment', 'website_payment', 'website_portal_sale', 'website_account', 'website_mail', 'website_form', 'rating'], + 'depends': ['website', 'sale', 'payment', 'website_payment', 'website_portal_sale', 'website_account', 'website_mail', 'website_form', 'website_rating'], 'data': [ 'security/ir.model.access.csv', 'security/website_sale.xml', diff --git a/addons/website_sale/controllers/__init__.py b/addons/website_sale/controllers/__init__.py index 720ed5bf928..5ee7aaab8f2 100644 --- a/addons/website_sale/controllers/__init__.py +++ b/addons/website_sale/controllers/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. + from . import backend from . import main -from . import website_mail diff --git a/addons/website_sale/controllers/main.py b/addons/website_sale/controllers/main.py index 7162db54804..dbedb81ab88 100644 --- a/addons/website_sale/controllers/main.py +++ b/addons/website_sale/controllers/main.py @@ -277,7 +277,6 @@ class WebsiteSale(http.Controller): def product(self, product, category='', search='', **kwargs): product_context = dict(request.env.context, active_id=product.id) ProductCategory = request.env['product.public.category'] - Rating = request.env['rating.rating'] if category: category = ProductCategory.browse(int(category)).exists() @@ -296,11 +295,6 @@ class WebsiteSale(http.Controller): to_currency = pricelist.currency_id compute_currency = lambda price: from_currency.compute(price, to_currency) - # get the rating attached to a mail.message, and the rating stats of the product - ratings = Rating.search([('message_id', 'in', product.website_message_ids.ids)]) - rating_message_values = dict([(record.message_id.id, record.rating) for record in ratings]) - rating_product = product.rating_get_stats([('website_published', '=', True)]) - if not product_context.get('pricelist'): product_context['pricelist'] = pricelist.id product = product.with_context(product_context) @@ -317,8 +311,6 @@ class WebsiteSale(http.Controller): 'main_object': product, 'product': product, 'get_attribute_value_ids': self.get_attribute_value_ids, - 'rating_message_values': rating_message_values, - 'rating_product': rating_product } return request.render("website_sale.product", values) diff --git a/addons/website_sale/controllers/website_mail.py b/addons/website_sale/controllers/website_mail.py deleted file mode 100644 index 5931098d3a1..00000000000 --- a/addons/website_sale/controllers/website_mail.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- -# Part of Odoo. See LICENSE file for full copyright and licensing details. -from werkzeug import urls - -from odoo import http -from odoo.http import request - -from odoo.addons.website_mail.controllers.main import WebsiteMail - - -class WebsiteMailController(WebsiteMail): - - @http.route(['/website_mail/post/json'], type='json', auth='public', website=True) - def chatter_json(self, res_model='', res_id=None, message='', **kw): - params = kw.copy() - params.pop('rating', False) - message_data = super(WebsiteMailController, self).chatter_json(res_model=res_model, res_id=res_id, message=message, **params) - if message_data and kw.get('rating') and res_model == 'product.template': # restrict rating only for product template - res_model_id = request.env.ref('product.model_product_template').id - rating = request.env['rating.rating'].create({ - 'rating': float(kw.get('rating')), - 'res_model_id': res_model_id, - 'res_id': res_id, - 'message_id': message_data['id'], - 'consumed': True, - }) - message_data.update({ - 'rating_default_value': rating.rating, - 'rating_disabled': True, - }) - return message_data - - @http.route(['/website_mail/post/post'], type='http', methods=['POST'], auth='public', website=True) - def chatter_post(self, res_model='', res_id=None, message='', redirect=None, **kw): - params = kw.copy() - params.pop('rating') - response = super(WebsiteMailController, self).chatter_post(res_model=res_model, res_id=res_id, message=message, redirect=redirect, **params) - if kw.get('rating') and res_model == 'product.template': # restrict rating only for product template - try: - fragment = urls.url_parse(response.location).fragment - message_id = int(fragment.replace('message-', '')) - res_model_id = request.env.ref('product.model_product_template').id - request.env['rating.rating'].create({ - 'rating': float(kw.get('rating')), - 'res_model_id': res_model_id, - 'res_id': res_id, - 'message_id': message_id, - 'consumed': True, - }) - except Exception: - pass - return response diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml index 83270ed6682..cba93b108d6 100644 --- a/addons/website_sale/views/templates.xml +++ b/addons/website_sale/views/templates.xml @@ -17,7 +17,6 @@ <script type="text/javascript" src="/website_sale/static/src/js/website_sale_payment.js"></script> <script type="text/javascript" src="/website_sale/static/src/js/website_sale_validate.js"></script> <script type="text/javascript" src="/website_sale/static/src/js/website_sale_tour_buy.js"></script> - <script type="text/javascript" src="/website_sale/static/src/js/website_sale_rating.js"></script> <script type="text/javascript" src="/website_sale/static/src/js/website_sale_tracking.js"></script> </xpath> </template> @@ -552,32 +551,20 @@ <!-- Product options: OpenChatter --> <template id="product_comment" inherit_id="website_sale.product" active="False" customize_show="True" name="Discussion and Rating"> - <xpath expr="//div[@id='product_details']" position="inside"> - <t t-call="rating.rating_card"> - <t t-set="rating_stat" t-value="rating_product"/> - <t t-set="max_rate" t-value="5"/> - <t t-set="min_rate" t-value="1"/> - </t> - </xpath> <xpath expr="//div[@t-field='product.website_description']" position="after"> - <hr class="mb32"/> - <section class="container"> - <div class="row col-md-10 col-md-offset-1"> - <div class="text-muted"> - <h3 class="fa fa-comment-o"> - <a id="comments"> - <t t-if="len(product.website_message_ids) <= 1" ><t t-esc="len(product.website_message_ids)"/> comment</t> - <t t-if="len(product.website_message_ids) > 1"><t t-esc="len(product.website_message_ids)"/> comments</t> - </a> - </h3> + <div class="o_shop_discussion_rating"> + <section class="container mt16 mb16"> + <hr/> + <div class="row"> + <div class="col-md-8 col-md-offset-2"> + <t t-call="website_mail.message_thread"> + <t t-set="object" t-value="product"/> + <t t-set="display_rating" t-value="True"/> + </t> + </div> </div> - <t t-call="website_mail.message_thread"> - <t t-set="object" t-value="product"/> - <t t-set="chatter_mode" t-value="'json'"/> - <t t-set="rating_enable" t-value="True"/> - </t> - </div> - </section> + </section> + </div> </xpath> </template> @@ -704,30 +691,6 @@ </ul> </template> - <!-- extend the generic mail thread message template to add rating widget --> - <template id="message_thread_rating" inherit_id="website_mail.message_thread" name="Chatter with rating"> - <xpath expr="//section[contains(@class, 'o_website_mail_thread')]" position="attributes"> - <attribute name="t-att-data-rating-enabled">rating_message_values and 1 or 0</attribute> - </xpath> - <xpath expr="//textarea[@name='message']" position="before"> - <t t-if="rating_enable"> - <t t-call="rating.rating_star_card"> - <t t-set="rating_input_name" t-value="'rating'" /> - </t> - </t> - </xpath> - <xpath expr="//ul[contains(@class, 'o_website_comments')]//h5" position="after"> - <t t-if="rating_enable"> - <div t-if="rating_message_values.get(message.id)"> - <t t-call="rating.rating_star_card"> - <t t-set="rating_default_value" t-value="rating_message_values.get(message.id)" /> - <t t-set="rating_disabled" t-value="True" /> - </t> - </div> - </t> - </xpath> - </template> - <template id="wizard_checkout" name="Wizard Checkout"> <ul class="wizard pull-right hidden-xs"> <li t-att-class="step==10 and 'text-primary' or 'text-muted'" id="step10"> |
