Jordi Ballester Alomar
6 years ago
19 changed files with 314 additions and 13 deletions
-
5base_sms_client/__init__.py
-
4base_sms_client/__manifest__.py
-
2base_sms_client/data/sms_gateway_data.xml
-
5base_sms_client/models/__init__.py
-
4base_sms_client/models/server_action.py
-
1clicksend_sms_client/__init__.py
-
19clicksend_sms_client/__manifest__.py
-
9clicksend_sms_client/data/keychain.xml
-
35clicksend_sms_client/i18n/ar.po
-
34clicksend_sms_client/i18n/ca.po
-
35clicksend_sms_client/i18n/es.po
-
34clicksend_sms_client/i18n/fr.po
-
30clicksend_sms_client/i18n/ovh_sms_client.pot
-
2clicksend_sms_client/models/__init__.py
-
21clicksend_sms_client/models/keychain.py
-
78clicksend_sms_client/models/sms_gateway.py
-
4clicksend_sms_client/readme/CONFIGURE.rst
-
4clicksend_sms_client/readme/CONTRIBUTORS.rst
-
1clicksend_sms_client/readme/DESCRIPTION.rst
@ -1,7 +1,2 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Author: Sébastien BEAU <sebastien.beau@akretion.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
|
|||
from . import wizard |
|||
from . import models |
@ -1,8 +1,3 @@ |
|||
# -*- coding: utf-8 -*- |
|||
# Copyright (C) 2013 Julius Network Solutions SARL <contact@julius.fr> |
|||
# Author: Sébastien BEAU <sebastien.beau@akretion.com> |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from . import sms_gateway |
|||
from . import server_action |
|||
from . import sms_template |
|||
|
@ -0,0 +1 @@ |
|||
from . import models |
@ -0,0 +1,19 @@ |
|||
# Copyright (C) 2013 Julius Network Solutions SARL <contact@julius.fr> |
|||
# Copyright (C) 2015 Sébastien BEAU <sebastien.beau@akretion.com> |
|||
# Copyright (C) 2019 Eficent Business and IT Consulting Services, S.L. |
|||
|
|||
{ |
|||
'name': 'ClickSend SMS Client', |
|||
'version': '11.0.1.0.1', |
|||
'license': 'AGPL-3', |
|||
'depends': ['mail', |
|||
'base_sms_client', |
|||
'keychain', |
|||
], |
|||
'author': 'Eficent,' |
|||
'Odoo Community Association (OCA)', |
|||
'website': 'https://github.com/OCA/connector-telephony', |
|||
'category': 'Tools', |
|||
'data': ['data/keychain.xml'], |
|||
'installable': True, |
|||
} |
@ -0,0 +1,9 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo noupdate="1"> |
|||
<record id="keychain_clicksend" model="keychain.account"> |
|||
<field name="name">ClickSend sms default</field> |
|||
<field name="namespace">clicksend_provider</field> |
|||
<field name="technical_name">clicksend_default_account</field> |
|||
</record> |
|||
|
|||
</odoo> |
@ -0,0 +1,35 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * ovh_sms_client |
|||
# |
|||
# Translators: |
|||
# OCA Transbot <transbot@odoo-community.org>, 2017 |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: Odoo Server 10.0\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2017-04-27 02:37+0000\n" |
|||
"PO-Revision-Date: 2017-04-27 02:37+0000\n" |
|||
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n" |
|||
"Language-Team: Arabic (https://www.transifex.com/oca/teams/23907/ar/)\n" |
|||
"Language: ar\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " |
|||
"&& n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n" |
|||
|
|||
#. module: ovh_sms_client |
|||
#: model:ir.model,name:ovh_sms_client.model_sms_sms |
|||
msgid "SMS" |
|||
msgstr "رسالة قصيرة (SMS)" |
|||
|
|||
#. module: ovh_sms_client |
|||
#: model:ir.model,name:ovh_sms_client.model_sms_gateway |
|||
msgid "SMS Client" |
|||
msgstr "" |
|||
|
|||
#. module: ovh_sms_client |
|||
#: model:ir.model,name:ovh_sms_client.model_keychain_account |
|||
msgid "keychain.account" |
|||
msgstr "" |
@ -0,0 +1,34 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * ovh_sms_client |
|||
# |
|||
# Translators: |
|||
# OCA Transbot <transbot@odoo-community.org>, 2017 |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: Odoo Server 10.0\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2017-04-27 02:37+0000\n" |
|||
"PO-Revision-Date: 2017-04-27 02:37+0000\n" |
|||
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n" |
|||
"Language-Team: Catalan (https://www.transifex.com/oca/teams/23907/ca/)\n" |
|||
"Language: ca\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
|||
|
|||
#. module: ovh_sms_client |
|||
#: model:ir.model,name:ovh_sms_client.model_sms_sms |
|||
msgid "SMS" |
|||
msgstr "SMS" |
|||
|
|||
#. module: ovh_sms_client |
|||
#: model:ir.model,name:ovh_sms_client.model_sms_gateway |
|||
msgid "SMS Client" |
|||
msgstr "Client SMS" |
|||
|
|||
#. module: ovh_sms_client |
|||
#: model:ir.model,name:ovh_sms_client.model_keychain_account |
|||
msgid "keychain.account" |
|||
msgstr "" |
@ -0,0 +1,35 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * ovh_sms_client |
|||
# |
|||
# Translators: |
|||
# OCA Transbot <transbot@odoo-community.org>, 2017 |
|||
# enjolras <yo@miguelrevilla.com>, 2018 |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: Odoo Server 10.0\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2018-02-10 01:41+0000\n" |
|||
"PO-Revision-Date: 2018-02-10 01:41+0000\n" |
|||
"Last-Translator: enjolras <yo@miguelrevilla.com>, 2018\n" |
|||
"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" |
|||
"Language: es\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" |
|||
|
|||
#. module: ovh_sms_client |
|||
#: model:ir.model,name:ovh_sms_client.model_sms_sms |
|||
msgid "SMS" |
|||
msgstr "SMS" |
|||
|
|||
#. module: ovh_sms_client |
|||
#: model:ir.model,name:ovh_sms_client.model_sms_gateway |
|||
msgid "SMS Client" |
|||
msgstr "Cliente SMS" |
|||
|
|||
#. module: ovh_sms_client |
|||
#: model:ir.model,name:ovh_sms_client.model_keychain_account |
|||
msgid "keychain.account" |
|||
msgstr "keychain.account" |
@ -0,0 +1,34 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * ovh_sms_client |
|||
# |
|||
# Translators: |
|||
# OCA Transbot <transbot@odoo-community.org>, 2017 |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: Odoo Server 10.0\n" |
|||
"Report-Msgid-Bugs-To: \n" |
|||
"POT-Creation-Date: 2017-04-27 02:37+0000\n" |
|||
"PO-Revision-Date: 2017-04-27 02:37+0000\n" |
|||
"Last-Translator: OCA Transbot <transbot@odoo-community.org>, 2017\n" |
|||
"Language-Team: French (https://www.transifex.com/oca/teams/23907/fr/)\n" |
|||
"Language: fr\n" |
|||
"MIME-Version: 1.0\n" |
|||
"Content-Type: text/plain; charset=UTF-8\n" |
|||
"Content-Transfer-Encoding: \n" |
|||
"Plural-Forms: nplurals=2; plural=(n > 1);\n" |
|||
|
|||
#. module: ovh_sms_client |
|||
#: model:ir.model,name:ovh_sms_client.model_sms_sms |
|||
msgid "SMS" |
|||
msgstr "SMS" |
|||
|
|||
#. module: ovh_sms_client |
|||
#: model:ir.model,name:ovh_sms_client.model_sms_gateway |
|||
msgid "SMS Client" |
|||
msgstr "Client SMS" |
|||
|
|||
#. module: ovh_sms_client |
|||
#: model:ir.model,name:ovh_sms_client.model_keychain_account |
|||
msgid "keychain.account" |
|||
msgstr "" |
@ -0,0 +1,30 @@ |
|||
# Translation of Odoo Server. |
|||
# This file contains the translation of the following modules: |
|||
# * ovh_sms_client |
|||
# |
|||
msgid "" |
|||
msgstr "" |
|||
"Project-Id-Version: Odoo Server 10.0\n" |
|||
"Report-Msgid-Bugs-To: \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: ovh_sms_client |
|||
#: model:ir.model,name:ovh_sms_client.model_sms_sms |
|||
msgid "SMS" |
|||
msgstr "" |
|||
|
|||
#. module: ovh_sms_client |
|||
#: model:ir.model,name:ovh_sms_client.model_sms_gateway |
|||
msgid "SMS Client" |
|||
msgstr "" |
|||
|
|||
#. module: ovh_sms_client |
|||
#: model:ir.model,name:ovh_sms_client.model_keychain_account |
|||
msgid "keychain.account" |
|||
msgstr "" |
|||
|
@ -0,0 +1,2 @@ |
|||
from . import sms_gateway |
|||
from . import keychain |
@ -0,0 +1,21 @@ |
|||
# Copyright (C) 2015 Sébastien BEAU <sebastien.beau@akretion.com> |
|||
# Valentin CHEMIERE <valentin.chemiere@akretion.com> |
|||
# Copyright (C) 2019 Eficent Business and IT Consulting Services, S.L. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from odoo import models, fields |
|||
|
|||
CLICKSEND_KEYCHAIN_NAMESPACE = 'clicksend_provider' |
|||
|
|||
|
|||
class Keychain(models.Model): |
|||
_inherit = 'keychain.account' |
|||
|
|||
namespace = fields.Selection( |
|||
selection_add=[(CLICKSEND_KEYCHAIN_NAMESPACE, 'ClickSend_sms')]) |
|||
|
|||
def _clicksend_provider_init_data(self): |
|||
return {'sms_account': ""} |
|||
|
|||
def _clicksend_provider_validate_data(self, data): |
|||
return True |
@ -0,0 +1,78 @@ |
|||
# Copyright (C) 2015 Sébastien BEAU <sebastien.beau@akretion.com> |
|||
# Valentin CHEMIERE <valentin.chemiere@akretion.com> |
|||
# Copyright (C) 2019 Eficent Business and IT Consulting Services, S.L. |
|||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). |
|||
|
|||
from odoo import api, models, fields |
|||
from ..models.keychain import CLICKSEND_KEYCHAIN_NAMESPACE |
|||
import requests |
|||
import logging |
|||
from xml.etree.ElementTree import XML, fromstring, tostring |
|||
|
|||
_logger = logging.getLogger(__name__) |
|||
|
|||
|
|||
class SmsClient(models.Model): |
|||
_inherit = "sms.gateway" |
|||
|
|||
method = fields.Selection(selection_add=[ |
|||
('http_clicksend', 'ClickSend HTTP')]) |
|||
|
|||
@api.multi |
|||
def _provider_get_provider_conf(self): |
|||
for rec in self: |
|||
keychain = rec.env['keychain.account'] |
|||
# TODO: implement suspend_security module |
|||
#if rec._check_permissions(): |
|||
# retrieve = keychain.suspend_security().retrieve |
|||
#else: |
|||
# retrieve = keychain.retrieve |
|||
retrieve = keychain.retrieve |
|||
accounts = retrieve( |
|||
[['namespace', '=', CLICKSEND_KEYCHAIN_NAMESPACE]]) |
|||
return accounts[0] |
|||
|
|||
|
|||
class SmsSms(models.Model): |
|||
_inherit = "sms.sms" |
|||
|
|||
@api.model |
|||
def _prepare_http_clicksend(self): |
|||
|
|||
keychain_account = self.gateway_id._provider_get_provider_conf() |
|||
params = { |
|||
'username': keychain_account['login'], |
|||
'key': keychain_account.get_password(), |
|||
'senderid': self.gateway_id.from_provider, |
|||
'url': self.gateway_id.url, |
|||
'to': self._convert_to_e164(self.mobile), |
|||
'message': self.message, |
|||
} |
|||
return params |
|||
|
|||
@api.model |
|||
def _convert_to_e164(self, erp_number): |
|||
to_dial_number = erp_number.replace(u'\xa0', u'') |
|||
return to_dial_number |
|||
|
|||
@api.multi |
|||
def _send_http_clicksend(self): |
|||
self.ensure_one() |
|||
params = self._prepare_http_clicksend() |
|||
r = requests.get(params['url'], params=params.items()) |
|||
params.update({ |
|||
'password': '*****', |
|||
'to': '*****', |
|||
'smsAccount': '*****', |
|||
'login': '*****', |
|||
}) |
|||
_logger.debug("Call ClickSend API : %s params %s", |
|||
params['url'], params) |
|||
response = r.text |
|||
xml_response = fromstring(response) |
|||
for messages in xml_response: |
|||
for message in messages: |
|||
for element in message: |
|||
if element.tag == 'result' and \ |
|||
element.text != '0000': |
|||
raise ValueError(response) |
@ -0,0 +1,4 @@ |
|||
To configure this module, you need to: |
|||
|
|||
* go to settings > technical > telephony > gateway configuration and select ClickSend http in method |
|||
* go to settings > technical > keychain and set your credentials |
@ -0,0 +1,4 @@ |
|||
* Valentin Chemiere |
|||
* Yvan Party <yvan@julius.fr> |
|||
* MonsieurB <monsieurb@saaslys.com> |
|||
* Jordi Ballester Alomar <jordi.ballester@eficent.com> |
@ -0,0 +1 @@ |
|||
This module provides ClickSend fields to create a ClickSend gateway. |
Write
Preview
Loading…
Cancel
Save
Reference in new issue