Browse Source

Please welcome the new module ovh_telephony_connector !

Some code clean-up and re-organisation in the generic modules
Prepare the removal of the module asterisk_click2dial_crm
pull/47/head
Alexis de Lattre 9 years ago
parent
commit
e60a818fcb
  1. 17
      README.md
  2. 7
      asterisk_click2dial/asterisk_click2dial.py
  3. 2
      asterisk_click2dial_crm/__init__.py
  4. 30
      asterisk_click2dial_crm/__openerp__.py
  5. 45
      asterisk_click2dial_crm/asterisk_click2dial_crm.py
  6. 88
      asterisk_click2dial_crm/i18n/asterisk_click2dial_crm.pot
  7. 44
      asterisk_click2dial_crm/i18n/ca.po
  8. 44
      asterisk_click2dial_crm/i18n/es.po
  9. 88
      asterisk_click2dial_crm/i18n/fr.po
  10. 23
      asterisk_click2dial_crm/res_users_view.xml
  11. BIN
      asterisk_click2dial_crm/static/description/icon.png
  12. 4
      base_phone/base_phone.py
  13. 4
      base_phone/controller.py
  14. 3
      base_phone/static/src/xml/phone.xml
  15. 7
      base_phone/wizard/number_not_found.py
  16. 3
      base_phone/wizard/number_not_found_view.xml
  17. 19
      crm_phone/crm_phone.py
  18. 4
      crm_phone/res_users_view.xml
  19. 4
      crm_phone/wizard/number_not_found.py
  20. 22
      ovh_telephony_connector/__init__.py
  21. 39
      ovh_telephony_connector/__openerp__.py
  22. 104
      ovh_telephony_connector/ovh_connector.py
  23. 42
      ovh_telephony_connector/res_users_view.xml
  24. 17
      ovh_telephony_connector/static/src/xml/ovh_connector.xml

17
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

7
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

2
asterisk_click2dial_crm/__init__.py

@ -19,5 +19,3 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import asterisk_click2dial_crm

30
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,
}

45
asterisk_click2dial_crm/asterisk_click2dial_crm.py

@ -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 <alexis.delattre@akretion.com>
#
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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

88
asterisk_click2dial_crm/i18n/asterisk_click2dial_crm.pot

@ -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 ""

44
asterisk_click2dial_crm/i18n/ca.po

@ -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 <jmartin@zikzakmedia.com>\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ó"

44
asterisk_click2dial_crm/i18n/es.po

@ -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 <jmartin@zikzakmedia.com>\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ó"

88
asterisk_click2dial_crm/i18n/fr.po

@ -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 <alexis.delattre@akretion.com>\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"

23
asterisk_click2dial_crm/res_users_view.xml

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2012-2015 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="view_users_form_simple_modif" model="ir.ui.view">
<field name="name">asterisk.crm.preferences.option.view</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base_phone.view_users_form_simple_modif" />
<field name="arch" type="xml">
<group name="phone" position="attributes">
<attribute name="invisible">0</attribute>
</group>
</field>
</record>
</data>
</openerp>

BIN
asterisk_click2dial_crm/static/description/icon.png

Before

Width: 100  |  Height: 100  |  Size: 16 KiB

4
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

4
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

3
base_phone/static/src/xml/phone.xml

@ -13,7 +13,8 @@
<a href="#" class="oe_form_uri"/><span class="oe_form_char_content"/>
<!--
You should add the following "<a .. />" in your IPBX-specific
module (such as asterisk_click2dial) via <t t-extend="FieldPhone">
module (such as asterisk_click2dial or ovh_telephony_connector)
via <t t-extend="FieldPhone">
<a id="click2dial" href="#" class="oe_bold"/>
-->
</t>

7
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 <alexis@via.ecp.fr>
# Base Phone module for Odoo
# Copyright (C) 2010-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
@ -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."),

3
base_phone/wizard/number_not_found_view.xml

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Asterisk Click2dial module for OpenERP
Copyright (C) 2012-2013 Alexis de Lattre <alexis@via.ecp.fr>
Copyright (C) 2012-2015 Alexis de Lattre <alexis@via.ecp.fr>
The licence is in the file __openerp__.py
-->

19
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

4
crm_phone/res_users_view.xml

@ -10,7 +10,7 @@
<!-- Add option on user form view -->
<record id="view_users_form" model="ir.ui.view">
<field name="name">asterisk.crm.res.users.form</field>
<field name="name">crm.phone.res.users.form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base_phone.view_users_form"/>
<field name="arch" type="xml">
@ -22,7 +22,7 @@
</record>
<record id="view_users_form_simple_modif" model="ir.ui.view">
<field name="name">asterisk.crm.preferences.option.view</field>
<field name="name">crm.phone.preferences.option.view</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base_phone.view_users_form_simple_modif" />
<field name="arch" type="xml">

4
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 <alexis@via.ecp.fr>
# CRM Phone module for Odoo
# Copyright (C) 2010-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

22
ovh_telephony_connector/__init__.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# OVH Connector module for Odoo
# Copyright (C) 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
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import ovh_connector

39
ovh_telephony_connector/__openerp__.py

@ -0,0 +1,39 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OVH Connector module for Odoo
# Copyright (C) 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
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
{
'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,
}

104
ovh_telephony_connector/ovh_connector.py

@ -0,0 +1,104 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# OVH connector module for Odoo
# Copyright (C) 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
# 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 <http://www.gnu.org/licenses/>.
#
##############################################################################
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

42
ovh_telephony_connector/res_users_view.xml

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 Akretion (www.akretion.com)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="view_users_form" model="ir.ui.view">
<field name="name">ovh_connector.res.users.form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base_phone.view_users_form"/>
<field name="arch" type="xml">
<page name="phone" position="attributes">
<attribute name="invisible">0</attribute>
</page>
<group name="phone-preferences" position="after">
<group name="ovh" string="OVH Parameters">
<field name="ovh_billing_number"/>
<field name="ovh_calling_number"/>
<field name="ovh_click2call_login"/>
<field name="ovh_click2call_password" password="True"/>
</group>
</group>
</field>
</record>
<record id="view_users_form_simple_modif" model="ir.ui.view">
<field name="name">ovh_connector.users.preferences.option.view</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base_phone.view_users_form_simple_modif" />
<field name="arch" type="xml">
<group name="phone" position="attributes">
<attribute name="invisible">0</attribute>
</group>
</field>
</record>
</data>
</openerp>

17
ovh_telephony_connector/static/src/xml/ovh_connector.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
OVH connector module for Odoo
Copyright (C) 2015 Alexis de Lattre <alexis@via.ecp.fr>
The licence is in the file __openerp__.py
-->
<template>
<!-- Add Dial button in phone widget for click2dial feature -->
<t t-extend="FieldPhone">
<t t-jquery="a.oe_form_uri" t-operation="after">
<a id="click2dial" href="#" class="oe_bold"/>
</t>
</t>
</template>
Loading…
Cancel
Save