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/im_livechat/models/rating.py | |
| parent | 0a15094050bfde69a06d6eff798e9a8ddf2b8c21 (diff) | |
initial commit 2
Diffstat (limited to 'addons/im_livechat/models/rating.py')
| -rw-r--r-- | addons/im_livechat/models/rating.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/addons/im_livechat/models/rating.py b/addons/im_livechat/models/rating.py new file mode 100644 index 00000000..f6a638ed --- /dev/null +++ b/addons/im_livechat/models/rating.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import api, models + + +class Rating(models.Model): + + _inherit = "rating.rating" + + @api.depends('res_model', 'res_id') + def _compute_res_name(self): + for rating in self: + # cannot change the rec_name of session since it is use to create the bus channel + # so, need to override this method to set the same alternative rec_name as in reporting + if rating.res_model == 'mail.channel': + current_object = self.env[rating.res_model].sudo().browse(rating.res_id) + rating.res_name = ('%s / %s') % (current_object.livechat_channel_id.name, current_object.id) + else: + super(Rating, rating)._compute_res_name() + + def action_open_rated_object(self): + action = super(Rating, self).action_open_rated_object() + if self.res_model == 'mail.channel': + view_id = self.env.ref('im_livechat.mail_channel_view_form').id + action['views'] = [[view_id, 'form']] + return action |
