diff --git a/base_phone_popup/__init__.py b/base_phone_popup/__init__.py index d5a89e7..cde864b 100644 --- a/base_phone_popup/__init__.py +++ b/base_phone_popup/__init__.py @@ -1,3 +1,3 @@ # -*- coding: utf-8 -*- -from . import popup +from . import models diff --git a/base_phone_popup/__manifest__.py b/base_phone_popup/__manifest__.py index e56e04c..2775338 100644 --- a/base_phone_popup/__manifest__.py +++ b/base_phone_popup/__manifest__.py @@ -1,43 +1,17 @@ # -*- coding: utf-8 -*- -# © 2014-2016 Akretion (Alexis de Lattre ) +# Copyright 2014-2018 Akretion France +# @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Base Phone Pop-up', - 'version': '9.0.1.0.0', + 'version': '10.0.1.0.0', 'category': 'Phone', 'license': 'AGPL-3', - 'summary': 'Pop-up the related form view to the user on incoming calls', - 'description': """ -Base Phone Pop-up -================= - -When the user receives a phone call, OpenERP can automatically open the -corresponding partner/lead/employee/... in a pop-up without any action from the -user. - -The module *web_action_request* can be downloaded with Mercurial: - -hg clone http://bitbucket.org/anybox/web_action_request - -It depends on 2 other modules, *web_longpolling* and *web_socketio*, that can -be downloaded with this command: - -hg clone http://bitbucket.org/anybox/web_socketio - -You will find some hints in this documentation : -https://bitbucket.org/anybox/web_action_request - -Warning : proxying WebSockets is only supported since Nginx 1.3.13 ; the -feature provided by this module won't work with older versions of Nginx. - -TODO : document this new feature on the Akretion Web site : -http://www.akretion.com/products-and-services/openerp-asterisk-voip-connector -""", + 'summary': 'Show a pop-up on incoming calls', 'author': "Akretion,Odoo Community Association (OCA)", 'website': 'http://www.akretion.com/', - 'depends': ['base_phone', 'web_action_request'], - 'data': ['res_users_view.xml'], - 'installable': False, + 'depends': ['base_phone', 'web_notify'], + 'installable': True, } diff --git a/base_phone_popup/models/__init__.py b/base_phone_popup/models/__init__.py new file mode 100644 index 0000000..08f0b66 --- /dev/null +++ b/base_phone_popup/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from . import phone_common diff --git a/base_phone_popup/popup.py b/base_phone_popup/models/phone_common.py similarity index 64% rename from base_phone_popup/popup.py rename to base_phone_popup/models/phone_common.py index b0fc561..c92e2dd 100644 --- a/base_phone_popup/popup.py +++ b/base_phone_popup/models/phone_common.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- -# © 2014-2016 Akretion (Alexis de Lattre ) +# Copyright 2014-2018 Akretion France +# @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from openerp import models, fields, api, _ +from odoo import api, models, _ import logging - logger = logging.getLogger(__name__) @@ -22,8 +22,7 @@ class PhoneCommon(models.AbstractModel): 'type': 'ir.actions.act_window', 'res_model': record_res[0], 'view_mode': 'form,tree', - 'views': [[False, 'form']], # Beurk, but needed - 'target': 'new', + 'views': [[False, 'form']], 'res_id': record_res[1], } else: @@ -32,7 +31,7 @@ class PhoneCommon(models.AbstractModel): 'type': 'ir.actions.act_window', 'res_model': 'number.not.found', 'view_mode': 'form', - 'views': [[False, 'form']], # Beurk, but needed + 'views': [[False, 'form']], 'target': 'new', 'context': {'default_calling_number': number} } @@ -44,26 +43,22 @@ class PhoneCommon(models.AbstractModel): res = self.get_record_from_phone_number(number) users = self.env['res.users'].search( [('login', 'in', login_list)]) - logger.debug( - 'Notify incoming call from number %s to users %s' + logger.info( + 'Notify incoming call from number %s to users IDs %s' % (number, users.ids)) action = self._prepare_incall_pop_action(res, number) if action: - for user in users: - if user.context_incall_popup: - self.sudo(user.id).env['action.request'].notify(action) - logger.debug( - 'This action has been sent to user ID %d: %s' - % (user.id, action)) + title = _('Incoming call') + message = _('Call from %s') % number + action_link_name = res and res[2] or action['name'] + users.notify_info( + message, title=title, sticky=True, action=action, + action_link_name=action_link_name) + logger.debug( + 'This action has been sent to users IDs %s: %s' + % (users.ids, action)) if res: callerid = res[2] else: callerid = False return callerid - - -class ResUsers(models.Model): - _inherit = 'res.users' - - context_incall_popup = fields.Boolean( - string='Pop-up on Incoming Calls', default=True) diff --git a/base_phone_popup/readme/CONTRIBUTORS.rst b/base_phone_popup/readme/CONTRIBUTORS.rst new file mode 100644 index 0000000..ff65d68 --- /dev/null +++ b/base_phone_popup/readme/CONTRIBUTORS.rst @@ -0,0 +1 @@ +* Alexis de Lattre diff --git a/base_phone_popup/readme/DESCRIPTION.rst b/base_phone_popup/readme/DESCRIPTION.rst new file mode 100644 index 0000000..b2c7dfa --- /dev/null +++ b/base_phone_popup/readme/DESCRIPTION.rst @@ -0,0 +1,3 @@ +When the user receives a phone call, Odoo will display a notification +at the top-right of the screen that contains a link to the corresponding +partner/lead/employee/... or a link to the *Number not found* wizard. diff --git a/base_phone_popup/readme/USAGE.rst b/base_phone_popup/readme/USAGE.rst new file mode 100644 index 0000000..46522e6 --- /dev/null +++ b/base_phone_popup/readme/USAGE.rst @@ -0,0 +1 @@ +To deploy this feature with an Asterisk-based IPBX, please read this `document `_. diff --git a/base_phone_popup/res_users_view.xml b/base_phone_popup/res_users_view.xml deleted file mode 100644 index 1631b8a..0000000 --- a/base_phone_popup/res_users_view.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - base_phone_popup.res.users.form - res.users - - - - 0 - - - - - - - - - base_phone_popup.users.preferences.view - res.users - - - - - - - 0 - - - - - - diff --git a/oca_dependencies.txt b/oca_dependencies.txt index a89069d..f3ae436 100644 --- a/oca_dependencies.txt +++ b/oca_dependencies.txt @@ -1 +1,2 @@ -server-tools \ No newline at end of file +server-tools +web