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.

77 lines
2.9 KiB

  1. # -*- encoding: utf-8 -*-
  2. ##############################################################################
  3. #
  4. # Asterisk click2dial CRM module for OpenERP
  5. # Copyright (c) 2011 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
  6. # Copyright (c) 2012 Akretion (http://www.akretion.com)
  7. # @author: Jesús Martín <jmartin@zikzakmedia.com>
  8. # @author: Alexis de Lattre <alexis.delattre@akretion.com>
  9. #
  10. # This program is free software: you can redistribute it and/or modify
  11. # it under the terms of the GNU Affero General Public License as published by
  12. # the Free Software Foundation, either version 3 of the License, or
  13. # (at your option) any later version.
  14. #
  15. # This program is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU Affero General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU Affero General Public License
  21. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. #
  23. ##############################################################################
  24. from osv import osv, fields
  25. # Lib to translate error messages
  26. from tools.translate import _
  27. class res_partner_address(osv.osv):
  28. _inherit = "res.partner.address"
  29. def dial(self, cr, uid, ids, phone_field='phone', context=None):
  30. '''
  31. This method open the phone call history when the phone click2dial
  32. button of asterisk_click2dial module is pressed
  33. :return the phone call history view of the partner
  34. '''
  35. if context is None:
  36. context = {}
  37. super(res_partner_address, self).dial(cr, uid, ids, phone_field=phone_field, context=context)
  38. user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
  39. context['partner_address_id'] = ids[0]
  40. action_start_wizard = {
  41. 'name': 'Create phone call in CRM',
  42. 'type': 'ir.actions.act_window',
  43. 'res_model': 'wizard.create.crm.phonecall',
  44. 'view_type': 'form',
  45. 'view_mode': 'form',
  46. 'nodestroy': True,
  47. 'target': 'new',
  48. 'context': context,
  49. }
  50. if user.context_propose_creation_crm_call:
  51. return action_start_wizard
  52. else:
  53. return True
  54. res_partner_address()
  55. class res_users(osv.osv):
  56. _inherit = "res.users"
  57. _columns = {
  58. # Field name starts with 'context_' to allow modification by the user
  59. # in his preferences, cf server/openerp/addons/base/res/res_users.py
  60. # in "def write" of "class users"
  61. # This exists in since OpenERP 6.0 (it is not in OpenERP 5.0)
  62. 'context_propose_creation_crm_call': fields.boolean('Propose to create a call in CRM after a click2dial'),
  63. }
  64. _defaults = {
  65. 'context_propose_creation_crm_call': lambda *a: True,
  66. }
  67. res_users()