Browse Source

[add][clicksend_sms_client]

pull/182/head
Jordi Ballester Alomar 6 years ago
parent
commit
894da1791c
  1. 5
      base_sms_client/__init__.py
  2. 4
      base_sms_client/__manifest__.py
  3. 2
      base_sms_client/data/sms_gateway_data.xml
  4. 5
      base_sms_client/models/__init__.py
  5. 4
      base_sms_client/models/server_action.py
  6. 1
      clicksend_sms_client/__init__.py
  7. 19
      clicksend_sms_client/__manifest__.py
  8. 9
      clicksend_sms_client/data/keychain.xml
  9. 35
      clicksend_sms_client/i18n/ar.po
  10. 34
      clicksend_sms_client/i18n/ca.po
  11. 35
      clicksend_sms_client/i18n/es.po
  12. 34
      clicksend_sms_client/i18n/fr.po
  13. 30
      clicksend_sms_client/i18n/ovh_sms_client.pot
  14. 2
      clicksend_sms_client/models/__init__.py
  15. 21
      clicksend_sms_client/models/keychain.py
  16. 78
      clicksend_sms_client/models/sms_gateway.py
  17. 4
      clicksend_sms_client/readme/CONFIGURE.rst
  18. 4
      clicksend_sms_client/readme/CONTRIBUTORS.rst
  19. 1
      clicksend_sms_client/readme/DESCRIPTION.rst

5
base_sms_client/__init__.py

@ -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 wizard
from . import models from . import models

4
base_sms_client/__manifest__.py

@ -7,7 +7,7 @@
{ {
"name": "Base Sms Client", "name": "Base Sms Client",
"version": "10.0.1.0.0",
"version": "11.0.1.0.0",
'license': 'AGPL-3', 'license': 'AGPL-3',
"depends": ['mail', "depends": ['mail',
'base_phone', 'base_phone',
@ -35,5 +35,5 @@
"wizard/mass_sms_view.xml", "wizard/mass_sms_view.xml",
"views/smstemplate_view.xml" "views/smstemplate_view.xml"
], ],
"installable": False,
"installable": True,
} }

2
base_sms_client/data/sms_gateway_data.xml

@ -6,7 +6,7 @@
<field name="interval_type">minutes</field> <field name="interval_type">minutes</field>
<field name="numbercall">-1</field> <field name="numbercall">-1</field>
<field name="doall">False</field> <field name="doall">False</field>
<field name="model">sms.gateway</field>
<field name="model_id" ref="model_sms_gateway"/>
<field name="function">_run_send_sms</field> <field name="function">_run_send_sms</field>
<field name="args">()</field> <field name="args">()</field>
<field name="active">False</field> <field name="active">False</field>

5
base_sms_client/models/__init__.py

@ -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 sms_gateway
from . import server_action from . import server_action
from . import sms_template from . import sms_template

4
base_sms_client/models/server_action.py

@ -13,6 +13,10 @@ class ServerAction(models.Model):
""" """
_inherit = 'ir.actions.server' _inherit = 'ir.actions.server'
state = fields.Selection(selection_add=[
('sms', 'Send SMS'),
])
mobile = fields.Char( mobile = fields.Char(
string='Mobile No', string='Mobile No',
help="Field to be used to fetch the mobile number, e.g. you select" help="Field to be used to fetch the mobile number, e.g. you select"

1
clicksend_sms_client/__init__.py

@ -0,0 +1 @@
from . import models

19
clicksend_sms_client/__manifest__.py

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

9
clicksend_sms_client/data/keychain.xml

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

35
clicksend_sms_client/i18n/ar.po

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

34
clicksend_sms_client/i18n/ca.po

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

35
clicksend_sms_client/i18n/es.po

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

34
clicksend_sms_client/i18n/fr.po

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

30
clicksend_sms_client/i18n/ovh_sms_client.pot

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

2
clicksend_sms_client/models/__init__.py

@ -0,0 +1,2 @@
from . import sms_gateway
from . import keychain

21
clicksend_sms_client/models/keychain.py

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

78
clicksend_sms_client/models/sms_gateway.py

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

4
clicksend_sms_client/readme/CONFIGURE.rst

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

4
clicksend_sms_client/readme/CONTRIBUTORS.rst

@ -0,0 +1,4 @@
* Valentin Chemiere
* Yvan Party <yvan@julius.fr>
* MonsieurB <monsieurb@saaslys.com>
* Jordi Ballester Alomar <jordi.ballester@eficent.com>

1
clicksend_sms_client/readme/DESCRIPTION.rst

@ -0,0 +1 @@
This module provides ClickSend fields to create a ClickSend gateway.
Loading…
Cancel
Save