Files
odoo_source/addons/website_rating/models/mail_message.py
T
Jérome Maes ccf869a83e [ADD] website_rating: generic rating management on chatter frontend
Extend new dynamic chatter to manage rating
when posting comment.

The model should inherit of rating.mixin and
its frontend chatter should allow rating to enjoy
star widget and rating card.

This is more generic : stats, rating, ... are manage
in one place (this module) for all document.
2017-06-30 11:07:00 +02:00

20 lines
737 B
Python

# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
from odoo import api, fields, models
class MailMessage(models.Model):
_inherit = 'mail.message'
@api.multi
def website_message_format(self):
result = super(MailMessage, self).website_message_format()
# inlude rating value in data if requested
if self._context.get('rating_include'):
message_data = self.read(['rating_value'])
message_tree = dict((m['id'], m['rating_value']) for m in message_data)
for message_vals in result:
message_vals['rating_value'] = message_tree.get(message_vals['id'], False) # False for no rating
return result