-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
707 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
============= | ||
Deltatech SMS | ||
============= | ||
|
||
.. | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! This file is generated by oca-gen-addon-readme !! | ||
!! changes will be overwritten. !! | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
!! source digest: sha256:c837a21b15df215590c7eca967bc62f29cdc52b42c35001343e7c5799822dfc4 | ||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
.. |badge1| image:: https://img.shields.io/badge/maturity-Mature-brightgreen.png | ||
:target: https://odoo-community.org/page/development-status | ||
:alt: Mature | ||
.. |badge2| image:: https://img.shields.io/badge/licence-OPL--1-blue.png | ||
:target: https://www.odoo.com/documentation/master/legal/licenses.html | ||
:alt: License: OPL-1 | ||
.. |badge3| image:: https://img.shields.io/badge/github-dhongu%2Fdeltatech-lightgray.png?logo=github | ||
:target: https://github.com/dhongu/deltatech/tree/17.0/deltatech_sms | ||
:alt: dhongu/deltatech | ||
|
||
|badge1| |badge2| |badge3| | ||
|
||
Features: | ||
- in endpointse folosesc parametrii: | ||
{number}: string: E164 formatted phone number, | ||
{content}: string: content to send | ||
|
||
|
||
|
||
https://sms.4pay.ro/smscust/api.send_sms?servID={ID}&msg_dst={number}&msg_text={content}&API&password={password}@&external_messageID=1 | ||
|
||
**Table of contents** | ||
|
||
.. contents:: | ||
:local: | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `Terrabit Issues <https://www.terrabit.ro/helpdesk>`_. | ||
In case of trouble, please check there if your issue has already been reported. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Authors | ||
~~~~~~~ | ||
|
||
* Terrabit | ||
* Dorin Hongu | ||
* Dan Stoica | ||
|
||
Contributors | ||
~~~~~~~~~~~~ | ||
|
||
* `Terrabit <https://www.terrabit.ro>`_: | ||
|
||
* Dorin Hongu | ||
* Dan Stoica | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Maintainers | ||
~~~~~~~~~~~ | ||
|
||
.. |maintainer-dhongu| image:: https://github.com/dhongu.png?size=40px | ||
:target: https://github.com/dhongu | ||
:alt: dhongu | ||
|
||
Current maintainer: | ||
|
||
|maintainer-dhongu| | ||
|
||
This module is part of the `dhongu/deltatech <https://github.com/dhongu/deltatech/tree/17.0/deltatech_sms>`_ project on GitHub. | ||
|
||
You are welcome to contribute. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# © 2008-2021 Deltatech | ||
# Dorin Hongu <dhongu(@)gmail(.)com | ||
# See README.rst file on addons root folder for license details | ||
|
||
|
||
from . import models | ||
from . import wizard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# © 2008-2021 Deltatech | ||
# Dorin Hongu <dhongu(@)gmail(.)com | ||
# See README.rst file on addons root folder for license details | ||
|
||
{ | ||
"name": "Deltatech SMS", | ||
"summary": "Send SMS to custom endpoint", | ||
"version": "17.0.1.0.0", | ||
"author": "Terrabit, Dorin Hongu, Dan Stoica", | ||
"website": "https://www.terrabit.ro", | ||
"category": "Extra Tools", | ||
"depends": ["sms"], | ||
"license": "OPL-1", | ||
"data": ["views/iap_views.xml"], | ||
"images": ["static/description/main_screenshot.png"], | ||
"installable": True, | ||
"development_status": "Mature", | ||
"maintainers": ["dhongu"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
UPDATE iap_account | ||
SET endpoint = false | ||
where service_name = 'sms'; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# © 2008-2021 Deltatech | ||
# Dorin Hongu <dhongu(@)gmail(.)com | ||
# See README.rst file on addons root folder for license details | ||
|
||
|
||
from . import iap | ||
from . import sms_sms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# © 2008-2021 Deltatech | ||
# Dorin Hongu <dhongu(@)gmail(.)com | ||
# See README.rst file on addons root folder for license details | ||
|
||
from odoo import fields, models | ||
|
||
|
||
class IapAccount(models.Model): | ||
_inherit = "iap.account" | ||
|
||
endpoint = fields.Char() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# © 2008-2021 Deltatech | ||
# Dorin Hongu <dhongu(@)gmail(.)com | ||
# Dan Stoica | ||
# See README.rst file on addons root folder for license details | ||
|
||
import logging | ||
|
||
import requests | ||
|
||
from odoo import api | ||
|
||
from odoo.addons.sms.tools.sms_api import SmsApi as BaseSmsApi | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class SmsApi(BaseSmsApi): | ||
|
||
|
||
def _contact_iap(self, local_endpoint, params, timeout=15): | ||
account = self.env["iap.account"].get("sms") | ||
|
||
res = [] | ||
|
||
for message in params["messages"]: | ||
res_value = {"state": "success"} | ||
|
||
endpoint = account.endpoint | ||
if not endpoint: | ||
res_value["state"] = "Endpoint is not defined." | ||
|
||
for number in message["numbers"]: | ||
res_value["uuid"] = number["uuid"] | ||
endpoint_number = endpoint.format(number=number["number"], content=message["content"]) | ||
self.env.cr.execute("select unaccent(%s);", [endpoint_number]) | ||
endpoint_unaccent = self.env.cr.fetchone()[0] | ||
result = requests.get(endpoint_unaccent) | ||
response = result.content.decode("utf-8") | ||
|
||
if "OK" not in response: | ||
_logger.error("SMS: %s" % response) | ||
res_value["state"] = "server_error" | ||
res += [res_value] | ||
|
||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# © 2024 Deltatech | ||
# Dorin Hongu <dhongu(@)gmail(.)com | ||
# Dan Stoica | ||
# See README.rst file on addons root folder for license details | ||
|
||
import logging | ||
|
||
from werkzeug.urls import url_join | ||
|
||
from odoo import models, tools | ||
|
||
from .sms_api import SmsApi | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
|
||
class SmsSms(models.AbstractModel): | ||
_inherit = "sms.sms" | ||
|
||
def _send(self, unlink_failed=False, unlink_sent=True, raise_exception=False): | ||
"""Send SMS after checking the number (presence and formatting).""" | ||
messages = [ | ||
{ | ||
"content": body, | ||
"numbers": [{"number": sms.number, "uuid": sms.uuid} for sms in body_sms_records], | ||
} | ||
for body, body_sms_records in self.grouped("body").items() | ||
] | ||
|
||
delivery_reports_url = url_join(self[0].get_base_url(), "/sms/status") | ||
try: | ||
results = SmsApi(self.env)._send_sms_batch(messages, delivery_reports_url=delivery_reports_url) | ||
except Exception as e: | ||
_logger.info("Sent batch %s SMS: %s: failed with exception %s", len(self.ids), self.ids, e) | ||
if raise_exception: | ||
raise | ||
results = [{"uuid": sms.uuid, "state": "server_error"} for sms in self] | ||
else: | ||
_logger.info("Send batch %s SMS: %s: gave %s", len(self.ids), self.ids, results) | ||
|
||
results_uuids = [result["uuid"] for result in results] | ||
all_sms_sudo = ( | ||
self.env["sms.sms"] | ||
.sudo() | ||
.search([("uuid", "in", results_uuids)]) | ||
.with_context(sms_skip_msg_notification=True) | ||
) | ||
|
||
for iap_state, results_group in tools.groupby(results, key=lambda result: result["state"]): | ||
sms_sudo = all_sms_sudo.filtered(lambda s: s.uuid in {result["uuid"] for result in results_group}) | ||
if success_state := self.IAP_TO_SMS_STATE_SUCCESS.get(iap_state): | ||
sms_sudo.sms_tracker_id._action_update_from_sms_state(success_state) | ||
to_delete = {"to_delete": True} if unlink_sent else {} | ||
sms_sudo.write({"state": success_state, "failure_type": False, **to_delete}) | ||
else: | ||
failure_type = self.IAP_TO_SMS_FAILURE_TYPE.get(iap_state, "unknown") | ||
if failure_type != "unknown": | ||
sms_sudo.sms_tracker_id._action_update_from_sms_state("error", failure_type=failure_type) | ||
else: | ||
sms_sudo.sms_tracker_id._action_update_from_provider_error(iap_state) | ||
to_delete = {"to_delete": True} if unlink_failed else {} | ||
sms_sudo.write({"state": "error", "failure_type": failure_type, **to_delete}) | ||
|
||
all_sms_sudo.mail_message_id._notify_message_notification_update() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
* `Terrabit <https://www.terrabit.ro>`_: | ||
|
||
* Dorin Hongu | ||
* Dan Stoica | ||
|
||
Do not contact contributors directly about support or help with technical issues. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Features: | ||
- in endpointse folosesc parametrii: | ||
{number}: string: E164 formatted phone number, | ||
{content}: string: content to send | ||
|
||
|
||
|
||
https://sms.4pay.ro/smscust/api.send_sms?servID={ID}&msg_dst={number}&msg_text={content}&API&password={password}@&external_messageID=1 |
Binary file added
BIN
+548 KB
deltatech_sms/static/Specificatii_sistem_management_SMSuri_4PAY.v1 (1).pdf
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.