@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
# © 2014-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# 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 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 )