Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][ADD] sms_alternative_provider, sms_messagebird #327

Open
wants to merge 9 commits into
base: 16.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 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
6 changes: 6 additions & 0 deletions setup/sms_alternative_provider/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,
)
1 change: 1 addition & 0 deletions setup/sms_messagebird/odoo/addons/sms_messagebird
6 changes: 6 additions & 0 deletions setup/sms_messagebird/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,
)
152 changes: 152 additions & 0 deletions sms_alternative_provider/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
=============================
Alternative providers for SMS
=============================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:211fd292e6cdc76561c38b96220576ac59ab58d5011a1ddfa7d5b7ef3bb13588
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fconnector--telephony-lightgray.png?logo=github
:target: https://github.com/OCA/connector-telephony/tree/16.0/sms_alternative_provider
:alt: OCA/connector-telephony
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/connector-telephony-16-0/connector-telephony-16-0-sms_alternative_provider
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/connector-telephony&target_branch=16.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module allows configuring multiple providers for sending SMS.

By restricting providers to country or area codes, you can ie have Odoo
pick different providers for different countries.

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

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

To configure this module, you need to:

1. Go to Settings / Technical / Phone/SMS / SMS providers
2. Create/Edit providers, reorder them, restrict some provider to
certain country or area codes

Usage
=====

This module doesn't do anything on its own, it is meant to be used by
developers to implement SMS providers.

To do this, it suffices to inherit the ``ir.sms.gateway`` model to add a
type:

::

gateway_type = fields.Selection(selection_add=[("your_sms_provider", "Your SMS provider")])

and declare a function named like \_send\_$type:

::

def _send_your_sms_provider(self, messages):
# do here whatever you need to send the list of messages:
# [{
# 'id': id of the sms.sms record (may not be set),
# 'number': the number to send the sms to
# 'content': the content of the message
# }]
# return a list of dicts with sending results:
# [{
# 'id': id of the sms.sms record
# 'state': sms.sms#state
# 'failure_type': sms.sms#failure_type if state == 'error'
# # whatever other fields you want to write on the sms.sms record after sending,
# # such as provider-specific extra information
# }]

Probably your provider needs some api key or similar to function, add
those fields prefixed with your gateway_type name to the gateway class:

::

your_sms_provider_apikey = fields.Char('API key')

and add a group after group ``general`` in the form view of the model:

::

<group name="general" position="after">
<group name="your_sms_provider" attrs="{'invisible': [('gateway_type', '!=', 'your_sms_provider')]}">
<field name="your_sms_provider_apikey" password="True" attrs="{'required': [('gateway_type', '=', 'your_sms_provider')]}" />
</group>
</group>

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

Bugs are tracked on `GitHub Issues <https://github.com/OCA/connector-telephony/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/connector-telephony/issues/new?body=module:%20sms_alternative_provider%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* Hunki Enterprises BV

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

- Holger Brunn <[email protected]>
(https://hunki-enterprises.com)

Maintainers
-----------

This module is maintained by the OCA.

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

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.

.. |maintainer-hbrunn| image:: https://github.com/hbrunn.png?size=40px
:target: https://github.com/hbrunn
:alt: hbrunn

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-hbrunn|

This module is part of the `OCA/connector-telephony <https://github.com/OCA/connector-telephony/tree/16.0/sms_alternative_provider>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions sms_alternative_provider/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
29 changes: 29 additions & 0 deletions sms_alternative_provider/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2024 Hunki Enterprises BV
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0)

{
"name": "Alternative providers for SMS",
"summary": "Base module for implementing alternative SMS gateways",
"version": "16.0.1.0.0",
"development_status": "Alpha",
"category": "Tools",
"website": "https://github.com/OCA/connector-telephony",
"author": "Hunki Enterprises BV, Odoo Community Association (OCA)",
"maintainers": ["hbrunn"],
"license": "AGPL-3",
"depends": [
"sms",
],
"external_dependencies": {
"python": [
"phonenumbers",
],
},
"data": [
"data/ir_sms_gateway.xml",
"security/ir.model.access.csv",
"views/ir_sms_gateway.xml",
"views/sms_sms.xml",
],
"demo": [],
}
9 changes: 9 additions & 0 deletions sms_alternative_provider/data/ir_sms_gateway.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2024 Hunki Enterprises BV
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl-3.0) -->
<data noupdate="1">
<record id="gateway_iap" model="ir.sms.gateway">
<field name="name">Odoo builtin</field>
<field name="gateway_type">iap</field>
</record>
</data>
3 changes: 3 additions & 0 deletions sms_alternative_provider/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import ir_sms_gateway
from . import sms_api
from . import sms_sms
Loading