diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2022-05-10 21:51:50 +0700 |
| commit | 3751379f1e9a4c215fb6eb898b4ccc67659b9ace (patch) | |
| tree | a44932296ef4a9b71d5f010906253d8c53727726 /addons/portal_rating/models/rating.py | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/portal_rating/models/rating.py')
| -rw-r--r-- | addons/portal_rating/models/rating.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/addons/portal_rating/models/rating.py b/addons/portal_rating/models/rating.py new file mode 100644 index 00000000..3b2d9574 --- /dev/null +++ b/addons/portal_rating/models/rating.py @@ -0,0 +1,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) |
