Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[17.0][MIG] base_phone_popup #310

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions base_phone_popup/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
=================
Base Phone Pop-up
=================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:ec510c031dcf39f8614be3fdcaae8d6837177255ccd70c3dc3f275c44145a2ff
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |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/17.0/base_phone_popup
: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-17-0/connector-telephony-17-0-base_phone_popup
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/connector-telephony&target_branch=17.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

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.

**Table of contents**

.. contents::
:local:

Usage
=====

To deploy this feature with an Asterisk-based IPBX, please read this
`document <https://akretion.com/en/open-source-contributions/odoo-asterisk-voip-connector>`__.

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/connector-telephony/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/connector-telephony/issues/new?body=module:%20base_phone_popup%0Aversion:%2017.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

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

Credits
=======

Authors
-------

* Akretion

Contributors
------------

- Alexis de Lattre <alexis.delattre@akretion.com>

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.

This module is part of the `OCA/connector-telephony <https://github.com/OCA/connector-telephony/tree/17.0/base_phone_popup>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
1 change: 1 addition & 0 deletions base_phone_popup/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions base_phone_popup/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2014-2019 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Base Phone Pop-up",
"version": "17.0.1.0.0",
"category": "Phone",
"license": "AGPL-3",
"summary": "Pop-up the related form view to the user on incoming calls",
"author": "Akretion,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/connector-telephony",
"depends": ["base_phone", "web_notify"],
"installable": True,
}
38 changes: 38 additions & 0 deletions base_phone_popup/i18n/base_phone_popup.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_phone_popup
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: base_phone_popup
#: model:ir.model,name:base_phone_popup.model_phone_common
msgid "Common methods for phone features"
msgstr ""

#. module: base_phone_popup
#: code:addons/base_phone_popup/models/phone_common.py:57
#, python-format
msgid "Here is my message"
msgstr ""

#. module: base_phone_popup
#: code:addons/base_phone_popup/models/phone_common.py:58
#, python-format
msgid "Incoming call"
msgstr ""

#. module: base_phone_popup
#: code:addons/base_phone_popup/models/phone_common.py:32
#, python-format
msgid "Number Not Found"
msgstr ""

46 changes: 46 additions & 0 deletions base_phone_popup/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * base_phone_popup
#
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-08-25 22:05+0000\n"
"PO-Revision-Date: 2014-08-25 22:05+0000\n"
"Last-Translator: Alexis de Lattre <alexis.delattre@akretion.com>\n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: base_phone_popup
#: model:ir.model,name:base_phone_popup.model_phone_common
msgid "Common methods for phone features"
msgstr ""

#. module: base_phone_popup
#: code:addons/base_phone_popup/models/phone_common.py:57
#, python-format
msgid "Here is my message"
msgstr ""

#. module: base_phone_popup
#: code:addons/base_phone_popup/models/phone_common.py:58
#, fuzzy, python-format
msgid "Incoming call"
msgstr "Pop-up sur Appel Entrant"

#. module: base_phone_popup
#: code:addons/base_phone_popup/models/phone_common.py:32
#, python-format
msgid "Number Not Found"
msgstr "Numéro introuvable"

#~ msgid "Users"
#~ msgstr "Utilisateurs"

#~ msgid "phone.common"
#~ msgstr "phone.common"
40 changes: 40 additions & 0 deletions base_phone_popup/i18n/nl_BE.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * base_phone_popup
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 12.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2020-08-03 22:59+0000\n"
"Last-Translator: Christophe Langenberg <christophe@langenberg.be>\n"
"Language-Team: none\n"
"Language: nl_BE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 3.10\n"

#. module: base_phone_popup
#: model:ir.model,name:base_phone_popup.model_phone_common
msgid "Common methods for phone features"
msgstr "Veelvoorkomende methodes voor telefoon kenmerken "

#. module: base_phone_popup
#: code:addons/base_phone_popup/models/phone_common.py:57
#, python-format
msgid "Here is my message"
msgstr "Hier is mijn boodschap"

#. module: base_phone_popup
#: code:addons/base_phone_popup/models/phone_common.py:58
#, python-format
msgid "Incoming call"
msgstr "Inkomende oproep"

#. module: base_phone_popup
#: code:addons/base_phone_popup/models/phone_common.py:32
#, python-format
msgid "Number Not Found"
msgstr "Nummer niet gevonden"
48 changes: 48 additions & 0 deletions base_phone_popup/i18n/sl.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Translation of OpenERP Server.
# This file contains the translation of the following modules:
# * base_phone_popup
#
# Matjaž Mozetič <m.mozetic@matmoz.si>, 2015.
msgid ""
msgstr ""
"Project-Id-Version: OpenERP Server 7.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-08-25 22:05+0000\n"
"PO-Revision-Date: 2015-04-05 09:23+0200\n"
"Last-Translator: Matjaž Mozetič <m.mozetic@matmoz.si>\n"
"Language-Team: Slovenian <translate@matmoz.si>\n"
"Language: sl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
"X-Generator: Lokalize 1.5\n"

#. module: base_phone_popup
#: model:ir.model,name:base_phone_popup.model_phone_common
msgid "Common methods for phone features"
msgstr ""

#. module: base_phone_popup
#: code:addons/base_phone_popup/models/phone_common.py:57
#, python-format
msgid "Here is my message"
msgstr ""

#. module: base_phone_popup
#: code:addons/base_phone_popup/models/phone_common.py:58
#, fuzzy, python-format
msgid "Incoming call"
msgstr "Pojavno okno ob prejemu klicev"

#. module: base_phone_popup
#: code:addons/base_phone_popup/models/phone_common.py:32
#, python-format
msgid "Number Not Found"
msgstr "Številka ni najdena"

#~ msgid "Users"
#~ msgstr "Uporabniki"

#~ msgid "phone.common"
#~ msgstr "phone.common"
2 changes: 2 additions & 0 deletions base_phone_popup/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import phone_common
# from . import res_users
69 changes: 69 additions & 0 deletions base_phone_popup/models/phone_common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright 2014-2018 Akretion France
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging

from odoo import _, api, models

from odoo.addons.web.controllers.utils import clean_action

logger = logging.getLogger(__name__)


class PhoneCommon(models.AbstractModel):
_inherit = "phone.common"

@api.model
def _prepare_incall_pop_action(self, record_res, number):
action = False
if record_res:
obj = self.env[record_res[0]]
action = {
"name": obj._description,
"type": "ir.actions.act_window",
"res_model": record_res[0],
"view_mode": "form,tree",
"views": [[False, "form"]],
"res_id": record_res[1],
}
else:
action = {
"name": _("Number Not Found"),
"type": "ir.actions.act_window",
"res_model": "number.not.found",
"view_mode": "form",
"views": [[False, "form"]],
"context": {"default_calling_number": number},
}
return action

@api.model
def incall_notify_by_login(self, number, login_list):
assert isinstance(login_list, list), "login_list must be a list"
res = self.get_record_from_phone_number(number)
users = self.env["res.users"].search([("login", "in", login_list)])
logger.info(
f"Notify incoming call from number {number} to user IDs {users.ids}"
)
action = self._prepare_incall_pop_action(res, number)
action = clean_action(action, self.env)
if action:
for user in users:
channel_partner = self.env.user.partner_id
bus_message = {
"type": "success",
"message": _("Here is my message"),
"title": _("Incoming call"),
"action": action,
"action_link_name": "action_link_name",
}
self.sudo().env["bus.bus"]._sendone(
channel_partner, "web.notify", [bus_message]
)
logger.debug(f"This action has been sent to user ID {user.id} {action}")
if res:
callerid = res[2]
else:
callerid = False
return callerid
13 changes: 13 additions & 0 deletions base_phone_popup/models/res_users.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2014-2018 Akretion France
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ResUsers(models.Model):
_inherit = "res.users"

context_incall_popup = fields.Boolean(
string="Pop-up on Incoming Calls", default=True
)
3 changes: 3 additions & 0 deletions base_phone_popup/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions base_phone_popup/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Alexis de Lattre \<<alexis.delattre@akretion.com>\>
3 changes: 3 additions & 0 deletions base_phone_popup/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 2 additions & 0 deletions base_phone_popup/readme/USAGE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
To deploy this feature with an Asterisk-based IPBX, please read this
[document](https://akretion.com/en/open-source-contributions/odoo-asterisk-voip-connector).
Binary file added base_phone_popup/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading