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.

73 lines
3.1 KiB

  1. # -*- encoding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Asterisk click2dial CRM module for OpenERP
  5. # Copyright (c) 2012-2014 Akretion (http://www.akretion.com)
  6. # @author: Alexis de Lattre <alexis.delattre@akretion.com>
  7. #
  8. # This program is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU Affero General Public License as published
  10. # by the Free Software Foundation, either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU Affero General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU Affero General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. #
  21. ##############################################################################
  22. from openerp.osv import orm
  23. class wizard_create_crm_phonecall(orm.TransientModel):
  24. _name = "wizard.create.crm.phonecall"
  25. def button_create_outgoing_phonecall(self, cr, uid, ids, context=None):
  26. partner = self.pool['res.partner'].browse(
  27. cr, uid, context.get('partner_id'), context=context)
  28. return self._create_open_crm_phonecall(
  29. cr, uid, partner, crm_categ='Outbound', context=context)
  30. def _create_open_crm_phonecall(
  31. self, cr, uid, partner, crm_categ, context=None):
  32. if context is None:
  33. context = {}
  34. categ_ids = self.pool['crm.case.categ'].search(
  35. cr, uid, [('name', '=', crm_categ)], context={'lang': 'en_US'})
  36. case_section_ids = self.pool['crm.case.section'].search(
  37. cr, uid, [('member_ids', 'in', uid)], context=context)
  38. context.update({
  39. 'default_partner_id': partner.id or False,
  40. 'default_partner_phone': partner.phone,
  41. 'default_partner_mobile': partner.mobile,
  42. 'default_categ_id': categ_ids and categ_ids[0] or False,
  43. 'default_section_id':
  44. case_section_ids and case_section_ids[0] or False,
  45. })
  46. return {
  47. 'name': partner.name,
  48. 'domain': [('partner_id', '=', partner.id)],
  49. 'res_model': 'crm.phonecall',
  50. 'view_mode': 'form,tree',
  51. 'type': 'ir.actions.act_window',
  52. 'nodestroy': False, # close the pop-up wizard after action
  53. 'target': 'current',
  54. 'context': context,
  55. }
  56. class wizard_open_calling_partner(orm.TransientModel):
  57. _inherit = "wizard.open.calling.partner"
  58. def create_incoming_phonecall(self, cr, uid, ids, crm_categ, context=None):
  59. '''Started by button on 'open calling partner wizard'''
  60. partner = self.browse(cr, uid, ids[0], context=context).partner_id
  61. action = self.pool['wizard.create.crm.phonecall'].\
  62. _create_open_crm_phonecall(
  63. cr, uid, partner, crm_categ='Inbound', context=context)
  64. return action