diff --git a/asterisk_click2dial/__openerp__.py b/asterisk_click2dial/__openerp__.py index 6639d17..37241bb 100644 --- a/asterisk_click2dial/__openerp__.py +++ b/asterisk_click2dial/__openerp__.py @@ -23,7 +23,7 @@ { 'name': 'Asterisk Click2dial', 'version': '0.3', - 'category': 'Generic Modules/Others', + 'category': 'Extra Tools', 'license': 'AGPL-3', 'description': """This module adds 3 functionnalities : diff --git a/asterisk_click2dial/asterisk_click2dial.py b/asterisk_click2dial/asterisk_click2dial.py index bcb8390..4d8cee4 100644 --- a/asterisk_click2dial/asterisk_click2dial.py +++ b/asterisk_click2dial/asterisk_click2dial.py @@ -489,9 +489,9 @@ class wizard_open_calling_partner(osv.osv_memory): '''Thanks to the default_get method, we are able to query Asterisk and get the corresponding partner when we launch the wizard''' res = {} - #calling_number = self.pool.get('asterisk.server')._connect_to_asterisk(cr, uid, method='get_calling_number', context=context) + calling_number = self.pool.get('asterisk.server')._connect_to_asterisk(cr, uid, method='get_calling_number', context=context) #To test the code without Asterisk server - calling_number = "0141981242" + #calling_number = "0141981242" if calling_number: res['calling_number'] = calling_number # We match only on the end of the phone number diff --git a/asterisk_click2dial_crm/__init__.py b/asterisk_click2dial_crm/__init__.py index 2bff310..be2809c 100644 --- a/asterisk_click2dial_crm/__init__.py +++ b/asterisk_click2dial_crm/__init__.py @@ -1,10 +1,11 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# Asterisk click2dial CRM module for OpenERP # Copyright (c) 2011 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. -# Jesús Martín -# $Id$ +# Copyright (c) 2012 Akretion (http://www.akretion.com) +# @author: Jesús Martín +# @author: Alexis de Lattre # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -21,5 +22,5 @@ # ############################################################################## -import res_partner_address - +import asterisk_click2dial_crm +import wizard diff --git a/asterisk_click2dial_crm/__openerp__.py b/asterisk_click2dial_crm/__openerp__.py index adf97be..7a86d5f 100644 --- a/asterisk_click2dial_crm/__openerp__.py +++ b/asterisk_click2dial_crm/__openerp__.py @@ -1,10 +1,11 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# Asterisk click2dial CRM module for OpenERP # Copyright (c) 2011 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. -# Jesús Martín -# $Id$ +# Copyright (c) 2012 Akretion (http://www.akretion.com) +# @author: Jesús Martín +# @author: Alexis de Lattre # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -22,28 +23,42 @@ ############################################################################## { - 'name': 'Asterisk Click2dial CRM', + "name": "Asterisk Click2dial CRM", "version": "0.1", - "author": "Zikzakmedia SL", + "author": "Zikzakmedia SL, Akretion", "website": "http://www.zikzakmedia.com", "license" : "AGPL-3", - 'category': 'Generic Modules/Others', + "category": "Customer Relationship Management", "description": """ - Create a outbound phone call in the CRM when the user makes a call phone - by clicking the click2dial button of the partner address view, - and opens it in a new tab. + This module adds CRM-specific features to the asterisk_click2dial module. - Also proposes to create an inbound phone call in the CRM when the user receives - a phone calls and clicks on "Open calling partner". + It adds 2 features : + + First, when you do a click2dial, OpenERP will propose you to create an + outbound phone call in the CRM ; if you answer 'Yes', it will create the phone + call in the CRM and open it in a new tab. If some users don't want to be asked + to create a phone call in the CRM each time they do a click2dial, you + should disable the corresponding option in the 'Telephony' tab of the 'User' + form. + + Second, when you receive a phone call and run the wizard "Open calling partner", + if the partner is found in OpenERP, you will see a button that proposes to create + an inbound phone call in the CRM. + + This module has been initially developped by Zikzakmedia and has been enhanced by Akretion. + + A detailed documentation for the OpenERP-Asterisk connector is available on the Akretion Web site : http://www.akretion.com/en/products-and-services/openerp-asterisk-voip-connector """, "depends": [ 'asterisk_click2dial', 'crm', ], - "init_xml" : [ ], - "demo_xml" : [ ], - "update_xml" : [ - 'open_calling_partner_view.xml', + "init_xml": [], + "demo_xml": [], + "update_xml": [ + 'wizard/open_calling_partner_view.xml', + 'wizard/create_crm_phonecall_view.xml', + 'res_users_view.xml', ], "installable": True, } diff --git a/asterisk_click2dial_crm/asterisk_click2dial_crm.py b/asterisk_click2dial_crm/asterisk_click2dial_crm.py new file mode 100644 index 0000000..d77e00f --- /dev/null +++ b/asterisk_click2dial_crm/asterisk_click2dial_crm.py @@ -0,0 +1,73 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Asterisk click2dial CRM module for OpenERP +# Copyright (c) 2011 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. +# Copyright (c) 2012 Akretion (http://www.akretion.com) +# @author: Jesús Martín +# @author: Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import osv, fields +# Lib to translate error messages +from tools.translate import _ + +class res_partner_address(osv.osv): + _inherit = "res.partner.address" + + def dial(self, cr, uid, ids, phone_field='phone', context=None): + ''' + This method open the phone call history when the phone click2dial + button of asterisk_click2dial module is pressed + :return the phone call history view of the partner + ''' + if context is None: + context = {} + super(res_partner_address, self).dial(cr, uid, ids, phone_field=phone_field, context=context) + user = self.pool.get('res.users').browse(cr, uid, uid, context=context) + context['partner_address_id'] = ids[0] + action_start_wizard = { + 'name': 'Create phone call in CRM', + 'type': 'ir.actions.act_window', + 'res_model': 'wizard.create.crm.phonecall', + 'view_type': 'form', + 'view_mode': 'form', + 'nodestroy': True, + 'target': 'new', + 'context': context, + } + if user.propose_creation_crm_phonecall: + return action_start_wizard + else: + return True + +res_partner_address() + + +class res_users(osv.osv): + _inherit = "res.users" + + _columns = { + 'propose_creation_crm_phonecall': fields.boolean('Propose to create a call in CRM after a click2dial'), + } + + _defaults = { + 'propose_creation_crm_phonecall': True, + } + +res_users() + diff --git a/asterisk_click2dial_crm/i18n/asterisk_click2dial_crm.pot b/asterisk_click2dial_crm/i18n/asterisk_click2dial_crm.pot index 970ec47..5f33124 100644 --- a/asterisk_click2dial_crm/i18n/asterisk_click2dial_crm.pot +++ b/asterisk_click2dial_crm/i18n/asterisk_click2dial_crm.pot @@ -4,10 +4,10 @@ # msgid "" msgstr "" -"Project-Id-Version: OpenERP Server 6.0.2\n" -"Report-Msgid-Bugs-To: support@openerp.com\n" -"POT-Creation-Date: 2011-11-09 15:28+0000\n" -"PO-Revision-Date: 2011-11-09 15:28+0000\n" +"Project-Id-Version: OpenERP Server 6.1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2012-06-02 23:46+0000\n" +"PO-Revision-Date: 2012-06-02 23:46+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,23 +16,63 @@ msgstr "" "Plural-Forms: \n" #. module: asterisk_click2dial_crm -#: model:ir.model,name:asterisk_click2dial_crm.model_res_partner_address -msgid "Partner Addresses" -msgstr "Partner Addresses" +#: model:ir.actions.act_window,name:asterisk_click2dial_crm.action_create_crm_phonecall +msgid "Create CRM phonecall" +msgstr "" + +#. module: asterisk_click2dial_crm +#: code:addons/asterisk_click2dial_crm/wizard/create_crm_phonecall.py:45 +#, python-format +msgid "Call with" +msgstr "" + +#. module: asterisk_click2dial_crm +#: view:wizard.open.calling.partner:0 +msgid "Create call in CRM" +msgstr "" + +#. module: asterisk_click2dial_crm +#: view:wizard.create.crm.phonecall:0 +msgid "CRM phone call" +msgstr "" + +#. module: asterisk_click2dial_crm +#: view:wizard.create.crm.phonecall:0 +msgid "No" +msgstr "" + +#. module: asterisk_click2dial_crm +#: model:ir.model,name:asterisk_click2dial_crm.model_wizard_open_calling_partner +msgid "wizard.open.calling.partner" +msgstr "" #. module: asterisk_click2dial_crm -#: model:ir.module.module,description:asterisk_click2dial_crm.module_meta_information -msgid "\n" -" Create a outbound phone call when the user makes a call phone by clicking\n" -" the click2dial button of the partner address view, and opens it in a new tab.\n" -" " -msgstr "\n" -" Create a outbound phone call when the user makes a call phone by clicking\n" -" the click2dial button of the partner address view, and opens it in a new tab.\n" -" " +#: model:ir.model,name:asterisk_click2dial_crm.model_wizard_create_crm_phonecall +msgid "wizard.create.crm.phonecall" +msgstr "" + +#. module: asterisk_click2dial_crm +#: field:res.users,propose_creation_crm_phonecall:0 +msgid "Propose to create a call in CRM after a click2dial" +msgstr "" #. module: asterisk_click2dial_crm -#: model:ir.module.module,shortdesc:asterisk_click2dial_crm.module_meta_information -msgid "Asterisk Click2dial CRM" -msgstr "Asterisk Click2dial CRM" +#: view:wizard.create.crm.phonecall:0 +msgid "Create a phone call in the CRM ?" +msgstr "" + +#. module: asterisk_click2dial_crm +#: model:ir.model,name:asterisk_click2dial_crm.model_res_users +msgid "res.users" +msgstr "" + +#. module: asterisk_click2dial_crm +#: view:wizard.create.crm.phonecall:0 +msgid "Yes" +msgstr "" + +#. module: asterisk_click2dial_crm +#: model:ir.model,name:asterisk_click2dial_crm.model_res_partner_address +msgid "Partner Addresses" +msgstr "" diff --git a/asterisk_click2dial_crm/i18n/fr.po b/asterisk_click2dial_crm/i18n/fr.po new file mode 100644 index 0000000..bc2d165 --- /dev/null +++ b/asterisk_click2dial_crm/i18n/fr.po @@ -0,0 +1,78 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * asterisk_click2dial_crm +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.1\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2012-06-02 23:47+0000\n" +"PO-Revision-Date: 2012-06-02 23:47+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: asterisk_click2dial_crm +#: model:ir.actions.act_window,name:asterisk_click2dial_crm.action_create_crm_phonecall +msgid "Create CRM phonecall" +msgstr "Créer un appel dans la CRM" + +#. module: asterisk_click2dial_crm +#: code:addons/asterisk_click2dial_crm/wizard/create_crm_phonecall.py:45 +#, python-format +msgid "Call with" +msgstr "Conversation avec" + +#. module: asterisk_click2dial_crm +#: view:wizard.open.calling.partner:0 +msgid "Create call in CRM" +msgstr "Créer un appel dans la CRM" + +#. module: asterisk_click2dial_crm +#: view:wizard.create.crm.phonecall:0 +msgid "CRM phone call" +msgstr "Appel dans la CRM" + +#. module: asterisk_click2dial_crm +#: view:wizard.create.crm.phonecall:0 +msgid "No" +msgstr "Non" + +#. module: asterisk_click2dial_crm +#: model:ir.model,name:asterisk_click2dial_crm.model_wizard_open_calling_partner +msgid "wizard.open.calling.partner" +msgstr "wizard.open.calling.partner" + +#. module: asterisk_click2dial_crm +#: model:ir.model,name:asterisk_click2dial_crm.model_wizard_create_crm_phonecall +msgid "wizard.create.crm.phonecall" +msgstr "wizard.create.crm.phonecall" + +#. module: asterisk_click2dial_crm +#: field:res.users,propose_creation_crm_phonecall:0 +msgid "Propose to create a call in CRM after a click2dial" +msgstr "Propose de créer un appel dans la CRM après un click2dial" + +#. module: asterisk_click2dial_crm +#: view:wizard.create.crm.phonecall:0 +msgid "Create a phone call in the CRM ?" +msgstr "Créer un appel téléphonique dans la CRM ?" + +#. module: asterisk_click2dial_crm +#: model:ir.model,name:asterisk_click2dial_crm.model_res_users +msgid "res.users" +msgstr "res.users" + +#. module: asterisk_click2dial_crm +#: view:wizard.create.crm.phonecall:0 +msgid "Yes" +msgstr "Oui" + +#. module: asterisk_click2dial_crm +#: model:ir.model,name:asterisk_click2dial_crm.model_res_partner_address +msgid "Partner Addresses" +msgstr "Carnet d'adresses" + diff --git a/asterisk_click2dial_crm/res_users_view.xml b/asterisk_click2dial_crm/res_users_view.xml new file mode 100644 index 0000000..1beff6a --- /dev/null +++ b/asterisk_click2dial_crm/res_users_view.xml @@ -0,0 +1,24 @@ + + + + + + + + + asterisk.crm.option.view + res.users + + + + + + + + + + diff --git a/asterisk_click2dial_crm/wizard/__init__.py b/asterisk_click2dial_crm/wizard/__init__.py new file mode 100644 index 0000000..9200a68 --- /dev/null +++ b/asterisk_click2dial_crm/wizard/__init__.py @@ -0,0 +1,23 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# Asterisk click2dial CRM module for OpenERP +# Copyright (c) 2012 Akretion (http://www.akretion.com/) +# @author: Alexis de Lattre +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import create_crm_phonecall diff --git a/asterisk_click2dial_crm/res_partner_address.py b/asterisk_click2dial_crm/wizard/create_crm_phonecall.py similarity index 61% rename from asterisk_click2dial_crm/res_partner_address.py rename to asterisk_click2dial_crm/wizard/create_crm_phonecall.py index e4febbf..34b2a1d 100644 --- a/asterisk_click2dial_crm/res_partner_address.py +++ b/asterisk_click2dial_crm/wizard/create_crm_phonecall.py @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# OpenERP, Open Source Management Solution +# Asterisk click2dial CRM module for OpenERP # Copyright (c) 2011 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. # Copyright (c) 2012 Akretion (http://www.akretion.com) # @author: Jesús Martín @@ -26,56 +26,23 @@ from osv import osv, fields # Lib to translate error messages from tools.translate import _ -class res_partner_address(osv.osv): - _inherit = "res.partner.address" - def dial(self, cr, uid, ids, phone_field='phone', context=None): - ''' - This method open the phone call history when the phone click2dial - button of asterisk_click2dial module is pressed - :return the phone call history view of the partner - ''' - if context is None: - context = {} - super(res_partner_address, self).dial(cr, uid, ids, phone_field=phone_field, context=context) - return self.create_open_phonecall(cr, uid, ids, crm_categ='Outbound', context=context) +class wizard_create_crm_phonecall(osv.osv_memory): + _name = "wizard.create.crm.phonecall" + def button_create_outgoing_phonecall(self, cr, uid, ids, context=None): + partner_address = self.pool.get('res.partner.address').browse(cr, uid, context.get('partner_address_id'), context=context) + return self._create_open_crm_phonecall(cr, uid, partner_address, crm_categ='Outbound', context=context) - def create_open_phonecall(self, cr, uid, ids, crm_categ, context=None): + def _create_open_crm_phonecall(self, cr, uid, partner_address, crm_categ, context=None): if context is None: context = {} - crm_phonecall_id = self.create_phonecall(cr, uid, ids, crm_categ=crm_categ, context=context) - partner = self.browse(cr, uid, ids[0], context=context).partner_id - return { - 'name': partner.name, - 'domain': "[('partner_address_id.partner_id.id', '=', %s)]" % partner.id, - 'res_model': 'crm.phonecall', - 'res_id': [crm_phonecall_id], - 'view_type': 'form', - 'view_mode': 'form,tree', - 'type': 'ir.actions.act_window', - 'nodestroy': True, - 'target': 'current', - 'context': context, - } - - - def create_phonecall(self, cr, uid, ids, crm_categ='Outbound', context=None): - ''' - This method creates a phone call history when the phone click2dial - button of asterisk_click2dial module is pressed and opens it. - :return True - ''' - if context is None: - context = {} - crm_phonecall_obj = self.pool.get('crm.phonecall') - partner_address = self.browse(cr, uid, ids[0], context=context) categ_ids = self.pool.get('crm.case.categ').search(cr, uid, [('name','=',crm_categ)], context={'lang': 'en_US'}) case_section_ids = self.pool.get('crm.case.section').search(cr, uid, [('member_ids', 'in', uid)], context=context) values = { - 'name': "CRM Call", # TODO check name + 'name': _('Call with') + ' ' + partner_address.name, 'partner_id': partner_address.partner_id and partner_address.partner_id.id or False, 'partner_address_id': partner_address.id, 'partner_phone': partner_address.phone, @@ -84,20 +51,37 @@ class res_partner_address(osv.osv): 'user_id': uid, 'categ_id': categ_ids and categ_ids[0] or False, 'section_id': case_section_ids and case_section_ids[0] or False, + # As we now ask the user if he wants to create a phone call in CRM, + # we suppose that he will decide to create one only if the call + # has succeeded, so we create it directly in 'Held' (done) state. + # Otherwise, it would have been created in 'Todo' (open) state. + 'state': 'done', } crm_phonecall_id = crm_phonecall_obj.create(cr, uid, values, context=context) - return crm_phonecall_id -res_partner_address() + return { + 'name': partner_address.name, + 'domain': [('partner_id', '=', partner_address.partner_id.id)], + 'res_model': 'crm.phonecall', + 'res_id': [crm_phonecall_id], + 'view_type': 'form', + 'view_mode': 'form,tree', + 'type': 'ir.actions.act_window', + 'nodestroy': False, # close the pop-up wizard after action + 'target': 'current', + 'context': context, + } + +wizard_create_crm_phonecall() + class wizard_open_calling_partner(osv.osv_memory): _inherit = "wizard.open.calling.partner" def create_incoming_phonecall(self, cr, uid, ids, crm_categ, context=None): '''Started by button on 'open calling partner wizard''' - partner_address_id = self.browse(cr, uid, ids[0], context=context).partner_address_id.id - action = self.pool.get('res.partner.address').create_open_phonecall(cr, uid, [partner_address_id], crm_categ='Inbound', context=context) - action['nodestroy'] = False + partner_address = self.browse(cr, uid, ids[0], context=context).partner_address_id + action = self.pool.get('wizard.create.crm.phonecall')._create_open_crm_phonecall(cr, uid, partner_address, crm_categ='Inbound', context=context) return action wizard_open_calling_partner() diff --git a/asterisk_click2dial_crm/wizard/create_crm_phonecall_view.xml b/asterisk_click2dial_crm/wizard/create_crm_phonecall_view.xml new file mode 100644 index 0000000..7467d79 --- /dev/null +++ b/asterisk_click2dial_crm/wizard/create_crm_phonecall_view.xml @@ -0,0 +1,37 @@ + + + + + + + + + create_crm_phonecall.view + wizard.create.crm.phonecall + form + +
+