You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.3 KiB

  1. # -*- coding: utf-8 -*-
  2. # Copyright 2017 Specialty Medical Drugstore, LLC.
  3. # License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
  4. from openerp import api, models
  5. class MailChannel(models.Model):
  6. _inherit = 'mail.channel'
  7. @api.multi
  8. def channel_info(self, extra_info=False):
  9. channel_infos = super(MailChannel, self).channel_info(extra_info)
  10. partner_mod = self.env['res.partner']
  11. operator_id = self.env.context.get('im_livechat_operator_partner_id')
  12. for channel_info in channel_infos:
  13. if operator_id and channel_info['public'] == 'public':
  14. operator = partner_mod.browse(operator_id)
  15. if operator.firstname:
  16. operator_name = operator.firstname
  17. else:
  18. operator_name = operator.name
  19. channel_info['operator_pid'] = \
  20. (operator.id, u'%s' % operator_name)
  21. # channel name format:
  22. # 'customer name, operator/employee name'
  23. channel_name = channel_info['name'].split(', ')
  24. new_channel_name = '%s, %s' % \
  25. (channel_name[0], operator_name)
  26. channel_info['name'] = new_channel_name
  27. return channel_infos