Browse Source

Port base_phone_popup to v9

pull/88/head
Alexis de Lattre 9 years ago
parent
commit
79e1634ca1
  1. 2
      .travis.yml
  2. 19
      base_phone_popup/__init__.py
  3. 33
      base_phone_popup/__openerp__.py
  4. 68
      base_phone_popup/popup.py
  5. 8
      base_phone_popup/res_users_view.xml

2
.travis.yml

@ -33,7 +33,7 @@ install:
- travis_install_nightly
- pip install phonenumbers py-Asterisk SOAPpy
- hg clone http://bitbucket.org/juris_malinens/web_action_request -b ${VERSION} ${HOME}/web_action_request # Pull request is not merged in anybox
- hg clone http://bitbucket.org/anybox/bus_enhanced ${HOME}/bus_enhanced
- hg clone http://bitbucket.org/juris_malinens/bus_enhanced -b ${VERSION} ${HOME}/bus_enhanced # Pull request is not merged in anybox
script:
- travis_run_tests

19
base_phone_popup/__init__.py

@ -1,22 +1,3 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Base Phone Pop-up module for Odoo/OpenERP
# Copyright (C) 2014 Alexis de Lattre <alexis@via.ecp.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from . import popup

33
base_phone_popup/__openerp__.py

@ -1,28 +1,11 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Base Phone Pop-up module for Odoo/OpenERP
# Copyright (C) 2014 Alexis de Lattre <alexis@via.ecp.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# -*- coding: utf-8 -*-
# © 2014-2016 Akretion (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': '8.0.0.4.0',
'version': '9.0.1.0.0',
'category': 'Phone',
'license': 'AGPL-3',
'summary': 'Pop-up the related form view to the user on incoming calls',
@ -55,10 +38,6 @@ http://www.akretion.com/products-and-services/openerp-asterisk-voip-connector
'author': "Akretion,Odoo Community Association (OCA)",
'website': 'http://www.akretion.com/',
'depends': ['base_phone', 'web_action_request'],
'data': [
'res_users_view.xml',
],
'images': [],
'active': False,
'installable': False,
'data': ['res_users_view.xml'],
'installable': True,
}

68
base_phone_popup/popup.py

@ -1,40 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Base Phone Pop-up module for Odoo/OpenERP
# Copyright (C) 2014 Alexis de Lattre <alexis@via.ecp.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
# © 2014-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from openerp.osv import orm, fields
from openerp.tools.translate import _
from openerp import models, fields, api, _
import logging
logger = logging.getLogger(__name__)
class phone_common(orm.AbstractModel):
class PhoneCommon(models.AbstractModel):
_inherit = 'phone.common'
def _prepare_incall_pop_action(
self, cr, uid, record_res, number, context=None):
@api.model
def _prepare_incall_pop_action(self, record_res, number):
action = False
if record_res:
obj = self.pool[record_res[0]]
obj = self.env[record_res[0]]
action = {
'name': obj._description,
'type': 'ir.actions.act_window',
@ -56,28 +38,23 @@ class phone_common(orm.AbstractModel):
}
return action
def incall_notify_by_login(
self, cr, uid, number, login_list, context=None):
@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(
cr, uid, number, context=context)
user_ids = self.pool['res.users'].search(
cr, uid, [('login', 'in', login_list)], context=context)
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'
% (number, user_ids))
action = self._prepare_incall_pop_action(
cr, uid, res, number, context=context)
% (number, users.ids))
action = self._prepare_incall_pop_action(res, number)
if action:
users = self.pool['res.users'].read(
cr, uid, user_ids, ['context_incall_popup'], context=context)
for user in users:
if user['context_incall_popup']:
self.pool['action.request'].notify(
cr, user['id'], action)
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))
% (user.id, action))
if res:
callerid = res[2]
else:
@ -85,13 +62,8 @@ class phone_common(orm.AbstractModel):
return callerid
class res_users(orm.Model):
class ResUsers(models.Model):
_inherit = 'res.users'
_columns = {
'context_incall_popup': fields.boolean('Pop-up on Incoming Calls'),
}
_defaults = {
'context_incall_popup': True,
}
context_incall_popup = fields.Boolean(
string='Pop-up on Incoming Calls', default=True)

8
base_phone_popup/res_users_view.xml

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 Alexis de Lattre <alexis@via.ecp.fr>
The licence is in the file __openerp__.py
© 2014-2016 Akretion (Alexis de Lattre <alexis.delattre@akretion.com>)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<odoo>
<data>
<record id="view_users_form" model="ir.ui.view">
@ -36,4 +36,4 @@
</record>
</data>
</openerp>
</odoo>
Loading…
Cancel
Save