diff --git a/connector_voicent/README.rst b/connector_voicent/README.rst index 2bcf14d..36f2beb 100644 --- a/connector_voicent/README.rst +++ b/connector_voicent/README.rst @@ -1,13 +1,93 @@ -**Connector Voicent** - -*This module allows you to connect Odoo with Voicent (https://www.voicent.com).* - -* **DESCRIPTION.rst** -* **USAGE.rst** -* **CONTRIBUTORS.rst** -* INSTALL.rst -* CONFIGURE.rst -* DEVELOP.rst -* ROADMAP.rst -* HISTORY.rst -* CREDITS.rst +================= +Voicent Connector +================= + +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |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/12.0/connector_voicent + :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-12-0/connector-telephony-12-0-connector_voicent + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png + :target: https://runbot.odoo-community.org/runbot/228/12.0 + :alt: Try me on Runbot + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module allows you to connect Odoo with Voicent and is meant to be extended to integrate Odoo records and processes with phone calls made by Voicent. + +**Table of contents** + +.. contents:: + :local: + +Usage +===== + +To use this module, you need to: + +#. Go to Connectors > Backends > Voicent Backends +#. Create a new Voicent Backend with the host and port +#. Create Call Lines to determine when (which stage in the process) calls are added to the queue +#. Create Time Line to determine when (what time) calls are made + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +~~~~~~~ + +* Open Source Integrators + +Contributors +~~~~~~~~~~~~ + +* Maxime Chambreuil +* Youness MAAFI +* Murtuza Saleh + +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-max3903| image:: https://github.com/max3903.png?size=40px + :target: https://github.com/max3903 + :alt: max3903 + +Current `maintainer `__: + +|maintainer-max3903| + +This module is part of the `OCA/connector-telephony `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/connector_voicent/__init__.py b/connector_voicent/__init__.py index 0650744..69f7bab 100644 --- a/connector_voicent/__init__.py +++ b/connector_voicent/__init__.py @@ -1 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from . import models diff --git a/connector_voicent/__manifest__.py b/connector_voicent/__manifest__.py index 716fc65..8067dd0 100644 --- a/connector_voicent/__manifest__.py +++ b/connector_voicent/__manifest__.py @@ -1,30 +1,31 @@ -# @TODO: To use the right License. -# @TODO: Description, Website, Contributros..etc. +# Copyright (C) 2019 Open Source Integrators +# +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + { 'name': 'Voicent Connector', 'version': '12.0.1.0.0', - 'category': 'Phone', + 'category': 'Connector', 'license': 'AGPL-3', - 'summary': 'Automate phone calls based on stage changes', - 'development_status': 'Stable', - 'maintainers': [ - 'younessmaafi', - 'max3903', - ], - 'author': 'Maxime Chambreuil, Youness MAAFI,' - ' Odoo Community Association (OCA)', - 'website': 'http://opensourceintegrators.com', + 'summary': """This module allows you to connect Odoo with Voicent + (https://www.voicent.com) and is meant to be extended to integrate + Odoo records and processes with phone calls made by Voicent.""", + "author": "Open Source Integrators, " + "Odoo Community Association (OCA)", + "website": "https://github.com/OCA/connector-telephony", 'depends': [ - 'base', - ], + 'connector', + ], 'data': [ - # Security 'security/ir.model.access.csv', - # Views + 'data/check_the_voicent_status.xml', 'view/res_partner.xml', 'view/backend_voicent.xml', - ], - 'demo': [], + 'view/queue_job_view.xml', + ], 'installable': True, - 'auto_install': False, + 'maintainers': [ + 'max3903', + ], + 'development_status': 'Beta', } diff --git a/connector_voicent/data/check_the_voicent_status.xml b/connector_voicent/data/check_the_voicent_status.xml new file mode 100644 index 0000000..ae7fa47 --- /dev/null +++ b/connector_voicent/data/check_the_voicent_status.xml @@ -0,0 +1,17 @@ + + + + + Fetch check the Voicent status + + + + 15 + minutes + -1 + + code + model._run_check_the_voicent_status() + + + diff --git a/connector_voicent/models/__init__.py b/connector_voicent/models/__init__.py index c0c25d8..46f473c 100644 --- a/connector_voicent/models/__init__.py +++ b/connector_voicent/models/__init__.py @@ -1,4 +1,5 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + from . import res_partner from . import backend_voicent -from . import backend_voicent_call_line -from . import backend_voicent_time_line +from . import queue_job diff --git a/connector_voicent/models/backend_voicent.py b/connector_voicent/models/backend_voicent.py index 5952cee..48320f7 100644 --- a/connector_voicent/models/backend_voicent.py +++ b/connector_voicent/models/backend_voicent.py @@ -1,33 +1,130 @@ +# Copyright (C) 2019 Open Source Integrators +# # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import fields, models + +from odoo import api, fields, models +from datetime import datetime, timedelta +from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT +from pytz import timezone +from ..examples import voicent class BackendVoicent(models.Model): _name = 'backend.voicent' _description = 'Voicent Backend' + _inherit = ['connector.backend'] _rec_name = 'host' host = fields.Char( - string=u'Host', + string='Host', required=True, ) port = fields.Integer( - string=u'Port', + string='Port', required=True, ) next_call = fields.Datetime( - string=u'Next Call', + string='Next Call', copy=False, - default=lambda self: fields.Datetime.now(), ) call_line_ids = fields.One2many( - string=u'Call Lines', + string='Call Lines', comodel_name='backend.voicent.call.line', inverse_name='backend_id', ) time_line_ids = fields.One2many( - string=u'Call Times', + string='Call Times', comodel_name='backend.voicent.time.line', inverse_name='backend_id', ) + is_active = fields.Boolean('Is Active') + + @api.model + def _run_check_the_voicent_status(self): + ''' This method is called from a cron job. ''' + + cr_time_list = [] + is_next_day = False + backend_voicent_rec = self.search([('is_active', '=', True)]) + for backend_voicent in backend_voicent_rec: + current_dt = datetime.now(timezone('UTC')) + user_tz = timezone( + self.env.context.get('tz') or self.env.user.tz or 'UTC') + dt_value = current_dt.astimezone(user_tz) + convt_dt_strf = dt_value.strftime( + DEFAULT_SERVER_DATETIME_FORMAT) + convt_dt = datetime.strptime( + convt_dt_strf, + DEFAULT_SERVER_DATETIME_FORMAT) + current_time = convt_dt.strftime("%H:%M") + for time_line_rec in backend_voicent.time_line_ids: + hours, minutes = divmod(abs(time_line_rec.time) * 60, 60) + minutes = round(minutes) + if minutes == 60: + minutes = 0 + hours += 1 + line_time = '%02d:%02d' % (hours, minutes) + cr_time_list.append(line_time) + cr_time_list = sorted(cr_time_list) + next_call = datetime.now() + for each_time_entry in cr_time_list: + if each_time_entry > current_time and not is_next_day: + next_call = datetime.now().replace( + hour=int(each_time_entry.split(':')[0]), + minute=int(each_time_entry.split(':')[1])) + is_next_day = True + if cr_time_list and not is_next_day: + next_call = datetime.now().replace( + hour=int(cr_time_list[0].split(':')[0]), + minute=int(cr_time_list[0].split(':')[1])) + timedelta( + days=1) + next_call_tz = timezone(self.env.context.get( + 'tz') or self.env.user.tz).localize(next_call, is_dst=False) + next_call_utc = next_call_tz.astimezone(timezone('UTC')) + next_call_utc = datetime.strptime( + fields.Datetime.to_string(next_call_utc), + DEFAULT_SERVER_DATETIME_FORMAT) + backend_voicent.next_call = fields.Datetime.to_string( + next_call_utc) + + +class BackendVoicentTimeLine(models.Model): + _name = 'backend.voicent.time.line' + _description = 'Voicent Backend Time Line' + + name = fields.Char( + string='Name', + required=True, + ) + time = fields.Float( + string='Time', + copy=False, + ) + backend_id = fields.Many2one( + string='Backend', + comodel_name='backend.voicent', + ondelete='set null', + ) + + +class BackendVoicentCallLine(models.Model): + _name = 'backend.voicent.call.line' + _description = 'Voicent Backend Call Line' + + name = fields.Char( + string='Name', + required=True, + ) + applies_on = fields.Selection( + string='Applies on', + selection=[], + ) + voicent_app = fields.Char( + string='Voicent App', + ) + backend_id = fields.Many2one( + string='Backend', + comodel_name='backend.voicent', + ondelete='set null', + ) diff --git a/connector_voicent/models/backend_voicent_call_line.py b/connector_voicent/models/backend_voicent_call_line.py deleted file mode 100644 index 9006b93..0000000 --- a/connector_voicent/models/backend_voicent_call_line.py +++ /dev/null @@ -1,25 +0,0 @@ -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import fields, models - - -class BackendVoicentCallLine(models.Model): - _name = 'backend.voicent.call.line' - _description = 'Voicent Backend Call Line' - - name = fields.Char( - string=u'Name', - required=True, - ) - applies_on = fields.Selection( - string=u'Applies on', - selection=[], - ) - voicent_app = fields.Char( - string=u'Voicent App', - ) - backend_id = fields.Many2one( - string=u'Backend', - comodel_name='backend.voicent', - ondelete='set null', - ) diff --git a/connector_voicent/models/backend_voicent_time_line.py b/connector_voicent/models/backend_voicent_time_line.py deleted file mode 100644 index 3335849..0000000 --- a/connector_voicent/models/backend_voicent_time_line.py +++ /dev/null @@ -1,23 +0,0 @@ -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import fields, models - - -class BackendVoicentTimeLine(models.Model): - _name = 'backend.voicent.time.line' - _description = 'Voicent Backend Time Line' - - name = fields.Char( - string=u'Name', - required=True, - ) - time = fields.Datetime( - string=u'Time', - copy=False, - default=lambda self: fields.Datetime.now(), - ) - backend_id = fields.Many2one( - string=u'Backend', - comodel_name='backend.voicent', - ondelete='set null', - ) diff --git a/connector_voicent/models/queue_job.py b/connector_voicent/models/queue_job.py new file mode 100644 index 0000000..8c3e8be --- /dev/null +++ b/connector_voicent/models/queue_job.py @@ -0,0 +1,17 @@ +# Copyright (C) 2019 Open Source Integrators +# +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class QueueJob(models.Model): + """ Job status and result """ + _inherit = 'queue.job' + + call_line_id = fields.Many2one( + 'backend.voicent.call.line', 'Call Line', + ) + voicent_campaign = fields.Text( + 'Campaign ID', + ) diff --git a/connector_voicent/models/res_partner.py b/connector_voicent/models/res_partner.py index 0315fe1..6d2359f 100644 --- a/connector_voicent/models/res_partner.py +++ b/connector_voicent/models/res_partner.py @@ -1,3 +1,5 @@ +# Copyright (C) 2019 Open Source Integrators +# # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import fields, models @@ -7,5 +9,5 @@ class ResPartner(models.Model): _inherit = 'res.partner' can_call = fields.Boolean( - string=u'Accepts Calls', + string='Accepts Calls', ) diff --git a/connector_voicent/readme/CONFIGURE.rst b/connector_voicent/readme/CONFIGURE.rst deleted file mode 100644 index 7583d6e..0000000 --- a/connector_voicent/readme/CONFIGURE.rst +++ /dev/null @@ -1 +0,0 @@ -There is no specific configuration procedure for this module. diff --git a/connector_voicent/readme/CONTRIBUTORS.rst b/connector_voicent/readme/CONTRIBUTORS.rst index 0f79ba1..b56fc23 100644 --- a/connector_voicent/readme/CONTRIBUTORS.rst +++ b/connector_voicent/readme/CONTRIBUTORS.rst @@ -1,2 +1,3 @@ * Maxime Chambreuil * Youness MAAFI +* Murtuza Saleh diff --git a/connector_voicent/readme/CREDITS.rst b/connector_voicent/readme/CREDITS.rst deleted file mode 100644 index e69de29..0000000 diff --git a/connector_voicent/readme/DESCRIPTION.rst b/connector_voicent/readme/DESCRIPTION.rst index a14dec3..4a2ce3e 100644 --- a/connector_voicent/readme/DESCRIPTION.rst +++ b/connector_voicent/readme/DESCRIPTION.rst @@ -1,2 +1 @@ -This module allows you to connect Odoo with Voicent (https://www.voicent.com), -and is meant to be extended to integrate Odoo records and processes with phone calls made by Voicent. +This module allows you to connect Odoo with Voicent and is meant to be extended to integrate Odoo records and processes with phone calls made by Voicent. diff --git a/connector_voicent/readme/HISTORY.rst b/connector_voicent/readme/HISTORY.rst deleted file mode 100644 index e69de29..0000000 diff --git a/connector_voicent/readme/INSTALL.rst b/connector_voicent/readme/INSTALL.rst deleted file mode 100644 index 9d94322..0000000 --- a/connector_voicent/readme/INSTALL.rst +++ /dev/null @@ -1 +0,0 @@ -There is no specific installation procedure for this module. diff --git a/connector_voicent/readme/ROADMAP.rst b/connector_voicent/readme/ROADMAP.rst deleted file mode 100644 index e69de29..0000000 diff --git a/connector_voicent/security/ir.model.access.csv b/connector_voicent/security/ir.model.access.csv index a1c6cb8..d9bbcff 100644 --- a/connector_voicent/security/ir.model.access.csv +++ b/connector_voicent/security/ir.model.access.csv @@ -1,4 +1,4 @@ id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -access_backend_voicent,access_backend_voicent,model_backend_voicent,base.group_user,1,1,1,0 -access_backend_voicent_call_line,access_backend_voicent_call_line,model_backend_voicent_call_line,base.group_user,1,1,1,0 -access_backend_voicent_time_line,access_backend_voicent_time_line,model_backend_voicent_time_line,base.group_user,1,0,1,0 +access_backend_voicent,access_backend_voicent,model_backend_voicent,base.group_user,1,1,1,1 +access_backend_voicent_call_line,access_backend_voicent_call_line,model_backend_voicent_call_line,base.group_user,1,1,1,1 +access_backend_voicent_time_line,access_backend_voicent_time_line,model_backend_voicent_time_line,base.group_user,1,1,1,1 diff --git a/connector_voicent/static/description/index.html b/connector_voicent/static/description/index.html new file mode 100644 index 0000000..9439998 --- /dev/null +++ b/connector_voicent/static/description/index.html @@ -0,0 +1,433 @@ + + + + + + +Voicent Connector + + + +
+

Voicent Connector

+ + +

Beta License: AGPL-3 OCA/connector-telephony Translate me on Weblate Try me on Runbot

+

This module allows you to connect Odoo with Voicent <https://www.voicent.com> and is meant to be extended to integrate Odoo records and processes with phone calls made by Voicent.

+

Table of contents

+ +
+

Usage

+
    +
  1. Go to Connectors > Backends > Voicent Backends
  2. +
  3. Create a new Voicent Backend with the host and port
  4. +
  5. Create Call Lines to determine when (which stage in the process) calls are added to the queue
  6. +
  7. Create Time Line to determine when (what time) calls are made
  8. +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed +feedback.

+

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

+
+
+

Credits

+
+

Authors

+
    +
  • Open Source Integrators
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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.

+

Current maintainer:

+

max3903

+

This module is part of the OCA/connector-telephony project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/connector_voicent/tests/__init__.py b/connector_voicent/tests/__init__.py new file mode 100644 index 0000000..e1cc30d --- /dev/null +++ b/connector_voicent/tests/__init__.py @@ -0,0 +1,3 @@ +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from . import test_backend_voicent diff --git a/connector_voicent/tests/test_backend_voicent.py b/connector_voicent/tests/test_backend_voicent.py new file mode 100644 index 0000000..95fd16f --- /dev/null +++ b/connector_voicent/tests/test_backend_voicent.py @@ -0,0 +1,34 @@ +# Copyright (C) 2019 Open Source Integrators +# +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo.tests.common import TransactionCase + + +class TestBackendVoicent(TransactionCase): + + def setUp(self): + super(TestBackendVoicent, self).setUp() + self.backend_voicent_model = self.env['backend.voicent'] + + self.backend_voicent_id = self.backend_voicent_model.create( + {'host': 'localhost', + 'port': '8155', + 'is_active': True, + 'call_line_ids': [(0, 0, + {'name': 'call 1', + 'applies_on': False, + 'voicent_app': 'App'})], + 'time_line_ids': [(0, 0, {'name': 'Call Time 1', + 'time': 10.0}), + (0, 0, {'name': 'Call Time 2', + 'time': 11.0}), + (0, 0, {'name': 'Call Time 3', + 'time': 12.0}), + (0, 0, {'name': 'Call Time 4', + 'time': 13.0})] + }) + + def test_run_check_the_voicent_status(self): + """To call the scheduler method.""" + self.backend_voicent_id._run_check_the_voicent_status() diff --git a/connector_voicent/view/backend_voicent.xml b/connector_voicent/view/backend_voicent.xml index 759e200..181c238 100644 --- a/connector_voicent/view/backend_voicent.xml +++ b/connector_voicent/view/backend_voicent.xml @@ -1,60 +1,62 @@ - + - - view.backend.voicent.tree + + backend.voicent.tree.view backend.voicent - primary - + + - - view.backend.voicent.form + + backend.voicent.form.view backend.voicent - primary -
-
-
+ + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + +
- - view.backend.voicent.search + + backend.voicent.search.view backend.voicent - primary + @@ -65,30 +67,25 @@ backend.voicent tree,form form - +

Click to add new Voicent Backend

- - - Connectors - - - - Backends - - - + - - Voicent Backends - - - - +
diff --git a/connector_voicent/view/queue_job_view.xml b/connector_voicent/view/queue_job_view.xml new file mode 100644 index 0000000..f22f39b --- /dev/null +++ b/connector_voicent/view/queue_job_view.xml @@ -0,0 +1,18 @@ + + + + + queue.job.form.inherit.voicent + queue.job + + + + + + + + + + + + diff --git a/connector_voicent/view/res_partner.xml b/connector_voicent/view/res_partner.xml index f359f21..7c7c214 100644 --- a/connector_voicent/view/res_partner.xml +++ b/connector_voicent/view/res_partner.xml @@ -1,5 +1,6 @@ - + + view.res.partner.form res.partner @@ -12,4 +13,5 @@ + diff --git a/oca_dependencies.txt b/oca_dependencies.txt index f3ae436..4e478c8 100644 --- a/oca_dependencies.txt +++ b/oca_dependencies.txt @@ -1,2 +1,4 @@ +connector +queue server-tools web