From ff410504f140ec9959fdb6139651bb4ed1534034 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sun, 18 Nov 2018 21:05:59 +0100 Subject: [PATCH 1/3] [MIG] base_phone_popup to v10 We now use the great OCA module web_notify (OCA/web) --- base_phone_popup/__init__.py | 2 +- base_phone_popup/__manifest__.py | 36 +++++------------ base_phone_popup/models/__init__.py | 3 ++ .../{popup.py => models/phone_common.py} | 36 +++++++---------- base_phone_popup/res_users_view.xml | 39 ------------------- 5 files changed, 28 insertions(+), 88 deletions(-) create mode 100644 base_phone_popup/models/__init__.py rename base_phone_popup/{popup.py => models/phone_common.py} (64%) delete mode 100644 base_phone_popup/res_users_view.xml 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..4537f1d 100644 --- a/base_phone_popup/__manifest__.py +++ b/base_phone_popup/__manifest__.py @@ -1,43 +1,25 @@ # -*- 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', + 'summary': 'Show a pop-up 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 +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/... and a link to the *Number not found* wizard. """, '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..17a365b 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,21 @@ 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, True, False, action, 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/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 - - - - - - From 4ba55b04941630f296923aab676e99484a7c8f45 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Mon, 19 Nov 2018 09:53:27 +0100 Subject: [PATCH 2/3] base_phone_popup: use named arguments Move README from manifest to dedicated dir --- base_phone_popup/__manifest__.py | 8 -------- base_phone_popup/models/phone_common.py | 3 ++- base_phone_popup/readme/CONTRIBUTORS.rst | 1 + base_phone_popup/readme/DESCRIPTION.rst | 3 +++ base_phone_popup/readme/USAGE.rst | 1 + 5 files changed, 7 insertions(+), 9 deletions(-) create mode 100644 base_phone_popup/readme/CONTRIBUTORS.rst create mode 100644 base_phone_popup/readme/DESCRIPTION.rst create mode 100644 base_phone_popup/readme/USAGE.rst diff --git a/base_phone_popup/__manifest__.py b/base_phone_popup/__manifest__.py index 4537f1d..2775338 100644 --- a/base_phone_popup/__manifest__.py +++ b/base_phone_popup/__manifest__.py @@ -10,14 +10,6 @@ 'category': 'Phone', 'license': 'AGPL-3', 'summary': 'Show a pop-up on incoming calls', - 'description': """ -Base Phone Pop-up -================= - -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/... and a link to the *Number not found* wizard. -""", 'author': "Akretion,Odoo Community Association (OCA)", 'website': 'http://www.akretion.com/', 'depends': ['base_phone', 'web_notify'], diff --git a/base_phone_popup/models/phone_common.py b/base_phone_popup/models/phone_common.py index 17a365b..c92e2dd 100644 --- a/base_phone_popup/models/phone_common.py +++ b/base_phone_popup/models/phone_common.py @@ -52,7 +52,8 @@ class PhoneCommon(models.AbstractModel): message = _('Call from %s') % number action_link_name = res and res[2] or action['name'] users.notify_info( - message, title, True, False, action, action_link_name) + 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)) 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 `_. From 27e33f1cbda35b641b396101331696f296f71fc8 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Wed, 29 May 2019 00:34:33 +0200 Subject: [PATCH 3/3] Add web in oca_dependencies.txt --- oca_dependencies.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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