blob: 3b2d95747b294b4947f37353e9bc42751695b6a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# -*- coding: utf-8 -*-
from odoo import fields, models, exceptions, _
class Rating(models.Model):
_inherit = 'rating.rating'
# Adding information for comment a rating message
publisher_comment = fields.Text("Publisher comment")
publisher_id = fields.Many2one('res.partner', 'Commented by',
ondelete='set null', readonly=True)
publisher_datetime = fields.Datetime("Commented on", readonly=True)
def write(self, values):
if values.get('publisher_comment'):
if not self.env.user.has_group("website.group_website_publisher"):
raise exceptions.AccessError(_("Only the publisher of the website can change the rating comment"))
if not values.get('publisher_datetime'):
values['publisher_datetime'] = fields.Datetime.now()
if not values.get('publisher_id'):
values['publisher_id'] = self.env.user.partner_id.id
return super(Rating, self).write(values)
|