Skip to content

Commit

Permalink
[MIG] base_phone_popup
Browse files Browse the repository at this point in the history
  • Loading branch information
murtuzasaleh authored and MS-OSI committed Feb 14, 2024
1 parent e71754f commit 92e2d69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 50 deletions.
19 changes: 8 additions & 11 deletions base_phone_popup/models/phone_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from odoo import _, api, models

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

logger = logging.getLogger(__name__)

Expand All @@ -25,7 +25,6 @@ def _prepare_incall_pop_action(self, record_res, number):
"res_model": record_res[0],
"view_mode": "form,tree",
"views": [[False, "form"]],
# 'target': 'new',
"res_id": record_res[1],
}
else:
Expand All @@ -35,7 +34,6 @@ def _prepare_incall_pop_action(self, record_res, number):
"res_model": "number.not.found",
"view_mode": "form",
"views": [[False, "form"]],
# 'target': 'new',
"context": {"default_calling_number": number},
}
return action
Expand All @@ -46,25 +44,24 @@ def incall_notify_by_login(self, number, login_list):
res = self.get_record_from_phone_number(number)
users = self.env["res.users"].search([("login", "in", login_list)])
logger.info(
"Notify incoming call from number %s to user IDs %s" % (number, users.ids)
f"Notify incoming call from number {number} to user IDs {users.ids}"
)
action = self._prepare_incall_pop_action(res, number)
action = clean_action(action)
action = clean_action(action, self.env)
if action:
for user in users:
channel = "notify_info_%s" % user.id
channel_partner = self.env.user.partner_id
bus_message = {
"type": "success",
"message": _("Here is my message"),
"title": _("Incoming call"),
"action": action,
# 'sticky': True,
"action_link_name": "action_link_name",
}

self.sudo().env["bus.bus"].sendone(channel, bus_message)
logger.debug(
"This action has been sent to user ID %d: %s" % (user.id, action)
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:
Expand Down
39 changes: 0 additions & 39 deletions base_phone_popup/views/res_users.xml

This file was deleted.

0 comments on commit 92e2d69

Please sign in to comment.