@ -0,0 +1,54 @@ |
|||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.svg |
|||
:target: https://www.gnu.org/licenses/agpl-3.0-standalone.html |
|||
:alt: License: AGPL-3 |
|||
|
|||
Multiple SMS Gateway Integration |
|||
================================ |
|||
* Module for sending SMS through different SMS gateways such as Twilio, Telesign, Vonage. |
|||
|
|||
Installation |
|||
============ |
|||
- www.odoo.com/documentation/17.0/setup/install.html |
|||
- Install all external dependencies |
|||
- Install our custom addon |
|||
|
|||
Configuration |
|||
============= |
|||
- Add the users to the new security group 'Multiple SMS Gateway Integration / Manager' to give access to |
|||
the new menus of Multiple SMS Gateway Integration module. |
|||
- Setup the gateways that you would like to use by adding the required credentials. |
|||
|
|||
License |
|||
------- |
|||
GNU Affero General Public License v3.0 (AGPL v3) |
|||
(https://www.gnu.org/licenses/agpl-3.0-standalone.html) |
|||
|
|||
Company |
|||
------- |
|||
* `Cybrosys Techno Solutions <https://cybrosys.com/>`__ |
|||
|
|||
Credits |
|||
------- |
|||
* Developer: (V16) Sumith S, |
|||
(V17) Anjana PV, Contact: odoo@cybrosys.com |
|||
|
|||
Contacts |
|||
-------- |
|||
* Mail Contact : odoo@cybrosys.com |
|||
|
|||
Bug Tracker |
|||
----------- |
|||
Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. |
|||
|
|||
Maintainer |
|||
========== |
|||
.. image:: https://cybrosys.com/images/logo.png |
|||
:target: https://cybrosys.com |
|||
|
|||
This module is maintained by Cybrosys Technologies. |
|||
|
|||
For support and more information, please visit https://www.cybrosys.com |
|||
|
|||
Further information |
|||
=================== |
|||
HTML Description: `<static/description/index.html>`__ |
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from . import models |
|||
from . import wizard |
@ -0,0 +1,52 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
{ |
|||
'name': 'Multiple SMS Gateway Integration', |
|||
'version': '17.0.1.0.0', |
|||
'category': 'Extra Tools', |
|||
'summary': 'Module to send SMS through different SMS gateway', |
|||
'description': """This modules helps to send SMS using different SMS |
|||
gateways including Twilio, Vonage, TeleSign""", |
|||
'author': 'Cybrosys Techno Solutions', |
|||
'company': 'Cybrosys Techno Solutions', |
|||
'maintainer': 'Cybrosys Techno Solutions', |
|||
'website': 'https://www.cybrosys.com', |
|||
'depends': ['base', 'contacts'], |
|||
'data': [ |
|||
'security/multi_sms_gateway_groups.xml', |
|||
'security/sms_history_security.xml', |
|||
'security/ir.model.access.csv', |
|||
'data/sms_gateway_data.xml', |
|||
'views/sms_history_views.xml', |
|||
'views/sms_gateway_config_views.xml', |
|||
'views/res_partner_views.xml', |
|||
'wizard/send_sms_views.xml', |
|||
'views/multi_sms_gateway_menus.xml' |
|||
], |
|||
'external_dependencies': { |
|||
'python': ['telesign', 'twilio', 'vonage'] |
|||
}, |
|||
'images': ['static/description/banner.jpg'], |
|||
'license': 'AGPL-3', |
|||
'installable': True, |
|||
'auto_install': False, |
|||
'application': False |
|||
} |
@ -0,0 +1,13 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<!-- Records for SMS Gateway --> |
|||
<record id="sms_gateway_twilio" model="sms.gateway"> |
|||
<field name="name">twilio</field> |
|||
</record> |
|||
<record id="sms_gateway_vonage" model="sms.gateway"> |
|||
<field name="name">vonage</field> |
|||
</record> |
|||
<record id="sms_gateway_telesign" model="sms.gateway"> |
|||
<field name="name">telesign</field> |
|||
</record> |
|||
</odoo> |
@ -0,0 +1,7 @@ |
|||
## Module <multi_sms_gateway> |
|||
|
|||
#### 29.07.2024 |
|||
#### Version 17.0.1.0.0 |
|||
#### ADD |
|||
|
|||
- Initial commit for Multiple SMS Gateway Integration |
@ -0,0 +1,24 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from . import res_partner |
|||
from . import sms_gateway |
|||
from . import sms_gateway_config |
|||
from . import sms_history |
@ -0,0 +1,50 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from odoo import models, _ |
|||
|
|||
|
|||
class ResPartner(models.Model): |
|||
""" |
|||
Inheriting model 'res.partner' to add the function to send SMS. |
|||
Methods: |
|||
send_sms(): |
|||
Opens the Send SMS wizard. |
|||
""" |
|||
_inherit = 'res.partner' |
|||
|
|||
def send_sms(self): |
|||
""" |
|||
Function to open Send SMS wizard. |
|||
Returns: |
|||
dict: the action window of 'send.sms'. |
|||
""" |
|||
record_ids = self.env.context.get('active_ids') |
|||
numbers = self.env['res.partner'].browse(record_ids).mapped('mobile') |
|||
return { |
|||
'name': _('Send SMS'), |
|||
'type': 'ir.actions.act_window', |
|||
'res_model': 'send.sms', |
|||
'context': { |
|||
'default_sms_to': ','.join([str(numb) for numb in numbers]), |
|||
}, |
|||
'view_mode': 'form', |
|||
'target': 'new' |
|||
} |
@ -0,0 +1,32 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from odoo import fields, models |
|||
|
|||
|
|||
class SmsGateway(models.Model): |
|||
""" |
|||
Class to add the gateway providers. |
|||
""" |
|||
_name = 'sms.gateway' |
|||
_description = 'SMS Gateway' |
|||
|
|||
name = fields.Char(string='Provider Name', |
|||
help='Provide the name of the provider.') |
@ -0,0 +1,65 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from odoo import api, fields, models, _ |
|||
from odoo.exceptions import UserError |
|||
|
|||
|
|||
class SmsGatewayConfig(models.Model): |
|||
""" |
|||
Class to save the user credential details for the SMS gateways. |
|||
""" |
|||
_name = 'sms.gateway.config' |
|||
_description = 'SMS Gateway Configuration' |
|||
_rec_name = 'gateway_name' |
|||
|
|||
sms_gateway_id = fields.Many2one( |
|||
'sms.gateway', string='Gateway', help='The SMS Gateway.') |
|||
gateway_name = fields.Char( |
|||
related='sms_gateway_id.name', help='Gateway Name') |
|||
vonage_key = fields.Char(string='Key', help='The key for Vonage') |
|||
vonage_secret = fields.Char(string='Secret', help='The secret for Vonage.') |
|||
twilio_account_sid = fields.Char( |
|||
string='Account SID', help='Account SID for Twilio.') |
|||
twilio_auth_token = fields.Char( |
|||
string='Auth Token', help='Auth token for Twilio.') |
|||
twilio_phone_number = fields.Char( |
|||
string='Twilio Number', help='Twilio phone number.') |
|||
telesign_customer = fields.Char( |
|||
string='TeleSign Customer ID', help='Customer ID for TeleSign.') |
|||
telesign_api_key = fields.Char( |
|||
string='TeleSign API Key', help='API key for TeleSign') |
|||
|
|||
@api.constrains('sms_gateway_id') |
|||
def _check_credentials(self): |
|||
""" Check whether all the credential field have values""" |
|||
if self.sms_gateway_id.name == 'telesign': |
|||
if not self.telesign_customer or not self.telesign_api_key: |
|||
raise UserError( |
|||
_('Provide correct credentials for Telesign')) |
|||
if self.sms_gateway_id.name == 'vonage': |
|||
if not self.vonage_key or not self.vonage_secret: |
|||
raise UserError( |
|||
_('Provide correct credentials for Vonage')) |
|||
if self.sms_gateway_id.name == 'twilio': |
|||
if (not self.twilio_phone_number or not self.twilio_auth_token |
|||
or not self.twilio_account_sid): |
|||
raise UserError( |
|||
_('Provide correct credentials for Twilio')) |
@ -0,0 +1,43 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from odoo import fields, models |
|||
|
|||
|
|||
class SmsHistory(models.Model): |
|||
""" |
|||
This model stores the details of all the SMS messages that have been |
|||
sent, including the gateway name, date of sending, mobile phone number, |
|||
and SMS text. |
|||
""" |
|||
_name = 'sms.history' |
|||
_description = 'SMS History' |
|||
_rec_name = 'sms_mobile' |
|||
|
|||
sms_gateway_id = fields.Many2one('sms.gateway', string='Gateway', |
|||
help='The SMS Gateway.') |
|||
sms_date = fields.Datetime(string='Date', default=fields.Date().today(), |
|||
help='Date of sending message(current day).') |
|||
sms_mobile = fields.Char( |
|||
string='Mobile Number', help='Phone Number to send SMS.') |
|||
sms_text = fields.Text(string='SMS Text', help='The message to be sent.') |
|||
company_id = fields.Many2one( |
|||
'res.company', string='Company', required=True, |
|||
default=lambda self: self.env.company, help='Active company.') |
|
@ -0,0 +1,14 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<!-- Security groups --> |
|||
<record id="module_category_send_sms" model="ir.module.category" > |
|||
<field name="name">Multiple SMS Gateway Integration</field> |
|||
<field name="description">Manage user access for Multiple SMS Gateway Integration module</field> |
|||
<field name="sequence">20</field> |
|||
</record> |
|||
<record id="multi_sms_gateway_group_manager" model="res.groups"> |
|||
<field name="name">Manager</field> |
|||
<field name="category_id" ref="module_category_send_sms"/> |
|||
<field name="comment">Access to the new menus and records of Multiple SMS Gateway Integration</field> |
|||
</record> |
|||
</odoo> |
@ -0,0 +1,9 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<!-- Multi-Company rule for SMS History --> |
|||
<record id="sms_history_rule_company" model="ir.rule" > |
|||
<field name="name">SMS History: Multi-company</field> |
|||
<field name="model_id" ref="model_sms_history"/> |
|||
<field name="domain_force">['|', ('company_id', '=', False), ('company_id', 'in', company_ids)]</field> |
|||
</record> |
|||
</odoo> |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 310 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 576 B |
After Width: | Height: | Size: 733 B |
After Width: | Height: | Size: 911 B |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 673 B |
After Width: | Height: | Size: 878 B |
After Width: | Height: | Size: 653 B |
After Width: | Height: | Size: 905 B |
After Width: | Height: | Size: 839 B |
After Width: | Height: | Size: 427 B |
After Width: | Height: | Size: 627 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 988 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 4.4 KiB |
After Width: | Height: | Size: 589 B |
After Width: | Height: | Size: 3.4 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 967 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 3.8 KiB |
After Width: | Height: | Size: 5.0 KiB |
After Width: | Height: | Size: 85 KiB |
After Width: | Height: | Size: 76 KiB |
After Width: | Height: | Size: 76 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 79 KiB |
After Width: | Height: | Size: 89 KiB |
After Width: | Height: | Size: 185 KiB |
After Width: | Height: | Size: 101 KiB |
After Width: | Height: | Size: 146 KiB |
After Width: | Height: | Size: 92 KiB |
After Width: | Height: | Size: 153 KiB |
After Width: | Height: | Size: 74 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 221 KiB |
After Width: | Height: | Size: 55 KiB |
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 162 KiB |
After Width: | Height: | Size: 95 KiB |
After Width: | Height: | Size: 64 KiB |
After Width: | Height: | Size: 167 KiB |
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 12 KiB |
@ -0,0 +1,16 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<!-- Root Menu --> |
|||
<menuitem name="SMS Gateway" id="send_sms_menu_root" parent="base.menu_administration" |
|||
groups="multi_sms_gateway.multi_sms_gateway_group_manager" /> |
|||
<!-- Menu to access SMS Gateways --> |
|||
<menuitem name="Gateway List" id="sms_gateway_config_menu_action" |
|||
parent="multi_sms_gateway.send_sms_menu_root" |
|||
action="multi_sms_gateway.sms_gateway_config_action" |
|||
groups="multi_sms_gateway.multi_sms_gateway_group_manager" /> |
|||
<!-- Menu to access SMS History --> |
|||
<menuitem name="SMS History" id="sms_history_menu_action" |
|||
parent="multi_sms_gateway.send_sms_menu_root" |
|||
action="multi_sms_gateway.sms_history_action" |
|||
groups="multi_sms_gateway.multi_sms_gateway_group_manager" /> |
|||
</odoo> |
@ -0,0 +1,13 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<!-- Server action in 'res.partner' to open the wizard to send the SMS. --> |
|||
<!-- Available in Form and Tree Views --> |
|||
<record id="action_send_sms" model="ir.actions.server"> |
|||
<field name="name">Send SMS</field> |
|||
<field name="model_id" ref="base.model_res_partner"/> |
|||
<field name="binding_model_id" ref="base.model_res_partner"/> |
|||
<field name="binding_view_types">form,list</field> |
|||
<field name="state">code</field> |
|||
<field name="code">action = records.send_sms()</field> |
|||
</record> |
|||
</odoo> |
@ -0,0 +1,74 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<!-- Form view for SMS Gateway Configuration --> |
|||
<record id="sms_gateway_config_view_form" model="ir.ui.view"> |
|||
<field name="name">sms.gateway.config.view.form</field> |
|||
<field name="model">sms.gateway.config</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="SMS Gateway Configuration"> |
|||
<sheet> |
|||
<group string="Gateway"> |
|||
<field name="sms_gateway_id" options="{'no_create_edit':True}"/> |
|||
<field name="gateway_name" invisible="1"/> |
|||
</group> |
|||
<notebook> |
|||
<page string="General"> |
|||
<group> |
|||
<!-- Credentials for Vonage --> |
|||
<group string="Vonage Credentials" |
|||
invisible="gateway_name != 'vonage'"> |
|||
<field name="vonage_key" |
|||
invisible="gateway_name != 'vonage'"/> |
|||
<field name="vonage_secret" |
|||
string="Secret Key" |
|||
invisible="gateway_name != 'vonage'"/> |
|||
</group> |
|||
<!-- Credentials for Twilio --> |
|||
<group string="Twilio Credentials" |
|||
invisible="gateway_name != 'twilio'"> |
|||
<field name="twilio_account_sid" |
|||
invisible="gateway_name != 'twilio'"/> |
|||
<field name="twilio_auth_token" |
|||
invisible="gateway_name != 'twilio'"/> |
|||
<field name="twilio_phone_number" |
|||
invisible="gateway_name != 'twilio'"/> |
|||
</group> |
|||
<!-- Credentials for Telesign --> |
|||
<group string="Telesign Credentials" |
|||
invisible="gateway_name != 'telesign'"> |
|||
<field name="telesign_customer" |
|||
invisible="gateway_name != 'telesign'"/> |
|||
<field name="telesign_api_key" |
|||
invisible="gateway_name != 'telesign'"/> |
|||
</group> |
|||
</group> |
|||
</page> |
|||
</notebook> |
|||
</sheet> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
<!-- Tree view for SMS Gateway Configuration --> |
|||
<record id="sms_gateway_config_view_tree" model="ir.ui.view"> |
|||
<field name="name">sms.gateway.config.view.tree</field> |
|||
<field name="model">sms.gateway.config</field> |
|||
<field name="arch" type="xml"> |
|||
<tree> |
|||
<field name="gateway_name"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
<!-- Window action for SMS Gateway Configuration --> |
|||
<record id="sms_gateway_config_action" model="ir.actions.act_window"> |
|||
<field name="name">SMS Gateway Configuration</field> |
|||
<field name="res_model">sms.gateway.config</field> |
|||
<field name="help" type="html"> |
|||
<p class="o_view_nocontent_smiling_face"> |
|||
Gateway List Is Empty |
|||
</p> |
|||
<p> |
|||
Create a New Gateway List |
|||
</p> |
|||
</field> |
|||
</record> |
|||
</odoo> |
@ -0,0 +1,47 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<!-- Form view for SMS History --> |
|||
<record id="sms_history_view_form" model="ir.ui.view"> |
|||
<field name="name">sms.history.view.form</field> |
|||
<field name="model">sms.history</field> |
|||
<field name="arch" type="xml"> |
|||
<form string="SMS History"> |
|||
<sheet> |
|||
<group> |
|||
<group> |
|||
<field name="sms_gateway_id"/> |
|||
<field name="sms_date"/> |
|||
</group> |
|||
<group> |
|||
<field name="sms_mobile"/> |
|||
</group> |
|||
<field name="sms_text"/> |
|||
</group> |
|||
</sheet> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
<!-- Tree view for SMS History --> |
|||
<record id="sms_history_view_tree" model="ir.ui.view"> |
|||
<field name="name">sms.history.view.tree</field> |
|||
<field name="model">sms.history</field> |
|||
<field name="arch" type="xml"> |
|||
<tree create="0"> |
|||
<field name="sms_gateway_id"/> |
|||
<field name="sms_date"/> |
|||
<field name="sms_text"/> |
|||
<field name="sms_mobile"/> |
|||
</tree> |
|||
</field> |
|||
</record> |
|||
<!-- Window action for SMS History --> |
|||
<record id="sms_history_action" model="ir.actions.act_window"> |
|||
<field name="name">SMS History</field> |
|||
<field name="res_model">sms.history</field> |
|||
<field name="help" type="html"> |
|||
<p class="o_view_nocontent_smiling_face"> |
|||
SMS history is not created yet! Please send an SMS to create new history. |
|||
</p> |
|||
</field> |
|||
</record> |
|||
</odoo> |
@ -0,0 +1,21 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
from . import send_sms |
@ -0,0 +1,87 @@ |
|||
# -*- coding: utf-8 -*- |
|||
############################################################################# |
|||
# |
|||
# Cybrosys Technologies Pvt. Ltd. |
|||
# |
|||
# Copyright (C) 2024-TODAY Cybrosys Technologies(<https://www.cybrosys.com>). |
|||
# |
|||
# You can modify it under the terms of the GNU AFFERO |
|||
# GENERAL PUBLIC LICENSE (AGPL v3), Version 3. |
|||
# |
|||
# This program is distributed in the hope that it will be useful, |
|||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
# GNU AFFERO GENERAL PUBLIC LICENSE (AGPL v3) for more details. |
|||
# |
|||
# You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE |
|||
# (AGPL v3) along with this program. |
|||
# If not, see <http://www.gnu.org/licenses/>. |
|||
# |
|||
############################################################################# |
|||
import vonage |
|||
from telesign.messaging import MessagingClient |
|||
from twilio.rest import Client |
|||
from odoo import fields, models, _ |
|||
from odoo.exceptions import UserError |
|||
|
|||
|
|||
class SendSms(models.TransientModel): |
|||
""" |
|||
Class for the wizard to send SMS. |
|||
Methods: |
|||
action_send_sms(): |
|||
Button action to send SMS. |
|||
""" |
|||
_name = 'send.sms' |
|||
_description = 'Wizard to send SMS' |
|||
|
|||
sms_id = fields.Many2one('sms.gateway.config', string='Connection ID', |
|||
help='Gateway record with credentials') |
|||
sms_to = fields.Char(string='Send To', |
|||
help='Enter the number to send the SMS') |
|||
text = fields.Text(string='Text', required=True, |
|||
help='Enter the text for the SMS') |
|||
|
|||
def action_send_sms(self): |
|||
""" |
|||
Function to send SMS using different SMS gateway |
|||
""" |
|||
if self.sms_id.gateway_name == 'vonage': |
|||
client = vonage.Client(key=self.sms_id.vonage_key, |
|||
secret=self.sms_id.vonage_secret) |
|||
vonage.Sms(client) |
|||
for number in self.sms_to.split(','): |
|||
if number: |
|||
client.sms.send_message( |
|||
{ |
|||
"from": 'Vonage APIs', |
|||
"to": number, |
|||
"text": self.text |
|||
} |
|||
) |
|||
elif self.sms_id.gateway_name == 'twilio': |
|||
client = Client(self.sms_id.twilio_account_sid, |
|||
self.sms_id.twilio_auth_token) |
|||
for number in self.sms_to.split(','): |
|||
if number: |
|||
try: |
|||
client.messages.create( |
|||
body=self.text, |
|||
from_=int(self.sms_id.twilio_phone_number), |
|||
to=number |
|||
) |
|||
except: |
|||
raise UserError( |
|||
_('Provide correct credentials')) |
|||
elif self.sms_id.gateway_name == 'telesign': |
|||
for number in self.sms_to.split(','): |
|||
if number: |
|||
messaging = MessagingClient( |
|||
self.sms_id.telesign_customer, |
|||
self.sms_id.telesign_api_key) |
|||
messaging.message(number, self.text, 'ARN') |
|||
self.env['sms.history'].sudo().create({ |
|||
'sms_gateway_id': self.sms_id.sms_gateway_id.id, |
|||
'sms_mobile': self.sms_to, |
|||
'sms_text': self.text |
|||
}) |
@ -0,0 +1,29 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<odoo> |
|||
<!-- Form view for SMS User --> |
|||
<record id="send_sms_view_form" model="ir.ui.view"> |
|||
<field name="name">send.sms.view.form</field> |
|||
<field name="model">send.sms</field> |
|||
<field name="arch" type="xml"> |
|||
<!-- Form view of the wizard --> |
|||
<form string="Send SMS"> |
|||
<group string="SMS Gateway" colspan="4"> |
|||
<field name="sms_id"/> |
|||
</group> |
|||
<group string="Send SMS" colspan="4"> |
|||
<field name="sms_to"/> |
|||
</group> |
|||
<notebook> |
|||
<page string="Message"> |
|||
<field name="text" colspan="4" nolabel="1"/> |
|||
</page> |
|||
</notebook> |
|||
<footer> |
|||
<button string="Send SMS" name="action_send_sms" |
|||
type="object" class="oe_highlight"/> |
|||
<button string="Cancel" class="oe_link" special="cancel"/> |
|||
</footer> |
|||
</form> |
|||
</field> |
|||
</record> |
|||
</odoo> |