diff --git a/.travis.yml b/.travis.yml index d1662f9..a66e27c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ install: - git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} - travis_install_nightly - - pip install phonenumbers py-Asterisk + - pip install phonenumbers py-Asterisk SOAPpy - hg clone http://bitbucket.org/anybox/web_action_request -b ${VERSION} ${HOME}/web_action_request - hg clone http://bitbucket.org/anybox/bus_enhanced ${HOME}/bus_enhanced diff --git a/README.md b/README.md index 5fb9db7..2bf7b19 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,18 @@ [![Build Status](https://travis-ci.org/OCA/connector-telephony.svg?branch=8.0)](https://travis-ci.org/OCA/connector-telephony) [![Coverage Status](https://coveralls.io/repos/OCA/connector-telephony/badge.png?branch=8.0)](https://coveralls.io/r/OCA/connector-telephony?branch=8.0) -# Odoo-Asterisk connector +# Odoo telephony connector -Asterisk is an OpenSource software for telephony. -It is used worldwide to run IPBXes inside companies. -This project connects Asterisk to Odoo/OpenERP. +This projets aims at connecting Odoo to different phone systems. Phone systems currently supported are Asterisk (an OpenSource IPBX, cf [asterisk.org](http://www.asterisk.org/) and OVH (the centrex offer of OVH, cf the [OVH website](http://www.ovhtelecom.fr/telephonie/)). -This project also provides a serie of modules (base\_phone, base\_phone\_popup, -crm\_phone, hr\_phone, event\_phone, etc...) that are independant from -Asterisk and can be usefull on all Odoo/OpenERP installations. +This project provides: +* a serie of modules (base\_phone, base\_phone\_popup, + crm\_phone, hr\_phone, event\_phone, etc...) that are independant from + the phone system and can be usefull on all Odoo installations. +* several modules (asterisk\_click2dial, ovh\_telephony\_connector) + that are specific to a particular phone system. -The main maintainer of the Asterisk-OpenERP connector is Alexis de Lattre from +The main maintainer of this project is Alexis de Lattre from Akretion (alexis.delattre \_at\_ akretion.com). To know more about the OpenERP-Asterisk connector, refer to the documentation diff --git a/asterisk_click2dial/asterisk_click2dial.py b/asterisk_click2dial/asterisk_click2dial.py index 0babd4d..e9c9d9f 100644 --- a/asterisk_click2dial/asterisk_click2dial.py +++ b/asterisk_click2dial/asterisk_click2dial.py @@ -392,10 +392,12 @@ class res_users(orm.Model): )] -class phone_common(orm.AbstractModel): +class PhoneCommon(orm.AbstractModel): _inherit = 'phone.common' def click2dial(self, cr, uid, erp_number, context=None): + res = super(PhoneCommon, self).click2dial( + cr, uid, erp_number, context=context) if not erp_number: raise orm.except_orm( _('Error:'), @@ -458,4 +460,5 @@ class phone_common(orm.AbstractModel): finally: ast_manager.Logoff() - return {'dialed_number': ast_number} + res['dialed_number'] = ast_number + return res diff --git a/asterisk_click2dial_crm/__init__.py b/asterisk_click2dial_crm/__init__.py index a42e8f0..676d5d5 100644 --- a/asterisk_click2dial_crm/__init__.py +++ b/asterisk_click2dial_crm/__init__.py @@ -19,5 +19,3 @@ # along with this program. If not, see . # ############################################################################## - -from . import asterisk_click2dial_crm diff --git a/asterisk_click2dial_crm/__openerp__.py b/asterisk_click2dial_crm/__openerp__.py index 1e3e3dc..7f63300 100644 --- a/asterisk_click2dial_crm/__openerp__.py +++ b/asterisk_click2dial_crm/__openerp__.py @@ -31,34 +31,18 @@ Asterisk Click2dial CRM ======================= -This module adds CRM-specific features to the asterisk_click2dial module. +This module is *EMPTY* ; so you should uninstall it now. +The code that used to be in this module has been moved to the module +*crm_phone* that is available in the same GitHub repository +https://github.com/OCA/connector-telephony -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 -completely re-written by Akretion. - -A detailed documentation for the OpenERP-Asterisk connector is available on the -Akretion Web site : -http://www.akretion.com/products-and-services/openerp-asterisk-voip-connector +This module will be removed from the repository in the near future. """, "depends": [ 'asterisk_click2dial', 'crm_phone', ], - "data": [ - 'res_users_view.xml', - ], + "data": [], "installable": True, - "application": True, + "application": False, } diff --git a/asterisk_click2dial_crm/asterisk_click2dial_crm.py b/asterisk_click2dial_crm/asterisk_click2dial_crm.py deleted file mode 100644 index 50e3065..0000000 --- a/asterisk_click2dial_crm/asterisk_click2dial_crm.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- encoding: utf-8 -*- -############################################################################## -# -# Asterisk click2dial CRM module for OpenERP -# Copyright (c) 2012-2014 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 . -# -############################################################################## - -from openerp import models, api, _ - - -class PhoneCommon(models.AbstractModel): - _inherit = 'phone.common' - - @api.model - def click2dial(self, erp_number): - ''' - Inherit the native click2dial function to trigger - a wizard "Create Call in CRM" via the Javascript code - of base_phone - ''' - res = super(PhoneCommon, self).click2dial(erp_number) - if ( - self.env.context.get('click2dial_model') in - ('res.partner', 'crm.lead') and - self.env.user.context_propose_creation_crm_call): - res.update({ - 'action_name': _('Create Call in CRM'), - 'action_model': 'wizard.create.crm.phonecall', - }) - return res diff --git a/asterisk_click2dial_crm/i18n/asterisk_click2dial_crm.pot b/asterisk_click2dial_crm/i18n/asterisk_click2dial_crm.pot deleted file mode 100644 index f39ccb0..0000000 --- a/asterisk_click2dial_crm/i18n/asterisk_click2dial_crm.pot +++ /dev/null @@ -1,88 +0,0 @@ -# Translation of OpenERP Server. -# This file contains the translation of the following modules: -# * asterisk_click2dial_crm -# -msgid "" -msgstr "" -"Project-Id-Version: OpenERP Server 7.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-08-25 22:02+0000\n" -"PO-Revision-Date: 2014-08-25 22:02+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 -#: view:wizard.create.crm.phonecall:0 -msgid "CRM phone call" -msgstr "" - -#. module: asterisk_click2dial_crm -#: 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/asterisk_click2dial_crm.py:46 -#, python-format -msgid "Create Call in CRM" -msgstr "" - -#. module: 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_crm_lead -msgid "Lead/Opportunity" -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 "Open calling partner" -msgstr "" - -#. module: asterisk_click2dial_crm -#: model:ir.model,name:asterisk_click2dial_crm.model_res_partner -msgid "Partner" -msgstr "" - -#. module: asterisk_click2dial_crm -#: field:res.users,context_propose_creation_crm_call:0 -msgid "Propose to create a call in CRM after a click2dial" -msgstr "" - -#. module: asterisk_click2dial_crm -#: model:ir.model,name:asterisk_click2dial_crm.model_reformat_all_phonenumbers -msgid "Reformat all phone numbers" -msgstr "" - -#. module: asterisk_click2dial_crm -#: model:ir.model,name:asterisk_click2dial_crm.model_res_users -msgid "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_phone_common -msgid "phone.common" -msgstr "" - -#. module: asterisk_click2dial_crm -#: model:ir.model,name:asterisk_click2dial_crm.model_wizard_create_crm_phonecall -msgid "wizard.create.crm.phonecall" -msgstr "" - diff --git a/asterisk_click2dial_crm/i18n/ca.po b/asterisk_click2dial_crm/i18n/ca.po deleted file mode 100644 index b50b2d9..0000000 --- a/asterisk_click2dial_crm/i18n/ca.po +++ /dev/null @@ -1,44 +0,0 @@ -# Translation of OpenERP Server. -# This file contains the translation of the following modules: -# * asterisk_click2dial_crm -# -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 16:30+0100\n" -"Last-Translator: Jesús Martín \n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: \n" - -#. module: asterisk_click2dial_crm -#: model:ir.model,name:asterisk_click2dial_crm.model_res_partner_address -msgid "Partner Addresses" -msgstr "Adreça de l'empresa" - -#. 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" -" Crea una trucada de telèfon sortint quan l'usuari fa una trucada de telèfon\n" -" mitjançant el botó click2dial de la vista d'adreces de l'empresa i l'obre a una\n" -" nova pestanya.\n" -" " - -#. module: asterisk_click2dial_crm -#: model:ir.module.module,shortdesc:asterisk_click2dial_crm.module_meta_information -msgid "Asterisk Click2dial CRM" -msgstr "Asterisk Click2dial CRM" - -#~ msgid "Reconciliation" -#~ msgstr "Reconciliació" - diff --git a/asterisk_click2dial_crm/i18n/es.po b/asterisk_click2dial_crm/i18n/es.po deleted file mode 100644 index a91196e..0000000 --- a/asterisk_click2dial_crm/i18n/es.po +++ /dev/null @@ -1,44 +0,0 @@ -# Translation of OpenERP Server. -# This file contains the translation of the following modules: -# * asterisk_click2dial_crm -# -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 16:32+0100\n" -"Last-Translator: Jesús Martín \n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: \n" - -#. module: asterisk_click2dial_crm -#: model:ir.model,name:asterisk_click2dial_crm.model_res_partner_address -msgid "Partner Addresses" -msgstr "Dirección de la empresa" - -#. 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" -" Crea una llamada de teléfono saliente cuando el usuario hace una llamada de\n" -" teléfono mediante el botón click2dial de la vista de direcciones de la empresa y\n" -" la abre a una nueva pestaña.\n" -" " - -#. module: asterisk_click2dial_crm -#: model:ir.module.module,shortdesc:asterisk_click2dial_crm.module_meta_information -msgid "Asterisk Click2dial CRM" -msgstr "Asterisk Click2dial CRM" - -#~ msgid "Reconciliation" -#~ msgstr "Reconciliació" - diff --git a/asterisk_click2dial_crm/i18n/fr.po b/asterisk_click2dial_crm/i18n/fr.po deleted file mode 100644 index ba58f45..0000000 --- a/asterisk_click2dial_crm/i18n/fr.po +++ /dev/null @@ -1,88 +0,0 @@ -# Translation of OpenERP Server. -# This file contains the translation of the following modules: -# * asterisk_click2dial_crm -# -msgid "" -msgstr "" -"Project-Id-Version: OpenERP Server 7.0\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-08-25 22:02+0000\n" -"PO-Revision-Date: 2014-08-25 22:02+0000\n" -"Last-Translator: Alexis de Lattre \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 -#: view:wizard.create.crm.phonecall:0 -msgid "CRM phone call" -msgstr "Appel dans la CRM" - -#. 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/asterisk_click2dial_crm.py:46 -#, python-format -msgid "Create Call in CRM" -msgstr "Créer Appel dans CRM" - -#. 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_crm_lead -msgid "Lead/Opportunity" -msgstr "Piste/opportunité" - -#. 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 "Open calling partner" -msgstr "Ouvrir le partenaire appelant" - -#. module: asterisk_click2dial_crm -#: model:ir.model,name:asterisk_click2dial_crm.model_res_partner -msgid "Partner" -msgstr "Partenaire" - -#. module: asterisk_click2dial_crm -#: field:res.users,context_propose_creation_crm_call: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 -#: model:ir.model,name:asterisk_click2dial_crm.model_reformat_all_phonenumbers -msgid "Reformat all phone numbers" -msgstr "Reformate tous les numéros de téléphone" - -#. module: asterisk_click2dial_crm -#: model:ir.model,name:asterisk_click2dial_crm.model_res_users -msgid "Users" -msgstr "Utilisateurs" - -#. 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_phone_common -msgid "phone.common" -msgstr "phone.common" - -#. 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" - diff --git a/asterisk_click2dial_crm/res_users_view.xml b/asterisk_click2dial_crm/res_users_view.xml deleted file mode 100644 index 0c57f29..0000000 --- a/asterisk_click2dial_crm/res_users_view.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - asterisk.crm.preferences.option.view - res.users - - - - 0 - - - - - - diff --git a/asterisk_click2dial_crm/static/description/icon.png b/asterisk_click2dial_crm/static/description/icon.png deleted file mode 100644 index f6a53a3..0000000 Binary files a/asterisk_click2dial_crm/static/description/icon.png and /dev/null differ diff --git a/base_phone/base_phone.py b/base_phone/base_phone.py index 778c02a..b5fb2b0 100644 --- a/base_phone/base_phone.py +++ b/base_phone/base_phone.py @@ -212,7 +212,7 @@ class PhoneCommon(models.AbstractModel): def click2dial(self, cr, uid, erp_number, context=None): '''This function is designed to be overridden in IPBX-specific - modules, such as asterisk_click2dial''' + modules, such as asterisk_click2dial or ovh_telephony_connector''' return {'dialed_number': erp_number} @api.model @@ -235,7 +235,7 @@ class PhoneCommon(models.AbstractModel): to_dial_number = phonenumbers.format_out_of_country_calling_number( parsed_num, country_code.upper()) to_dial_number = str(to_dial_number).translate(None, ' -.()/') - _logger.debug('Number to be sent to Asterisk = %s' % to_dial_number) + _logger.debug('Number to be sent to phone system: %s' % to_dial_number) return to_dial_number diff --git a/base_phone/controller.py b/base_phone/controller.py index b73f01a..1a90e95 100644 --- a/base_phone/controller.py +++ b/base_phone/controller.py @@ -1,8 +1,8 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Asterisk click2dial module for OpenERP -# Copyright (C) 2014 Alexis de Lattre (alexis@via.ecp.fr) +# Base Phone module for Odoo +# Copyright (C) 2014-2015 Alexis de Lattre (alexis@via.ecp.fr) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as diff --git a/base_phone/static/src/xml/phone.xml b/base_phone/static/src/xml/phone.xml index d1d4a59..7c5aae4 100644 --- a/base_phone/static/src/xml/phone.xml +++ b/base_phone/static/src/xml/phone.xml @@ -13,7 +13,8 @@ diff --git a/base_phone/wizard/number_not_found.py b/base_phone/wizard/number_not_found.py index 3580c47..4fc4a5b 100644 --- a/base_phone/wizard/number_not_found.py +++ b/base_phone/wizard/number_not_found.py @@ -1,8 +1,8 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Asterisk Click2dial module for OpenERP -# Copyright (C) 2010-2013 Alexis de Lattre +# Base Phone module for Odoo +# Copyright (C) 2010-2015 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 @@ -35,7 +35,8 @@ class number_not_found(orm.TransientModel): 'calling_number': fields.char( 'Calling Number', size=64, readonly=True, help="Phone number of calling party that has been obtained " - "from Asterisk, in the format used by Asterisk (not E.164)."), + "from the telephony server, in the format used by the " + "telephony server (not E.164)."), 'e164_number': fields.char( 'E.164 Number', size=64, help="E.164 equivalent of the calling number."), diff --git a/base_phone/wizard/number_not_found_view.xml b/base_phone/wizard/number_not_found_view.xml index 1cd47e1..f88b49f 100644 --- a/base_phone/wizard/number_not_found_view.xml +++ b/base_phone/wizard/number_not_found_view.xml @@ -1,7 +1,6 @@ diff --git a/crm_phone/crm_phone.py b/crm_phone/crm_phone.py index 3558fb7..aa6751a 100644 --- a/crm_phone/crm_phone.py +++ b/crm_phone/crm_phone.py @@ -20,7 +20,7 @@ # ############################################################################## -from openerp import models, fields +from openerp import models, fields, api, _ class CrmLead(models.Model): @@ -95,3 +95,20 @@ class ResUsers(models.Model): context_propose_creation_crm_call = fields.Boolean( string='Propose to create a call in CRM after a click2dial', default=True) + + +class PhoneCommon(models.AbstractModel): + _inherit = 'phone.common' + + @api.model + def click2dial(self, erp_number): + res = super(PhoneCommon, self).click2dial(erp_number) + if ( + self.env.user.context_propose_creation_crm_call and + self.env.context.get('click2dial_model') + in ('res.partner', 'crm.lead')): + res.update({ + 'action_name': _('Create Call in CRM'), + 'action_model': 'wizard.create.crm.phonecall', + }) + return res diff --git a/crm_phone/res_users_view.xml b/crm_phone/res_users_view.xml index 75589dc..10ffaf9 100644 --- a/crm_phone/res_users_view.xml +++ b/crm_phone/res_users_view.xml @@ -10,7 +10,7 @@ - asterisk.crm.res.users.form + crm.phone.res.users.form res.users @@ -22,7 +22,7 @@ - asterisk.crm.preferences.option.view + crm.phone.preferences.option.view res.users diff --git a/crm_phone/wizard/number_not_found.py b/crm_phone/wizard/number_not_found.py index 26a1922..df48bb2 100644 --- a/crm_phone/wizard/number_not_found.py +++ b/crm_phone/wizard/number_not_found.py @@ -1,8 +1,8 @@ # -*- encoding: utf-8 -*- ############################################################################## # -# Asterisk Click2dial module for OpenERP -# Copyright (C) 2010-2013 Alexis de Lattre +# CRM Phone module for Odoo +# Copyright (C) 2010-2015 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 diff --git a/ovh_telephony_connector/__init__.py b/ovh_telephony_connector/__init__.py new file mode 100644 index 0000000..5bd76f3 --- /dev/null +++ b/ovh_telephony_connector/__init__.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OVH Connector module for Odoo +# Copyright (C) 2015 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 . import ovh_connector diff --git a/ovh_telephony_connector/__openerp__.py b/ovh_telephony_connector/__openerp__.py new file mode 100644 index 0000000..3493565 --- /dev/null +++ b/ovh_telephony_connector/__openerp__.py @@ -0,0 +1,39 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OVH Connector module for Odoo +# Copyright (C) 2015 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 . +# +############################################################################## + +{ + 'name': 'OVH Telephony Connector', + 'version': '0.1', + 'category': 'Phone', + 'license': 'AGPL-3', + 'summary': 'OVH-Odoo telephony connector (click2call)', + 'author': 'Akretion', + 'website': 'http://www.akretion.com/', + 'depends': ['base_phone'], + 'external_dependencies': {'python': ['phonenumbers', 'SOAPpy']}, + 'data': [ + 'res_users_view.xml', + ], + 'demo': [], + 'qweb': ['static/src/xml/*.xml'], + 'application': True, + 'installable': True, +} diff --git a/ovh_telephony_connector/ovh_connector.py b/ovh_telephony_connector/ovh_connector.py new file mode 100644 index 0000000..ef138e1 --- /dev/null +++ b/ovh_telephony_connector/ovh_connector.py @@ -0,0 +1,104 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OVH connector module for Odoo +# Copyright (C) 2015 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 openerp import models, fields, api, _ +from openerp.exceptions import Warning +import logging + +try: + # -> pip install SOAPpy + from SOAPpy import WSDL +except ImportError: + WSDL = None + +_logger = logging.getLogger(__name__) + + +class ResUsers(models.Model): + _inherit = "res.users" + + ovh_billing_number = fields.Char(string='OVH Billing Number') + ovh_calling_number = fields.Char( + string="OVH Calling Number", help="The phone number that will " + "be presented during a click2dial") + ovh_click2call_login = fields.Char(string='OVH Click2call Login') + ovh_click2call_password = fields.Char( + string="OVH Click2call Password") + + +class PhoneCommon(models.AbstractModel): + _inherit = 'phone.common' + + @api.model + def click2dial(self, erp_number): + res = super(PhoneCommon, self).click2dial(erp_number) + if not erp_number: + raise Warning( + _('Missing phone number')) + + user = self.env.user + if not user.ovh_billing_number: + raise Warning( + _('Missing OVH Billing Number on user %s') % user.name) + + if not user.ovh_calling_number: + raise Warning( + _('Missing OVH Calling Number on user %s') % user.name) + + if not user.ovh_click2call_login: + raise Warning( + _('Missing OVH Click2call Login on user %s') % user.name) + + if not user.ovh_click2call_password: + raise Warning( + _('Missing OVH Click2dial Password on user %s') % user.name) + + soap = WSDL.Proxy('https://www.ovh.com/soapi/soapi-re-1.63.wsdl') + + called_number = self.convert_to_dial_number(erp_number) + _logger.debug( + 'Starting OVH telephonyClick2CallDo request with ' + 'login = %s billing number = %s calling number = %s ' + 'and called_number = %s' + % (user.ovh_click2call_login, user.ovh_billing_number, + user.ovh_calling_number, called_number)) + + try: + soap.telephonyClick2CallDo( + user.ovh_click2call_login, + user.ovh_click2call_password, + user.ovh_calling_number, + called_number, + user.ovh_billing_number) + _logger.info("OVH telephonyClick2CallDo successfull") + + except Exception, e: + _logger.error( + "Error in the OVH telephonyClick2CallDo request") + _logger.error( + "Here are the details of the error: '%s'" % unicode(e)) + raise Warning( + _("Click to call to OVH failed.\nHere is the error: " + "'%s'") + % unicode(e)) + + res['dialed_number'] = called_number + return res diff --git a/ovh_telephony_connector/res_users_view.xml b/ovh_telephony_connector/res_users_view.xml new file mode 100644 index 0000000..17c46bc --- /dev/null +++ b/ovh_telephony_connector/res_users_view.xml @@ -0,0 +1,42 @@ + + + + + + + + ovh_connector.res.users.form + res.users + + + + 0 + + + + + + + + + + + + + + ovh_connector.users.preferences.option.view + res.users + + + + 0 + + + + + + diff --git a/ovh_telephony_connector/static/src/xml/ovh_connector.xml b/ovh_telephony_connector/static/src/xml/ovh_connector.xml new file mode 100644 index 0000000..d469b31 --- /dev/null +++ b/ovh_telephony_connector/static/src/xml/ovh_connector.xml @@ -0,0 +1,17 @@ + + + +