Files
odoo_source/addons/portal_rating/controllers/portal_rating.py
T
Thibault Delavallée 9e0677882d [MOV] website_rating: move to portal_rating
PURPOSE

Clean posting process and improve mail.message definition and comprehension.
Move as much possible content from website_* modules to portal_* modules
to ease their use in customer portal

SPECIFICATIONS

Now that publish feature is replaced by internal directly in mail and portal
rating portal inclusion can be done safely in a portal_ratign module instead
of website_rating. It allows to remove the dependency and give the rating
feature of customer chatter directly in portal applications.

LINKS

Task ID 2071556
PR #38692
2019-12-02 15:18:45 +00:00

18 lines
748 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import http, _
from odoo.http import request
class PortalRating(http.Controller):
@http.route(['/website/rating/comment'], type='json', auth="user", method=['POST'], website=True)
def publish_rating_comment(self, rating_id, publisher_comment):
rating = request.env['rating.rating'].search([('id', '=', int(rating_id))])
if not rating:
return {'error': _('Invalid rating')}
rating.write({'publisher_comment': publisher_comment})
# return to the front-end the created/updated publisher comment
return rating.read(['publisher_comment', 'publisher_id', 'publisher_datetime'])[0]