Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
exclude: |
(?x)
#(?x)
# Files and folders generated by bots, to avoid loops
^setup/|/static/description/index\.html$|
# Maybe reactivate this when all README files include prettier ignore tags?
Expand Down
1 change: 1 addition & 0 deletions setup/sms_clickatell/odoo/addons/sms_clickatell
6 changes: 6 additions & 0 deletions setup/sms_clickatell/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import setuptools

setuptools.setup(
setup_requires=['setuptools-odoo'],
odoo_addon=True,
)
93 changes: 93 additions & 0 deletions sms_clickatell/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

========================================================================
SMS Clickatell - Override Odoo Standard SMS gateway
========================================================================

Send SMS with Clickatell instead of Odoo SA IAP.

Installation
============

To install this module, you need to:

#. Just do an standard installation.

Configuration
=============

To configure this module, you need to:

#. Go to Configuration, Technical, IAP Accounts and add your Clickatell
API key under an account named "sms.clickatell.


.. figure:: path/to/local/image.png
:alt: alternative description
:width: 600 px

Usage
=====

To use this module, you need to:

#. Go to ...

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/{repo_id}/{branch}

.. repo_id is available in https://github.com/OCA/maintainer-tools/blob/master/tools/repos_with_ids.txt
.. branch is "8.0" for example

Known issues / Roadmap
======================

* Extend to whatsapp msgs?

Bug Tracker
===========

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/{project_repo}/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smash it by providing detailed and welcomed feedback.

Credits
=======

Images
------

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Firstname Lastname <email.address@example.org>
* Second Person <second.person@example.org>

Funders
-------

The development of this module has been financially supported by:

* Company 1 name
* Company 2 name

Maintainer
----------

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

This module is maintained by the OCA.

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

To contribute to this module, please visit https://odoo-community.org.
1 change: 1 addition & 0 deletions sms_clickatell/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
14 changes: 14 additions & 0 deletions sms_clickatell/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "SMS Clickatell",
"summary": """
Send SMS with Clickatell instead of Odoo SA IAP.""",
"version": "13.0.1.0.0",
"license": "AGPL-3",
"author": "RPSJR, Odoo Community Association (OCA)",
"website": "https://github.com/oca/connector-telephony",
"depends": ["sms", "iap"], # Odoo SA.
"data": ["views/iap_account.xml"],
"demo": [],
}
1 change: 1 addition & 0 deletions sms_clickatell/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import iap_account, sms_api
10 changes: 10 additions & 0 deletions sms_clickatell/models/iap_account.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class IapAccount(models.Model):

_inherit = "iap.account"

key = fields.Char()
60 changes: 60 additions & 0 deletions sms_clickatell/models/sms_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import json

import requests

from odoo import api, models


class SmsApi(models.AbstractModel):

_inherit = "sms.api"

@api.model
def _contact_iap(self, local_endpoint, params):
account = self.env["iap.account"].get("sms.clickatell")
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": account.key,
}

if local_endpoint == "/iap/message_send":
messages = [
{"channel": "sms", "to": number, "content": params["message"]}
for number in params["numbers"]
]

elif local_endpoint == "/iap/sms/1/send":
messages = [
{
"channel": "sms",
"to": message["number"],
"content": message["content"],
}
for message in params["messages"]
]

values = json.dumps({"messages": messages})
request = requests.post(
"https://platform.clickatell.com/v1/message", data=values, headers=headers
)
response_list = request.json()["messages"]
params_list = params["messages"]
if type(request.json()) is dict:
response = []
for resp_id in range(len(response_list)):
response.append(
{
**params_list[resp_id],
"state": (
"success"
if "error" not in response_list[resp_id]
else "wrong_number_format"
),
"credit": 2,
**response_list[resp_id],
}
)
return response
Binary file added sms_clickatell/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions sms_clickatell/views/iap_account.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -->
<odoo>
<record model="ir.ui.view" id="iap_account_form_view">
<field name="name">iap.account.form (in sms_clickatell)</field>
<field name="model">iap.account</field>
<field name="inherit_id" ref="iap.iap_account_view_form" />
<field name="arch" type="xml">
<field name="account_token" position="after">
<field name="key" />
</field>
</field>
</record>
</odoo>