diff --git a/asterisk_click2dial/__openerp__.py b/asterisk_click2dial/__openerp__.py
index bac6600..8836b03 100644
--- a/asterisk_click2dial/__openerp__.py
+++ b/asterisk_click2dial/__openerp__.py
@@ -23,7 +23,7 @@
{
'name': 'Asterisk Click2dial',
'version': '0.4',
- 'category': 'Extra Tools',
+ 'category': 'Phone',
'license': 'AGPL-3',
'summary': 'Asterisk-OpenERP connector',
'description': """This module adds 3 functionalities :
@@ -58,7 +58,6 @@ A detailed documentation for this module is available on the Akretion Web site :
'res_users_view.xml',
'res_partner_view.xml',
'wizard/open_calling_partner_view.xml',
- 'security/asterisk_server_security.xml',
'security/ir.model.access.csv',
],
'demo': ['asterisk_click2dial_demo.xml'],
diff --git a/asterisk_click2dial/asterisk_click2dial.py b/asterisk_click2dial/asterisk_click2dial.py
index 9d4731a..9795ae0 100644
--- a/asterisk_click2dial/asterisk_click2dial.py
+++ b/asterisk_click2dial/asterisk_click2dial.py
@@ -50,7 +50,6 @@ class asterisk_server(orm.Model):
'wait_time': fields.integer('Wait time (sec)', required=True, help="Amount of time (in seconds) Asterisk will try to reach the user's phone before hanging up."),
'extension_priority': fields.integer('Extension priority', required=True, help="Priority of the extension in the Asterisk dialplan. Refer to /etc/asterisk/extensions.conf on your Asterisk server."),
'alert_info': fields.char('Alert-Info SIP header', size=255, help="Set Alert-Info header in SIP request to user's IP Phone for the click2dial feature. If empty, the Alert-Info header will not be added. You can use it to have a special ring tone for click2dial (a silent one !) or to activate auto-answer for example."),
- 'number_of_digits_to_match_from_end': fields.integer('Number of digits to match from end', help='In several situations, the Asterisk-OpenERP connector will have to find a Partner in OpenERP from a phone number presented by the calling party. As the phone numbers presented by your phone operator may not always be displayed in a standard format, the best method to find the related Partner in OpenERP is to try to match the end of the phone numbers of the Partners in OpenERP with the N last digits of the phone number presented by the calling party. N is the value you should enter in this field.'),
'company_id': fields.many2one('res.company', 'Company', help="Company who uses the Asterisk server."),
}
@@ -65,13 +64,11 @@ class asterisk_server(orm.Model):
_defaults = {
'active': True,
'port': 5038, # Default AMI port
- 'out_prefix': '0',
'national_prefix': '0',
'international_prefix': '00',
'country_prefix': _get_prefix_from_country,
'extension_priority': 1,
'wait_time': 15,
- 'number_of_digits_to_match_from_end': 9,
'company_id': lambda self, cr, uid, context: self.pool.get('res.company')._company_default_get(cr, uid, 'asterisk.server', context=context),
}
@@ -95,8 +92,6 @@ class asterisk_server(orm.Model):
raise orm.except_orm(_('Error :'), _("The 'extension priority' must be a positive value for the Asterisk server '%s'" % server.name))
if server.port > 65535 or server.port < 1:
raise orm.except_orm(_('Error :'), _("You should set a TCP port between 1 and 65535 for the Asterisk server '%s'" % server.name))
- if server.number_of_digits_to_match_from_end > 20 or server.number_of_digits_to_match_from_end < 1:
- raise orm.except_orm(_('Error :'), _("You should set a 'Number of digits to match from end' between 1 and 20 for the Asterisk server '%s'" % server.name))
for check_string in [dialplan_context, alert_info, login, password]:
if check_string[1]:
try:
@@ -107,7 +102,7 @@ class asterisk_server(orm.Model):
_constraints = [
- (_check_validity, "Error message in raise", ['out_prefix', 'country_prefix', 'national_prefix', 'international_prefix', 'wait_time', 'extension_priority', 'port', 'context', 'alert_info', 'login', 'password', 'number_of_digits_to_match_from_end']),
+ (_check_validity, "Error message in raise", ['out_prefix', 'country_prefix', 'national_prefix', 'international_prefix', 'wait_time', 'extension_priority', 'port', 'context', 'alert_info', 'login', 'password']),
]
@@ -395,65 +390,20 @@ class phone_common(orm.AbstractModel):
raise orm.except_orm(_('Error :'), _('There is no phone number !'))
return self.pool['asterisk.server']._dial_with_asterisk(cr, uid, erp_number_e164, context=context)
-
-class res_partner(orm.Model):
- _name = 'res.partner'
- _inherit = ['res.partner', 'phone.common']
-
- def get_name_from_phone_number(self, cr, uid, number, context=None):
- '''Function to get name from phone number. Usefull for use from Asterisk
- to add CallerID name to incoming calls.
- The "scripts/" subdirectory of this module has an AGI script that you can
- install on your Asterisk IPBX : the script will be called from the Asterisk
- dialplan via the AGI() function and it will use this function via an XML-RPC
- request.
- '''
- res = self.get_partner_from_phone_number(cr, uid, number, context=context)
- if res:
- return res[2]
- else:
- return False
-
-
- def get_partner_from_phone_number(self, cr, uid, presented_number, context=None):
- # We check that "number" is really a number
- _logger.debug(u"Call get_name_from_phone_number with number = %s" % presented_number)
- if not isinstance(presented_number, (str, unicode)):
- _logger.warning(u"Number '%s' should be a 'str' or 'unicode' but it is a '%s'" % (presented_number, type(presented_number)))
- return False
- if not presented_number.isdigit():
- _logger.warning(u"Number '%s' should only contain digits." % presented_number)
- return False
-
- ast_server = self.pool['asterisk.server']._get_asterisk_server_from_user(cr, uid, context=context)
- nr_digits_to_match_from_end = ast_server.number_of_digits_to_match_from_end
- if len(presented_number) >= nr_digits_to_match_from_end:
- end_number_to_match = presented_number[-nr_digits_to_match_from_end:len(presented_number)]
- else:
- end_number_to_match = presented_number
-
- _logger.debug("Will search phone and mobile numbers in res.partner ending with '%s'" % end_number_to_match)
-
- # We try to match a phone or mobile number with the same end
- pg_seach_number = str('%' + end_number_to_match)
- res_ids = self.search(cr, uid, ['|', ('phone', 'like', pg_seach_number), ('mobile', 'like', pg_seach_number)], context=context)
- # TODO : use is_number_match() of the phonenumber lib ?
- if len(res_ids) > 1:
- _logger.warning(u"There are several partners (IDS = %s) with a phone number ending with '%s'" % (str(res_ids), end_number_to_match))
- if res_ids:
- entry = self.read(cr, uid, res_ids[0], ['name', 'parent_id'], context=context)
- _logger.debug(u"Answer get_partner_from_phone_number with name = %s" % entry['name'])
- return (entry['id'], entry['parent_id'] and entry['parent_id'][0] or False, entry['name'])
- else:
- _logger.debug(u"No match for end of phone number '%s'" % end_number_to_match)
- return False
-
-
-# This module supports multi-company
-class res_company(orm.Model):
- _inherit = "res.company"
-
- _columns = {
- 'asterisk_server_ids': fields.one2many('asterisk.server', 'company_id', 'Asterisk servers', help="List of Asterisk servers.")
- }
-
+ def _prepare_incall_pop_action(
+ self, cr, uid, record_res, number, context=None):
+ # Not executed because this module doesn't depend on base_phone_popup
+ # TODO move to a dedicated module asterisk_popup ?
+ action = super(phone_common, self)._prepare_incall_pop_action(
+ cr, uid, record_res, number, context=context)
+ if not action:
+ action = {
+ 'name': _('No Partner Found'),
+ 'type': 'ir.actions.act_window',
+ 'res_model': 'wizard.open.calling.partner',
+ 'view_mode': 'form',
+ 'views': [[False, 'form']], # Beurk, but needed
+ 'target': 'new',
+ 'context': {'incall_number_popup': number}
+ }
+ return action
diff --git a/asterisk_click2dial/asterisk_server_view.xml b/asterisk_click2dial/asterisk_server_view.xml
index 0bcc1af..3bf813f 100644
--- a/asterisk_click2dial/asterisk_server_view.xml
+++ b/asterisk_click2dial/asterisk_server_view.xml
@@ -8,28 +8,14 @@
-
-
- asterisk.server.company
- res.company
-
-
-
-
-
-
-
-
-
-
asterisk.server.searchasterisk.server
-
-
+
@@ -48,7 +34,9 @@
-
+
@@ -62,7 +50,6 @@
-
@@ -75,10 +62,11 @@
asterisk.server
-
-
+
@@ -88,7 +76,6 @@
Asterisk Serversasterisk.server
- formtree,form{'asterisk_server_main_view': True}
diff --git a/asterisk_click2dial/res_partner_view.xml b/asterisk_click2dial/res_partner_view.xml
index 142ab07..4264da0 100644
--- a/asterisk_click2dial/res_partner_view.xml
+++ b/asterisk_click2dial/res_partner_view.xml
@@ -1,7 +1,7 @@
+
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
diff --git a/asterisk_click2dial/scripts/get_cid_name.py b/asterisk_click2dial/scripts/get_cid_name.py
index b3616cb..44680df 100755
--- a/asterisk_click2dial/scripts/get_cid_name.py
+++ b/asterisk_click2dial/scripts/get_cid_name.py
@@ -3,13 +3,15 @@
"""
CallerID name lookup in OpenERP for Asterisk IPBX
- When executed from the dialplan on an incoming phone call, it will lookup in
- OpenERP's partners, and, if it finds the phone number, it will get the
- corresponding name of the person and use this name as CallerID name for the incoming call.
+ When executed from the dialplan on an incoming phone call, it will
+ lookup in OpenERP's partners and other objects with phone numbers
+ (leads, employees, etc...), and, if it finds the phone number, it will
+ get the corresponding name of the person and use this name as CallerID
+ name for the incoming call.
- Requires the "asterisk_click2dial" module
+ Requires the "base_phone" module
available from https://code.launchpad.net/openerp-asterisk-connector
- for OpenERP version >= 5.0
+ for OpenERP version >= 7.0
This script is designed to be used as an AGI on an Asterisk IPBX...
BUT I advise you to use a wrapper around this script to control the
@@ -19,7 +21,7 @@
The simplest solution I found is to use the "timeout" shell command to
call this script, for example :
- # timeout 1s get_cid_name.py
+ # timeout 2s get_cid_name.py
See my sample wrapper "get_cid_name_timeout.sh"
@@ -41,10 +43,10 @@
"""
__author__ = "Alexis de Lattre "
-__date__ = "December 2010"
-__version__ = "0.3"
+__date__ = "July 2014"
+__version__ = "0.4"
-# Copyright (C) 2010-2012 Alexis de Lattre
+# Copyright (C) 2010-2014 Alexis de Lattre
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -64,7 +66,7 @@ import sys
from optparse import OptionParser
-# CID Name that will be displayed if there is no match in res.partner
+# CID Name that will be displayed if there is no match
# and no geolocalisation
default_cid_name = "Not in OpenERP"
@@ -198,13 +200,13 @@ def main(options, arguments):
if options.notify and arguments:
res = sock.execute(
options.database, options.user, options.password,
- 'res.partner', 'incall_notify_by_login',
+ 'phone.common', 'incall_notify_by_login',
input_cid_number, arguments)
stdout_write('VERBOSE "Calling incall_notify_by_login"\n')
else:
res = sock.execute(
options.database, options.user, options.password,
- 'res.partner', 'get_name_from_phone_number',
+ 'phone.common', 'get_name_from_phone_number',
input_cid_number)
stdout_write('VERBOSE "Calling get_name_from_phone_number"\n')
stdout_write('VERBOSE "End of XML-RPC request on OpenERP"\n')
diff --git a/asterisk_click2dial/security/ir.model.access.csv b/asterisk_click2dial/security/ir.model.access.csv
index 011c2e0..eabc9d1 100644
--- a/asterisk_click2dial/security/ir.model.access.csv
+++ b/asterisk_click2dial/security/ir.model.access.csv
@@ -1,5 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
ir_model_access_asterisk_server_user,Read access on asterisk.server,model_asterisk_server,base.group_user,1,0,0,0
ir_model_access_asterisk_server_system,Full rights on asterisk.server,model_asterisk_server,base.group_system,1,1,1,1
-asterisk_cid_res_partner_read,Read access on res.partner,base.model_res_partner,group_asterisk_cid,1,0,0,0
-asterisk_cid_asterisk_server_read,Read access on asterisk.server,model_asterisk_server,group_asterisk_cid,1,0,0,0
diff --git a/asterisk_click2dial/wizard/open_calling_partner.py b/asterisk_click2dial/wizard/open_calling_partner.py
index 0b9ec97..0dcc742 100644
--- a/asterisk_click2dial/wizard/open_calling_partner.py
+++ b/asterisk_click2dial/wizard/open_calling_partner.py
@@ -57,22 +57,29 @@ class wizard_open_calling_partner(orm.TransientModel):
res['to_update_partner_id'] = False
res['calling_number'] = context.get('incall_number_popup')
else:
- calling_number = self.pool['asterisk.server']._get_calling_number(cr, uid, context=context)
+ calling_number = self.pool['asterisk.server']._get_calling_number(
+ cr, uid, context=context)
#To test the code without Asterisk server
#calling_number = "0141981246"
if calling_number:
res['calling_number'] = calling_number
- partner = self.pool['res.partner'].get_partner_from_phone_number(cr, uid, calling_number, context=context)
- if partner:
- res['partner_id'] = partner[0]
- res['parent_partner_id'] = partner[1]
+ record = self.pool['phone.common'].get_record_from_phone_number(
+ cr, uid, calling_number, context=context)
+ if record and record[0] == 'res.partner':
+ res['partner_id'] = record[1]
+ partner = self.pool['res.partner'].browse(
+ cr, uid, record[1], context=context)
+ res['parent_partner_id'] = \
+ partner.parent_id and partner.parent_id.id or False
else:
res['partner_id'] = False
res['parent_partner_id'] = False
res['to_update_partner_id'] = False
else:
_logger.debug("Could not get the calling number from Asterisk.")
- raise orm.except_orm(_('Error :'), _("Could not get the calling number from Asterisk. Is your phone ringing or are you currently on the phone ? If yes, check your setup and look at the OpenERP debug logs."))
+ raise orm.except_orm(
+ _('Error :'),
+ _("Could not get the calling number from Asterisk. Is your phone ringing or are you currently on the phone ? If yes, check your setup and look at the OpenERP debug logs."))
return res
@@ -98,8 +105,7 @@ class wizard_open_calling_partner(orm.TransientModel):
if partner_id_to_filter:
action = {
'name': oerp_object._description,
- 'view_type': 'form',
- 'view_mode': 'tree,form',
+ 'view_mode': 'tree,form,kanban',
'res_model': oerp_object._name,
'type': 'ir.actions.act_window',
'nodestroy': False, # close the pop-up wizard after action
@@ -126,8 +132,7 @@ class wizard_open_calling_partner(orm.TransientModel):
if record_to_open:
return {
'name': self.pool['res.partner']._description,
- 'view_type': 'form',
- 'view_mode': 'form,tree',
+ 'view_mode': 'form,tree,kanban',
'res_model': 'res.partner',
'type': 'ir.actions.act_window',
'nodestroy': False, # close the pop-up wizard after action
@@ -160,8 +165,7 @@ class wizard_open_calling_partner(orm.TransientModel):
action = {
'name': 'Create new partner',
- 'view_type': 'form',
- 'view_mode': 'form,tree',
+ 'view_mode': 'form,tree,kanban',
'res_model': 'res.partner',
'type': 'ir.actions.act_window',
'nodestroy': False,
@@ -188,8 +192,7 @@ class wizard_open_calling_partner(orm.TransientModel):
self.pool['res.partner'].write(cr, uid, cur_wizard.to_update_partner_id.id, {phone_type: number_to_write}, context=context)
action = {
'name': 'Partner: ' + cur_wizard.to_update_partner_id.name,
- 'view_type': 'form',
- 'view_mode': 'form,tree',
+ 'view_mode': 'form,tree,kanban',
'res_model': 'res.partner',
'type': 'ir.actions.act_window',
'nodestroy': False,
diff --git a/asterisk_click2dial_crm/__openerp__.py b/asterisk_click2dial_crm/__openerp__.py
index 87a3e90..f8ea05d 100644
--- a/asterisk_click2dial_crm/__openerp__.py
+++ b/asterisk_click2dial_crm/__openerp__.py
@@ -28,7 +28,7 @@
"author": "Zikzakmedia SL, Akretion",
"website": "http://www.zikzakmedia.com",
"license": "AGPL-3",
- "category": "Customer Relationship Management",
+ "category": "Phone",
"description": """
Asterisk Click2dial CRM
=======================
@@ -47,7 +47,7 @@ A detailed documentation for the OpenERP-Asterisk connector is available on the
""",
"depends": [
'asterisk_click2dial',
- 'crm',
+ 'crm_phone',
],
"demo": [],
"data": [
@@ -55,7 +55,6 @@ A detailed documentation for the OpenERP-Asterisk connector is available on the
'wizard/create_crm_phonecall_view.xml',
'res_users_view.xml',
'crm_lead_view.xml',
- 'crm_phonecall_view.xml',
],
"installable": True,
"application": True,
diff --git a/asterisk_click2dial_crm/asterisk_click2dial_crm.py b/asterisk_click2dial_crm/asterisk_click2dial_crm.py
index e531956..bf1ff05 100644
--- a/asterisk_click2dial_crm/asterisk_click2dial_crm.py
+++ b/asterisk_click2dial_crm/asterisk_click2dial_crm.py
@@ -71,20 +71,3 @@ class res_users(orm.Model):
_defaults = {
'context_propose_creation_crm_call': True,
}
-
-
-class crm_lead(orm.Model):
- _name = 'crm.lead'
- _inherit = ['crm.lead', 'phone.common']
-
- def create(self, cr, uid, vals, context=None):
- vals_reformated = self._generic_reformat_phonenumbers(
- cr, uid, vals, context=context)
- return super(crm_lead, self).create(
- cr, uid, vals_reformated, context=context)
-
- def write(self, cr, uid, ids, vals, context=None):
- vals_reformated = self._generic_reformat_phonenumbers(
- cr, uid, vals, context=context)
- return super(crm_lead, self).write(
- cr, uid, ids, vals_reformated, context=context)
diff --git a/asterisk_click2dial_crm/crm_lead_view.xml b/asterisk_click2dial_crm/crm_lead_view.xml
index 6fb50df..799b112 100644
--- a/asterisk_click2dial_crm/crm_lead_view.xml
+++ b/asterisk_click2dial_crm/crm_lead_view.xml
@@ -29,9 +29,6 @@
-
- fax
-
@@ -53,9 +50,6 @@
-
- fax
-
diff --git a/asterisk_click2dial_crm/res_users_view.xml b/asterisk_click2dial_crm/res_users_view.xml
index a227405..fa9641c 100644
--- a/asterisk_click2dial_crm/res_users_view.xml
+++ b/asterisk_click2dial_crm/res_users_view.xml
@@ -1,6 +1,6 @@
@@ -9,27 +9,28 @@
-
- asterisk.crm.option.view
+
+ asterisk.crm.res.users.formres.users
-
+
-
+
+
-
+
-
+asterisk.crm.preferences.option.viewres.users
-
+
-
+
-
- Telephony Preferences
+
+ 0
diff --git a/asterisk_click2dial_crm/wizard/__init__.py b/asterisk_click2dial_crm/wizard/__init__.py
index aee3787..9f6c118 100644
--- a/asterisk_click2dial_crm/wizard/__init__.py
+++ b/asterisk_click2dial_crm/wizard/__init__.py
@@ -21,4 +21,3 @@
##############################################################################
from . import create_crm_phonecall
-from . import reformat_all_phonenumbers
diff --git a/asterisk_click2dial_crm/wizard/create_crm_phonecall_view.xml b/asterisk_click2dial_crm/wizard/create_crm_phonecall_view.xml
index 262c80c..b01df45 100644
--- a/asterisk_click2dial_crm/wizard/create_crm_phonecall_view.xml
+++ b/asterisk_click2dial_crm/wizard/create_crm_phonecall_view.xml
@@ -27,7 +27,6 @@
Create CRM phonecallwizard.create.crm.phonecall
- formformnew
diff --git a/asterisk_click2dial_crm/wizard/reformat_all_phonenumbers.py b/asterisk_click2dial_crm/wizard/reformat_all_phonenumbers.py
deleted file mode 100644
index 4dd501f..0000000
--- a/asterisk_click2dial_crm/wizard/reformat_all_phonenumbers.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# Asterisk click2dial CRM module for OpenERP
-# Copyright (c) 2013-2014 Akretion (http://www.akretion.com)
-# @author: Alexis de Lattre
-#
-# 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 .
-#
-##############################################################################
-
-from openerp.osv import orm
-
-
-class reformat_all_phonenumbers(orm.TransientModel):
- _inherit = "reformat.all.phonenumbers"
-
- def _extend_reformat_phonenumbers(self, cr, uid, context=None):
- res = super(
- reformat_all_phonenumbers, self)._extend_reformat_phonenumbers(
- cr, uid, context=context)
- res[self.pool['crm.lead']] = {
- 'allids': self.pool['crm.lead'].search(
- cr, uid, [], context=context),
- 'phonefields': ['phone', 'fax', 'mobile'],
- 'namefield': 'partner_name',
- }
- return res
diff --git a/asterisk_click2dial_crm_claim/__init__.py b/asterisk_click2dial_crm_claim/__init__.py
index 616717a..b76eb75 100644
--- a/asterisk_click2dial_crm_claim/__init__.py
+++ b/asterisk_click2dial_crm_claim/__init__.py
@@ -21,4 +21,3 @@
##############################################################################
from . import wizard
-from . import asterisk_click2dial_crm_claim
diff --git a/asterisk_click2dial_crm_claim/__openerp__.py b/asterisk_click2dial_crm_claim/__openerp__.py
index c2dcb67..979e94b 100644
--- a/asterisk_click2dial_crm_claim/__openerp__.py
+++ b/asterisk_click2dial_crm_claim/__openerp__.py
@@ -27,7 +27,7 @@
"author": "Akretion",
"website": "http://www.akretion.com",
"license" : "AGPL-3",
- "category": "Customer Relationship Management",
+ "category": "Phone",
"description": """
This module adds a button "Open Related CRM Claims" on the "Open calling partner" wizard and a "Dial" button on the CRM Claim form.
@@ -35,7 +35,7 @@
""",
"depends": [
'asterisk_click2dial',
- 'crm_claim',
+ 'crm_claim_phone',
],
"demo": [],
"data": [
diff --git a/asterisk_click2dial_crm_claim/crm_claim_view.xml b/asterisk_click2dial_crm_claim/crm_claim_view.xml
index ec7740e..9003341 100644
--- a/asterisk_click2dial_crm_claim/crm_claim_view.xml
+++ b/asterisk_click2dial_crm_claim/crm_claim_view.xml
@@ -14,11 +14,11 @@
asterisk.crm_claim.form.dialcrm.claim
-
+
-
+
diff --git a/asterisk_click2dial_crm_claim/wizard/__init__.py b/asterisk_click2dial_crm_claim/wizard/__init__.py
index 98a0a3c..d93f417 100644
--- a/asterisk_click2dial_crm_claim/wizard/__init__.py
+++ b/asterisk_click2dial_crm_claim/wizard/__init__.py
@@ -21,4 +21,3 @@
##############################################################################
from . import open_calling_partner
-from . import reformat_all_phonenumbers
diff --git a/asterisk_click2dial_crm_claim/wizard/open_calling_partner.py b/asterisk_click2dial_crm_claim/wizard/open_calling_partner.py
index dd01a0a..aa7559c 100644
--- a/asterisk_click2dial_crm_claim/wizard/open_calling_partner.py
+++ b/asterisk_click2dial_crm_claim/wizard/open_calling_partner.py
@@ -29,4 +29,4 @@ class wizard_open_calling_partner(orm.TransientModel):
def open_crm_claims(self, cr, uid, ids, context=None):
'''Function called by the related button of the wizard'''
return self.open_filtered_object(
- cr, uid, ids, self.pool.get('crm.claim'), context=context)
+ cr, uid, ids, self.pool['crm.claim'], context=context)
diff --git a/asterisk_click2dial_crm_claim/wizard/reformat_all_phonenumbers.py b/asterisk_click2dial_crm_claim/wizard/reformat_all_phonenumbers.py
deleted file mode 100644
index 61e8ae8..0000000
--- a/asterisk_click2dial_crm_claim/wizard/reformat_all_phonenumbers.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# -*- encoding: utf-8 -*-
-##############################################################################
-#
-# Asterisk click2dial CRM Claim module for OpenERP
-# Copyright (c) 2013-2014 Akretion (http://www.akretion.com)
-# @author: Alexis de Lattre
-#
-# 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 .
-#
-##############################################################################
-
-from openerp.osv import orm
-
-
-class reformat_all_phonenumbers(orm.TransientModel):
- _inherit = "reformat.all.phonenumbers"
-
- def _extend_reformat_phonenumbers(self, cr, uid, context=None):
- res = super(
- reformat_all_phonenumbers, self)._extend_reformat_phonenumbers(
- cr, uid, context=context)
- res[self.pool['crm.claim']] = {
- 'allids': self.pool['crm.claim'].search(
- cr, uid, [], context=context),
- 'phonefields': ['partner_phone'],
- 'namefield': 'name',
- }
- return res
diff --git a/asterisk_click2dial_registration/__init__.py b/asterisk_click2dial_event/__init__.py
similarity index 95%
rename from asterisk_click2dial_registration/__init__.py
rename to asterisk_click2dial_event/__init__.py
index a7829e9..cca301f 100644
--- a/asterisk_click2dial_registration/__init__.py
+++ b/asterisk_click2dial_event/__init__.py
@@ -20,4 +20,3 @@
##############################################################################
from . import wizard
-from . import asterisk_click2dial_registration
diff --git a/asterisk_click2dial_registration/__openerp__.py b/asterisk_click2dial_event/__openerp__.py
similarity index 97%
rename from asterisk_click2dial_registration/__openerp__.py
rename to asterisk_click2dial_event/__openerp__.py
index b73dd4c..f293d15 100644
--- a/asterisk_click2dial_registration/__openerp__.py
+++ b/asterisk_click2dial_event/__openerp__.py
@@ -25,7 +25,7 @@
"author": "INVITU",
"website": "http://www.invitu.com",
"license": "AGPL-3",
- "category": "Extra Tools",
+ "category": "Phone",
"description": """
This module adds a button "Open Registrations" on the "Open calling partner" wizard and a "Dial" button on the Registration form.
@@ -33,7 +33,7 @@
""",
"depends": [
'asterisk_click2dial',
- 'event',
+ 'event_phone',
],
"demo": [],
"data": [
diff --git a/asterisk_click2dial_registration/asterisk_click2dial_registration.py b/asterisk_click2dial_event/asterisk_click2dial_registration.py
similarity index 100%
rename from asterisk_click2dial_registration/asterisk_click2dial_registration.py
rename to asterisk_click2dial_event/asterisk_click2dial_registration.py
diff --git a/asterisk_click2dial_registration/registration_view.xml b/asterisk_click2dial_event/registration_view.xml
similarity index 67%
rename from asterisk_click2dial_registration/registration_view.xml
rename to asterisk_click2dial_event/registration_view.xml
index be23692..3191e2f 100644
--- a/asterisk_click2dial_registration/registration_view.xml
+++ b/asterisk_click2dial_event/registration_view.xml
@@ -11,10 +11,10 @@
-
+asterisk.event.registration.form.dialevent.registration
-
+
@@ -25,24 +25,16 @@
-
+asterisk.event.form.registration.tree.dialevent.event
-
+
-
+
-
-
-
-
- asterisk.event.form.registration.form.dial
- event.event
-
-
-
+
diff --git a/asterisk_click2dial_registration/wizard/__init__.py b/asterisk_click2dial_event/wizard/__init__.py
similarity index 100%
rename from asterisk_click2dial_registration/wizard/__init__.py
rename to asterisk_click2dial_event/wizard/__init__.py
diff --git a/asterisk_click2dial_registration/wizard/open_calling_partner.py b/asterisk_click2dial_event/wizard/open_calling_partner.py
similarity index 94%
rename from asterisk_click2dial_registration/wizard/open_calling_partner.py
rename to asterisk_click2dial_event/wizard/open_calling_partner.py
index 7a17dcb..33f15ba 100644
--- a/asterisk_click2dial_registration/wizard/open_calling_partner.py
+++ b/asterisk_click2dial_event/wizard/open_calling_partner.py
@@ -28,4 +28,4 @@ class wizard_open_calling_partner(orm.TransientModel):
def open_registrations(self, cr, uid, ids, context=None):
'''Function called by the related button of the wizard'''
return self.open_filtered_object(
- cr, uid, ids, self.pool.get('event.registration'), context=context)
+ cr, uid, ids, self.pool['event.registration'], context=context)
diff --git a/asterisk_click2dial_registration/wizard/open_calling_partner_view.xml b/asterisk_click2dial_event/wizard/open_calling_partner_view.xml
similarity index 100%
rename from asterisk_click2dial_registration/wizard/open_calling_partner_view.xml
rename to asterisk_click2dial_event/wizard/open_calling_partner_view.xml
diff --git a/asterisk_popup/res_users_view.xml b/asterisk_popup/res_users_view.xml
deleted file mode 100644
index 0b9eb8f..0000000
--- a/asterisk_popup/res_users_view.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
- asterisk.popup.res.users.form
- res.users
-
-
-
-
-
-
-
-
-
- asterisk.popup.preferences.view
- res.users
-
-
-
-
-
-
- Telephony Preferences
-
-
-
-
-
-
diff --git a/base_phone/__init__.py b/base_phone/__init__.py
index e140e96..7a4f039 100644
--- a/base_phone/__init__.py
+++ b/base_phone/__init__.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
-# Base Module module for OpenERP
+# Base Phone module for OpenERP
# Copyright (C) 2014 Alexis de Lattre
#
# This program is free software: you can redistribute it and/or modify
diff --git a/base_phone/__openerp__.py b/base_phone/__openerp__.py
index 5a6ee2d..ba0eac0 100644
--- a/base_phone/__openerp__.py
+++ b/base_phone/__openerp__.py
@@ -23,7 +23,7 @@
{
'name': 'Base Phone',
'version': '0.1',
- 'category': 'Extra Tools',
+ 'category': 'Phone',
'license': 'AGPL-3',
'summary': 'Validate phone numbers',
'description': """
@@ -53,7 +53,11 @@ Please contact Alexis de Lattre from Akretion for
'depends': ['base'],
'external_dependencies': {'python': ['phonenumbers']},
'data': [
+ 'security/phone_security.xml',
+ 'security/ir.model.access.csv',
'res_partner_view.xml',
+ 'res_company_view.xml',
+ 'res_users_view.xml',
'wizard/reformat_all_phonenumbers_view.xml',
],
'js': [
diff --git a/base_phone/base_phone.py b/base_phone/base_phone.py
index 6d484f6..a026c4e 100644
--- a/base_phone/base_phone.py
+++ b/base_phone/base_phone.py
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
-# Base Phone module for OpenERP
+# Base Phone module for Odoo/OpenERP
# Copyright (C) 2010-2014 Alexis de Lattre
#
# This program is free software: you can redistribute it and/or modify
@@ -19,7 +19,7 @@
#
##############################################################################
-from openerp.osv import orm
+from openerp.osv import orm, fields
from openerp.tools.translate import _
import logging
# Lib for phone number reformating -> pip install phonenumbers
@@ -62,7 +62,10 @@ class phone_common(orm.AbstractModel):
def _generic_reformat_phonenumbers(
self, cr, uid, vals,
- phonefields=['phone', 'partner_phone', 'fax', 'mobile'],
+ phonefields=[
+ 'phone', 'partner_phone', 'work_phone', 'fax',
+ 'mobile', 'partner_mobile', 'mobile_phone',
+ ],
context=None):
"""Reformat phone numbers in E.164 format i.e. +33141981242"""
if any([vals.get(field) for field in phonefields]):
@@ -100,6 +103,103 @@ class phone_common(orm.AbstractModel):
% (field, init_value, vals[field]))
return vals
+ def get_name_from_phone_number(
+ self, cr, uid, presented_number, context=None):
+ '''Function to get name from phone number. Usefull for use from IPBX
+ to add CallerID name to incoming calls.'''
+ res = self.get_record_from_phone_number(
+ cr, uid, presented_number, context=context)
+ if res:
+ return res[2]
+ else:
+ return False
+
+ def get_record_from_phone_number(
+ self, cr, uid, presented_number, context=None):
+ '''If it finds something, it returns (object name, ID, record name)
+ For example : ('res.partner', 42, u'Alexis de Lattre (Akretion)')
+ '''
+ if context is None:
+ context = {}
+ ctx_phone = context.copy()
+ ctx_phone['callerid'] = True
+ _logger.debug(
+ u"Call get_name_from_phone_number with number = %s"
+ % presented_number)
+ if not isinstance(presented_number, (str, unicode)):
+ _logger.warning(
+ u"Number '%s' should be a 'str' or 'unicode' but it is a '%s'"
+ % (presented_number, type(presented_number)))
+ return False
+ if not presented_number.isdigit():
+ _logger.warning(
+ u"Number '%s' should only contain digits." % presented_number)
+
+ user = self.pool['res.users'].browse(cr, uid, uid, context=context)
+ nr_digits_to_match_from_end = \
+ user.company_id.number_of_digits_to_match_from_end
+ if len(presented_number) >= nr_digits_to_match_from_end:
+ end_number_to_match = presented_number[
+ -nr_digits_to_match_from_end:len(presented_number)]
+ else:
+ end_number_to_match = presented_number
+
+ phonefieldsdict = self._get_phone_fields(cr, uid, context=context)
+ phonefieldslist = []
+ for objname, prop in phonefieldsdict.iteritems():
+ if prop.get('get_name_sequence'):
+ phonefieldslist.append({objname: prop})
+ phonefieldslist_sorted = sorted(
+ phonefieldslist,
+ key=lambda element: element.values()[0]['get_name_sequence'])
+
+ for phonedict in phonefieldslist_sorted:
+ objname = phonedict.keys()[0]
+ prop = phonedict.values()[0]
+ phonefields = prop['phonefields']
+ obj = self.pool[objname]
+ pg_search_number = str('%' + end_number_to_match)
+ _logger.debug(
+ "Will search phone and mobile numbers in %s ending with '%s'"
+ % (objname, end_number_to_match))
+ domain = []
+ for phonefield in phonefields:
+ domain.append((phonefield, 'like', pg_search_number))
+ if len(phonefields) > 1:
+ domain = ['|'] * (len(phonefields) - 1) + domain
+ res_ids = obj.search(cr, uid, domain, context=context)
+ if len(res_ids) > 1:
+ _logger.warning(
+ u"There are several %s (IDS = %s) with a phone number "
+ "ending with '%s'. Taking the first one."
+ % (objname, res_ids, end_number_to_match))
+ if res_ids:
+ name = obj.name_get(
+ cr, uid, res_ids[0], context=ctx_phone)[0][1]
+ res = (objname, res_ids[0], name)
+ print "res=", res
+ _logger.debug(
+ u"Answer get_record_from_phone_number: (%s, %d, %s)"
+ % (res[0], res[1], res[2]))
+ return res
+ else:
+ _logger.debug(
+ u"No match on %s for end of phone number '%s'"
+ % (objname, end_number_to_match))
+ return False
+
+ def _get_phone_fields(self, cr, uid, context=None):
+ '''Returns a dict with key = object name
+ and value = list of phone fields'''
+ res = {
+ 'res.partner': {
+ 'phonefields': ['phone', 'mobile'],
+ 'faxfields': ['fax'],
+ 'get_name_sequence': 10,
+ },
+ }
+ return res
+
class res_partner(orm.Model):
_name = 'res.partner'
@@ -116,3 +216,50 @@ class res_partner(orm.Model):
cr, uid, vals, context=context)
return super(res_partner, self).write(
cr, uid, ids, vals_reformated, context=context)
+
+ def name_get(self, cr, uid, ids, context=None):
+ if context is None:
+ context = {}
+ if context.get('callerid'):
+ res = []
+ if isinstance(ids, (int, long)):
+ ids = [ids]
+ for partner in self.browse(cr, uid, ids, context=context):
+ if partner.parent_id and partner.parent_id.is_company:
+ name = u'%s (%s)' % (partner.name, partner.parent_id.name)
+ else:
+ name = partner.name
+ res.append((partner.id, name))
+ return res
+ else:
+ return super(res_partner, self).name_get(
+ cr, uid, ids, context=context)
+
+
+class res_company(orm.Model):
+ _inherit = 'res.company'
+
+ _columns = {
+ 'number_of_digits_to_match_from_end': fields.integer(
+ 'Number of Digits To Match From End',
+ help="In several situations, OpenERP will have to find a "
+ "Partner/Lead/Employee/... from a phone number presented by the "
+ "calling party. As the phone numbers presented by your phone "
+ "operator may not always be displayed in a standard format, "
+ "the best method to find the related Partner/Lead/Employee/... "
+ "in OpenERP is to try to match the end of the phone number in "
+ "OpenERP with the N last digits of the phone number presented "
+ "by the calling party. N is the value you should enter in this "
+ "field."),
+ }
+
+ _defaults = {
+ 'number_of_digits_to_match_from_end': 8,
+ }
+
+ _sql_constraints = [(
+ 'number_of_digits_to_match_from_end_positive',
+ 'CHECK (number_of_digits_to_match_from_end > 0)',
+ "The value of the field 'Number of Digits To Match From End' must "
+ "be positive."),
+ ]
diff --git a/base_phone/res_company_view.xml b/base_phone/res_company_view.xml
new file mode 100644
index 0000000..fa3cf59
--- /dev/null
+++ b/base_phone/res_company_view.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+ base_phone.company.form
+ res.company
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/base_phone/res_users_view.xml b/base_phone/res_users_view.xml
new file mode 100644
index 0000000..99b64c9
--- /dev/null
+++ b/base_phone/res_users_view.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+ base_phone.res.users.telephony_tab
+ res.users
+
+
+
+
+
+
+
+
+
+
+
+
+
+ base_phone.user_preferences.view
+ res.users
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/base_phone/security/ir.model.access.csv b/base_phone/security/ir.model.access.csv
new file mode 100644
index 0000000..7593348
--- /dev/null
+++ b/base_phone/security/ir.model.access.csv
@@ -0,0 +1,2 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+callerid_res_partner_read,Read access on res.partner,base.model_res_partner,group_callerid,1,0,0,0
diff --git a/asterisk_click2dial/security/asterisk_server_security.xml b/base_phone/security/phone_security.xml
similarity index 52%
rename from asterisk_click2dial/security/asterisk_server_security.xml
rename to base_phone/security/phone_security.xml
index f8db4f4..627bdad 100644
--- a/asterisk_click2dial/security/asterisk_server_security.xml
+++ b/base_phone/security/phone_security.xml
@@ -1,7 +1,7 @@
@@ -9,8 +9,8 @@
-
- Asterisk CallerID
+
+ Phone CallerID
diff --git a/base_phone/wizard/reformat_all_phonenumbers.py b/base_phone/wizard/reformat_all_phonenumbers.py
index 2d19189..8546d35 100644
--- a/base_phone/wizard/reformat_all_phonenumbers.py
+++ b/base_phone/wizard/reformat_all_phonenumbers.py
@@ -22,7 +22,7 @@
from openerp.osv import orm, fields
import logging
-_logger = logging.getLogger(__name__)
+logger = logging.getLogger(__name__)
class reformat_all_phonenumbers(orm.TransientModel):
@@ -34,33 +34,33 @@ class reformat_all_phonenumbers(orm.TransientModel):
"Phone numbers that couldn't be reformatted"),
}
- def _extend_reformat_phonenumbers(self, cr, uid, context=None):
- '''This function is designed to be inherited
- to extend the functionnality to objects other than res.partner'''
- res = {
- self.pool['res.partner']: {
- 'allids': self.pool['res.partner'].search(
- cr, uid, [
- '|',
- ('active', '=', True),
- ('active', '=', False)
- ], context=context),
- 'phonefields': ['phone', 'fax', 'mobile'],
- 'namefield': 'name',
- }
- }
- return res
-
def run_reformat_all_phonenumbers(self, cr, uid, ids, context=None):
- _logger.info('Starting to reformat all the phone numbers')
+ logger.info('Starting to reformat all the phone numbers')
phonenumbers_not_reformatted = ''
- toreformat_dict = self._extend_reformat_phonenumbers(
+ toreformat_dict = self.pool['phone.common']._get_phone_fields(
cr, uid, context=context)
- for obj, prop in toreformat_dict.items():
+ for objname, prop in toreformat_dict.iteritems():
+ fields = []
+ obj = self.pool[objname]
+ if prop.get('phonefields'):
+ fields += prop['phonefields']
+ if prop.get('faxfields'):
+ fields += prop['faxfields']
+ logger.info(
+ 'Starting to reformat phone numbers on object %s '
+ '(fields = %s)' % (objname, fields))
+ # search if this object has an 'active' field
+ if obj._columns.get('active') or objname == 'hr.employee':
+ # hr.employee inherits from 'resource.resource' and
+ # 'resource.resource' has an active field
+ # As I don't know how to detect such cases, I hardcode it here
+ # If you know a better solution, please tell me
+ domain = ['|', ('active', '=', True), ('active', '=', False)]
+ else:
+ domain = []
+ all_ids = obj.search(cr, uid, domain, context=context)
for entry in obj.read(
- cr, uid, prop['allids'],
- [prop['namefield']] + prop['phonefields'],
- context=context):
+ cr, uid, all_ids, fields, context=context):
init_entry = entry.copy()
# entry is _updated_ by the fonction
# _generic_reformat_phonenumbers()
@@ -68,22 +68,23 @@ class reformat_all_phonenumbers(orm.TransientModel):
obj._generic_reformat_phonenumbers(
cr, uid, entry, context=context)
except Exception, e:
+ name = obj.name_get(
+ cr, uid, [init_entry['id']], context=context)[0][1]
phonenumbers_not_reformatted += \
"Problem on %s '%s'. Error message: %s\n" % (
obj._description,
- init_entry.get(prop['namefield']), e[1])
- _logger.warning(
+ name, e[1])
+ logger.warning(
"Problem on %s '%s'. Error message: %s" % (
obj._description,
- init_entry.get(prop['namefield']), e[1]))
+ name, e[1]))
continue
if any(
[init_entry.get(field)
!= entry.get(field) for field
- in prop['phonefields']]):
+ in fields]):
entry.pop('id')
- entry.pop(prop['namefield'])
- _logger.info(
+ logger.info(
'[%s] Reformating phone number: FROM %s TO %s' % (
obj._description, unicode(init_entry),
unicode(entry)))
@@ -96,5 +97,5 @@ class reformat_all_phonenumbers(orm.TransientModel):
cr, uid, ids[0],
{'phonenumbers_not_reformatted': phonenumbers_not_reformatted},
context=context)
- _logger.info('End of the phone number reformatting wizard')
+ logger.info('End of the phone number reformatting wizard')
return True
diff --git a/base_phone/wizard/reformat_all_phonenumbers_view.xml b/base_phone/wizard/reformat_all_phonenumbers_view.xml
index 9a029e7..66f1e79 100644
--- a/base_phone/wizard/reformat_all_phonenumbers_view.xml
+++ b/base_phone/wizard/reformat_all_phonenumbers_view.xml
@@ -14,17 +14,15 @@
@@ -32,7 +30,6 @@
Reformat Phone Numbersreformat.all.phonenumbers
- formformnew
diff --git a/asterisk_popup/__init__.py b/base_phone_popup/__init__.py
similarity index 95%
rename from asterisk_popup/__init__.py
rename to base_phone_popup/__init__.py
index 09972ec..b9cf425 100644
--- a/asterisk_popup/__init__.py
+++ b/base_phone_popup/__init__.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
-# Asterisk Pop-up module for OpenERP
+# Base Phone Pop-up module for Odoo/OpenERP
# Copyright (C) 2014 Alexis de Lattre
#
# This program is free software: you can redistribute it and/or modify
diff --git a/asterisk_popup/__openerp__.py b/base_phone_popup/__openerp__.py
similarity index 80%
rename from asterisk_popup/__openerp__.py
rename to base_phone_popup/__openerp__.py
index 5d7d7a3..ce93348 100644
--- a/asterisk_popup/__openerp__.py
+++ b/base_phone_popup/__openerp__.py
@@ -1,7 +1,7 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
-# Asterisk Pop-up module for OpenERP
+# Base Phone Pop-up module for Odoo/OpenERP
# Copyright (C) 2014 Alexis de Lattre
#
# This program is free software: you can redistribute it and/or modify
@@ -21,16 +21,16 @@
{
- 'name': 'Asterisk Pop-up',
+ 'name': 'Base Phone Pop-up',
'version': '0.4',
- 'category': 'Extra Tools',
+ 'category': 'Phone',
'license': 'AGPL-3',
- 'summary': 'Pop-up the Partner to the User on Incoming Calls',
+ 'summary': 'Pop-up the related form view to the user on incoming calls',
'description': """
-Asterisk-OpenERP Connector: Display Pop-up to User on Incoming Calls
-====================================================================
+Base Phone Pop-up
+=================
-When the user receives a phone call, OpenERP can automatically open the corresponding partner in a pop-up without any action from the user.
+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:
@@ -47,11 +47,10 @@ Warning : proxying WebSockets is only supported since Nginx 1.3.13 ; the feature
TODO : document this new feature on the Akretion Web site : http://www.akretion.com/en/products-and-services/openerp-asterisk-voip-connector """,
'author': 'Akretion',
'website': 'http://www.akretion.com/',
- 'depends': ['asterisk_click2dial', 'web_action_request'],
+ 'depends': ['base_phone', 'web_action_request'],
'data': [
'res_users_view.xml',
],
- 'demo': [],
'images': [],
'active': False,
}
diff --git a/asterisk_popup/i18n/asterisk_popup.pot b/base_phone_popup/i18n/asterisk_popup.pot
similarity index 100%
rename from asterisk_popup/i18n/asterisk_popup.pot
rename to base_phone_popup/i18n/asterisk_popup.pot
diff --git a/asterisk_popup/i18n/fr.po b/base_phone_popup/i18n/fr.po
similarity index 100%
rename from asterisk_popup/i18n/fr.po
rename to base_phone_popup/i18n/fr.po
diff --git a/asterisk_popup/popup.py b/base_phone_popup/popup.py
similarity index 75%
rename from asterisk_popup/popup.py
rename to base_phone_popup/popup.py
index 1ce3a45..0ac4556 100644
--- a/asterisk_popup/popup.py
+++ b/base_phone_popup/popup.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
##############################################################################
#
-# Asterisk Pop-up module for OpenERP
+# Base Phone Pop-up module for Odoo/OpenERP
# Copyright (C) 2014 Alexis de Lattre
#
# This program is free software: you can redistribute it and/or modify
@@ -22,40 +22,33 @@
from openerp.osv import orm, fields
import logging
+
logger = logging.getLogger(__name__)
-class res_partner(orm.Model):
- _inherit = 'res.partner'
+class phone_common(orm.AbstractModel):
+ _inherit = 'phone.common'
def _prepare_incall_pop_action(
- self, cr, uid, partner_res, number, context=None):
- if partner_res:
- action = {
- 'name': 'Partner',
- 'type': 'ir.actions.act_window',
- 'res_model': 'res.partner',
- 'view_mode': 'form,tree,kanban',
- 'views': [[False, 'form']], # Beurk, but needed
- 'target': 'new',
- 'res_id': partner_res[0],
- }
- else:
+ self, cr, uid, record_res, number, context=None):
+ action = False
+ if record_res:
+ obj = self.pool[record_res[0]]
action = {
- 'name': 'No Partner Found',
+ 'name': obj._description,
'type': 'ir.actions.act_window',
- 'res_model': 'wizard.open.calling.partner',
- 'view_mode': 'form',
+ 'res_model': record_res[0],
+ 'view_mode': 'form,tree',
'views': [[False, 'form']], # Beurk, but needed
'target': 'new',
- 'context': {'incall_number_popup': number}
+ 'res_id': record_res[1],
}
return action
def incall_notify_by_login(
self, cr, uid, number, login_list, context=None):
assert isinstance(login_list, list), 'login_list must be a list'
- res = self.get_partner_from_phone_number(
+ 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)
@@ -74,7 +67,11 @@ class res_partner(orm.Model):
logger.debug(
'This action has been sent to user ID %d: %s'
% (user['id'], action))
- return res
+ if res:
+ callerid = res[2]
+ else:
+ callerid = False
+ return callerid
class res_users(orm.Model):
diff --git a/base_phone_popup/res_users_view.xml b/base_phone_popup/res_users_view.xml
new file mode 100644
index 0000000..e215c15
--- /dev/null
+++ b/base_phone_popup/res_users_view.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+ base_phone_popup.res.users.form
+ res.users
+
+
+
+ 0
+
+
+
+
+
+
+
+
+ base_phone_popup.users.preferences.view
+ res.users
+
+
+
+
+
+
+ 0
+
+
+
+
+
+
diff --git a/crm_claim_phone/__init__.py b/crm_claim_phone/__init__.py
new file mode 100644
index 0000000..00c33a5
--- /dev/null
+++ b/crm_claim_phone/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# CRM Claim Phone module for Odoo/OpenERP
+# Copyright (C) 2014 Alexis de Lattre
+#
+# 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 .
+#
+##############################################################################
+
+from . import crm_claim_phone
diff --git a/crm_claim_phone/__openerp__.py b/crm_claim_phone/__openerp__.py
new file mode 100644
index 0000000..b79a5f8
--- /dev/null
+++ b/crm_claim_phone/__openerp__.py
@@ -0,0 +1,46 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# CRM Claim Phone module for Odoo/OpenERP
+# Copyright (C) 2014 Alexis de Lattre
+#
+# 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 .
+#
+##############################################################################
+
+
+{
+ 'name': 'CRM Claim Phone',
+ 'version': '0.1',
+ 'category': 'Phone',
+ 'license': 'AGPL-3',
+ 'summary': 'Validate phone numbers in CRM Claims',
+ 'description': """
+CRM Claims Phone
+================
+
+This module validate phone numbers in the CRM Claim module, just like the *base_phone* module valide phone numbers in the Partner form. Please refer to the description of the *base_phone* module for more information.
+
+This module is independant from the Asterisk connector.
+
+Please contact Alexis de Lattre from Akretion for any help or question about this module.
+""",
+ 'author': 'Akretion',
+ 'website': 'http://www.akretion.com/',
+ 'depends': ['base_phone', 'crm_claim'],
+ 'data': ['crm_claim_view.xml'],
+ 'images': [],
+ 'installable': True,
+ 'active': False,
+}
diff --git a/asterisk_click2dial_crm_claim/asterisk_click2dial_crm_claim.py b/crm_claim_phone/crm_claim_phone.py
similarity index 61%
rename from asterisk_click2dial_crm_claim/asterisk_click2dial_crm_claim.py
rename to crm_claim_phone/crm_claim_phone.py
index dac0549..a9996ef 100644
--- a/asterisk_click2dial_crm_claim/asterisk_click2dial_crm_claim.py
+++ b/crm_claim_phone/crm_claim_phone.py
@@ -1,8 +1,9 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
-# Asterisk click2dial CRM Claim module for OpenERP
-# Copyright (C) 2013 Invitu
+# CRM Claim Phone module for Odoo/OpenERP
+# Copyright (c) 2012-2014 Akretion (http://www.akretion.com)
+# @author: Alexis de Lattre
#
# 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
@@ -19,33 +20,13 @@
#
##############################################################################
-from openerp.osv import orm, fields
+from openerp.osv import orm
class crm_claim(orm.Model):
_name = 'crm.claim'
_inherit = ['crm.claim', 'phone.common']
- def format_phonenumber_to_e164(
- self, cr, uid, ids, name, arg, context=None):
- return self.generic_phonenumber_to_e164(
- cr, uid, ids, [('partner_phone', 'partner_phone_e164')],
- context=context)
-
- _columns = {
- # Note : even if we only have 1 field, we keep multi='..'
- # because the generic function generic_phonenumber_to_e164() is
- # designed to return the result as multi
- 'partner_phone_e164': fields.function(
- format_phonenumber_to_e164, type='char', size=64,
- string='Phone in E.164 format', readonly=True, multi='e164claim',
- store={
- 'crm.claim': (
- lambda self, cr, uid, ids, c={}: ids,
- ['partner_phone'], 10),
- }),
- }
-
def create(self, cr, uid, vals, context=None):
vals_reformated = self._generic_reformat_phonenumbers(
cr, uid, vals, context=context)
@@ -57,3 +38,15 @@ class crm_claim(orm.Model):
cr, uid, vals, context=context)
return super(crm_claim, self).write(
cr, uid, ids, vals_reformated, context=context)
+
+
+class phone_common(orm.AbstractModel):
+ _inherit = 'phone.common'
+
+ def _get_phone_fields(self, cr, uid, context=None):
+ res = super(phone_common, self)._get_phone_fields(
+ cr, uid, context=context)
+ res['crm.claim'] = {
+ 'phonefields': ['partner_phone'],
+ }
+ return res
diff --git a/crm_claim_phone/crm_claim_view.xml b/crm_claim_phone/crm_claim_view.xml
new file mode 100644
index 0000000..33e242a
--- /dev/null
+++ b/crm_claim_phone/crm_claim_view.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+ crm_claim_phone.crm_claim.form
+ crm.claim
+
+
+
+ phone
+
+
+
+
+
+
diff --git a/crm_phone/__init__.py b/crm_phone/__init__.py
new file mode 100644
index 0000000..c285235
--- /dev/null
+++ b/crm_phone/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# CRM Phone module for Odoo/OpenERP
+# Copyright (C) 2014 Alexis de Lattre
+#
+# 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 .
+#
+##############################################################################
+
+from . import crm_phone
diff --git a/crm_phone/__openerp__.py b/crm_phone/__openerp__.py
new file mode 100644
index 0000000..cf41044
--- /dev/null
+++ b/crm_phone/__openerp__.py
@@ -0,0 +1,49 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# CRM Phone module for OpenERP
+# Copyright (C) 2014 Alexis de Lattre
+#
+# 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 .
+#
+##############################################################################
+
+
+{
+ 'name': 'CRM Phone',
+ 'version': '0.1',
+ 'category': 'Phone',
+ 'license': 'AGPL-3',
+ 'summary': 'Validate phone numbers in CRM',
+ 'description': """
+CRM Phone
+=========
+
+This module validate phone numbers in the CRM module, just like the *base_phone* module valide phone numbers in the Partner form. Please refer to the description of the *base_phone* module for more information.
+
+This module is independant from the Asterisk connector.
+
+Please contact Alexis de Lattre from Akretion for any help or question about this module.
+""",
+ 'author': 'Akretion',
+ 'website': 'http://www.akretion.com/',
+ 'depends': ['base_phone', 'crm'],
+ 'data': [
+ 'security/ir.model.access.csv',
+ 'crm_view.xml',
+ ],
+ 'images': [],
+ 'installable': True,
+ 'active': False,
+}
diff --git a/crm_phone/crm_phone.py b/crm_phone/crm_phone.py
new file mode 100644
index 0000000..481dfb3
--- /dev/null
+++ b/crm_phone/crm_phone.py
@@ -0,0 +1,98 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# CRM phone module for Odoo/OpenERP
+# Copyright (c) 2012-2014 Akretion (http://www.akretion.com)
+# @author: Alexis de Lattre
+#
+# 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 .
+#
+##############################################################################
+
+from openerp.osv import orm
+
+
+class crm_lead(orm.Model):
+ _name = 'crm.lead'
+ _inherit = ['crm.lead', 'phone.common']
+
+ def create(self, cr, uid, vals, context=None):
+ vals_reformated = self._generic_reformat_phonenumbers(
+ cr, uid, vals, context=context)
+ return super(crm_lead, self).create(
+ cr, uid, vals_reformated, context=context)
+
+ def write(self, cr, uid, ids, vals, context=None):
+ vals_reformated = self._generic_reformat_phonenumbers(
+ cr, uid, vals, context=context)
+ return super(crm_lead, self).write(
+ cr, uid, ids, vals_reformated, context=context)
+
+ def name_get(self, cr, uid, ids, context=None):
+ if context is None:
+ context = {}
+ if context.get('callerid'):
+ res = []
+ if isinstance(ids, (int, long)):
+ ids = [ids]
+ for lead in self.browse(cr, uid, ids, context=context):
+ if lead.partner_name and lead.contact_name:
+ name = u'%s (%s)' % (lead.contact_name, lead.partner_name)
+ elif lead.partner_name:
+ name = lead.partner_name
+ elif lead.contact_name:
+ name = lead.contact_name
+ else:
+ name = lead.name
+ res.append((lead.id, name))
+ return res
+ else:
+ return super(crm_lead, self).name_get(
+ cr, uid, ids, context=context)
+
+
+class crm_phonecall(orm.Model):
+ _name = 'crm.phonecall'
+ _inherit = ['crm.phonecall', 'phone.common']
+
+ def create(self, cr, uid, vals, context=None):
+ vals_reformated = self._generic_reformat_phonenumbers(
+ cr, uid, vals, context=context)
+ return super(crm_phonecall, self).create(
+ cr, uid, vals_reformated, context=context)
+
+ def write(self, cr, uid, ids, vals, context=None):
+ vals_reformated = self._generic_reformat_phonenumbers(
+ cr, uid, vals, context=context)
+ return super(crm_phonecall, self).write(
+ cr, uid, ids, vals_reformated, context=context)
+
+
+class phone_common(orm.AbstractModel):
+ _inherit = 'phone.common'
+
+ def _get_phone_fields(self, cr, uid, context=None):
+ res = super(phone_common, self)._get_phone_fields(
+ cr, uid, context=context)
+ res.update({
+ 'crm.lead': {
+ 'phonefields': ['phone', 'mobile'],
+ 'faxfields': ['fax'],
+ 'get_name_sequence': 20,
+ },
+ 'crm.phonecall': {
+ 'phonefields': ['partner_phone', 'partner_mobile'],
+ },
+ })
+ return res
diff --git a/crm_phone/crm_view.xml b/crm_phone/crm_view.xml
new file mode 100644
index 0000000..c3e8696
--- /dev/null
+++ b/crm_phone/crm_view.xml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+ crm_phone.crm_lead.form
+ crm.lead
+
+
+
+ phone
+
+
+ phone
+
+
+ fax
+
+
+
+
+
+ crm_phone.case.view_opportuniy.form
+ crm.lead
+
+
+
+ phone
+
+
+ phone
+
+
+ fax
+
+
+
+
+
+ crm_phone.crm_phonecall.form
+ crm.phonecall
+
+
+
+ phone
+
+
+ phone
+
+
+
+
+
+
diff --git a/crm_phone/security/ir.model.access.csv b/crm_phone/security/ir.model.access.csv
new file mode 100644
index 0000000..1dbae56
--- /dev/null
+++ b/crm_phone/security/ir.model.access.csv
@@ -0,0 +1,2 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+callerid_crm_lead_read,Read access on crm.lead,crm.model_crm_lead,base_phone.group_callerid,1,0,0,0
diff --git a/event_phone/__init__.py b/event_phone/__init__.py
new file mode 100644
index 0000000..3ab9f89
--- /dev/null
+++ b/event_phone/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Event Phone module for Odoo/OpenERP
+# Copyright (C) 2014 Alexis de Lattre
+#
+# 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 .
+#
+##############################################################################
+
+from . import event_phone
diff --git a/event_phone/__openerp__.py b/event_phone/__openerp__.py
new file mode 100644
index 0000000..943cf1c
--- /dev/null
+++ b/event_phone/__openerp__.py
@@ -0,0 +1,49 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Event Phone module for Odoo/OpenERP
+# Copyright (C) 2014 Alexis de Lattre
+#
+# 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 .
+#
+##############################################################################
+
+
+{
+ 'name': 'Event Phone',
+ 'version': '0.1',
+ 'category': 'Phone',
+ 'license': 'AGPL-3',
+ 'summary': 'Validate phone numbers in Events',
+ 'description': """
+Event Phone
+===========
+
+This module validate phone numbers in the Event module, just like the *base_phone* module valide phone numbers in the Partner form. Please refer to the description of the *base_phone* module for more information.
+
+This module is independant from the Asterisk connector.
+
+Please contact Alexis de Lattre from Akretion for any help or question about this module.
+""",
+ 'author': 'Akretion',
+ 'website': 'http://www.akretion.com/',
+ 'depends': ['base_phone', 'event'],
+ 'data': [
+ 'security/ir.model.access.csv',
+ 'event_view.xml',
+ ],
+ 'images': [],
+ 'installable': True,
+ 'active': False,
+}
diff --git a/event_phone/event_phone.py b/event_phone/event_phone.py
new file mode 100644
index 0000000..e06f9ff
--- /dev/null
+++ b/event_phone/event_phone.py
@@ -0,0 +1,53 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# Event phone module for Odoo/OpenERP
+# Copyright (c) 2012-2014 Akretion (http://www.akretion.com)
+# @author: Alexis de Lattre
+#
+# 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 .
+#
+##############################################################################
+
+from openerp.osv import orm
+
+
+class event_registration(orm.Model):
+ _name = 'event.registration'
+ _inherit = ['event.registration', 'phone.common']
+
+ def create(self, cr, uid, vals, context=None):
+ vals_reformated = self._generic_reformat_phonenumbers(
+ cr, uid, vals, context=context)
+ return super(event_registration, self).create(
+ cr, uid, vals_reformated, context=context)
+
+ def write(self, cr, uid, ids, vals, context=None):
+ vals_reformated = self._generic_reformat_phonenumbers(
+ cr, uid, vals, context=context)
+ return super(event_registration, self).write(
+ cr, uid, ids, vals_reformated, context=context)
+
+
+class phone_common(orm.AbstractModel):
+ _inherit = 'phone.common'
+
+ def _get_phone_fields(self, cr, uid, context=None):
+ res = super(phone_common, self)._get_phone_fields(
+ cr, uid, context=context)
+ res['event.registration'] = {
+ 'phonefields': ['phone'],
+ 'get_name_sequence': 100,
+ }
+ return res
diff --git a/event_phone/event_view.xml b/event_phone/event_view.xml
new file mode 100644
index 0000000..ecf43b0
--- /dev/null
+++ b/event_phone/event_view.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+ event_phone.event_registration.form
+ event.registration
+
+
+
+ phone
+
+
+
+
+
+ event_phone.event.form
+ event.event
+
+
+
+ phone
+
+
+
+
+
+
+
diff --git a/event_phone/security/ir.model.access.csv b/event_phone/security/ir.model.access.csv
new file mode 100644
index 0000000..11de5fc
--- /dev/null
+++ b/event_phone/security/ir.model.access.csv
@@ -0,0 +1,2 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+callerid_event_registration_read,Read access on event.registration,event.model_event_registration,base_phone.group_callerid,1,0,0,0
diff --git a/hr_phone/__init__.py b/hr_phone/__init__.py
new file mode 100644
index 0000000..df6eeaa
--- /dev/null
+++ b/hr_phone/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# HR Phone module for Odoo/OpenERP
+# Copyright (C) 2014 Alexis de Lattre
+#
+# 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 .
+#
+##############################################################################
+
+from . import hr_phone
diff --git a/hr_phone/__openerp__.py b/hr_phone/__openerp__.py
new file mode 100644
index 0000000..e62b00b
--- /dev/null
+++ b/hr_phone/__openerp__.py
@@ -0,0 +1,49 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# HR Phone module for OpenERP
+# Copyright (C) 2014 Alexis de Lattre
+#
+# 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 .
+#
+##############################################################################
+
+
+{
+ 'name': 'HR Phone',
+ 'version': '0.1',
+ 'category': 'Phone',
+ 'license': 'AGPL-3',
+ 'summary': 'Validate phone numbers in HR',
+ 'description': """
+HR Phone
+========
+
+This module validate phone numbers in the HR module, just like the *base_phone* module valide phone numbers in the Partner form. Please refer to the description of the *base_phone* module for more information.
+
+This module is independant from the Asterisk connector.
+
+Please contact Alexis de Lattre from Akretion for any help or question about this module.
+""",
+ 'author': 'Akretion',
+ 'website': 'http://www.akretion.com/',
+ 'depends': ['base_phone', 'hr'],
+ 'data': [
+ 'security/ir.model.access.csv',
+ 'hr_view.xml',
+ ],
+ 'images': [],
+ 'installable': True,
+ 'active': False,
+}
diff --git a/hr_phone/hr_phone.py b/hr_phone/hr_phone.py
new file mode 100644
index 0000000..444c16d
--- /dev/null
+++ b/hr_phone/hr_phone.py
@@ -0,0 +1,53 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# HR phone module for Odoo/OpenERP
+# Copyright (c) 2012-2014 Akretion (http://www.akretion.com)
+# @author: Alexis de Lattre
+#
+# 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 .
+#
+##############################################################################
+
+from openerp.osv import orm
+
+
+class hr_employee(orm.Model):
+ _name = 'hr.employee'
+ _inherit = ['hr.employee', 'phone.common']
+
+ def create(self, cr, uid, vals, context=None):
+ vals_reformated = self._generic_reformat_phonenumbers(
+ cr, uid, vals, context=context)
+ return super(hr_employee, self).create(
+ cr, uid, vals_reformated, context=context)
+
+ def write(self, cr, uid, ids, vals, context=None):
+ vals_reformated = self._generic_reformat_phonenumbers(
+ cr, uid, vals, context=context)
+ return super(hr_employee, self).write(
+ cr, uid, ids, vals_reformated, context=context)
+
+
+class phone_common(orm.AbstractModel):
+ _inherit = 'phone.common'
+
+ def _get_phone_fields(self, cr, uid, context=None):
+ res = super(phone_common, self)._get_phone_fields(
+ cr, uid, context=context)
+ res['hr.employee'] = {
+ 'phonefields': ['work_phone', 'mobile_phone'],
+ 'get_name_sequence': 30,
+ }
+ return res
diff --git a/hr_phone/hr_view.xml b/hr_phone/hr_view.xml
new file mode 100644
index 0000000..3f7c7a7
--- /dev/null
+++ b/hr_phone/hr_view.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+ hr_phone.hr_employee.form
+ hr.employee
+
+
+
+ phone
+
+
+ phone
+
+
+
+
+
+
diff --git a/hr_phone/security/ir.model.access.csv b/hr_phone/security/ir.model.access.csv
new file mode 100644
index 0000000..610ef29
--- /dev/null
+++ b/hr_phone/security/ir.model.access.csv
@@ -0,0 +1,2 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+callerid_hr_employee_read,Read access on hr.employee,hr.model_hr_employee,base_phone.group_callerid,1,0,0,0
diff --git a/hr_recruitment_phone/__init__.py b/hr_recruitment_phone/__init__.py
new file mode 100644
index 0000000..8ac9f86
--- /dev/null
+++ b/hr_recruitment_phone/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# HR Recruitment Phone module for Odoo/OpenERP
+# Copyright (C) 2014 Alexis de Lattre
+#
+# 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 .
+#
+##############################################################################
+
+from . import hr_recruitment_phone
diff --git a/hr_recruitment_phone/__openerp__.py b/hr_recruitment_phone/__openerp__.py
new file mode 100644
index 0000000..fa04784
--- /dev/null
+++ b/hr_recruitment_phone/__openerp__.py
@@ -0,0 +1,49 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# HR Recruitment Phone module for OpenERP
+# Copyright (C) 2014 Alexis de Lattre
+#
+# 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 .
+#
+##############################################################################
+
+
+{
+ 'name': 'HR Recruitment Phone',
+ 'version': '0.1',
+ 'category': 'Phone',
+ 'license': 'AGPL-3',
+ 'summary': 'Validate phone numbers in HR Recruitment',
+ 'description': """
+HR Recruitment Phone
+====================
+
+This module validate phone numbers in the HR Recruitment module, just like the *base_phone* module valide phone numbers in the Partner form. Please refer to the description of the *base_phone* module for more information.
+
+This module is independant from the Asterisk connector.
+
+Please contact Alexis de Lattre from Akretion for any help or question about this module.
+""",
+ 'author': 'Akretion',
+ 'website': 'http://www.akretion.com/',
+ 'depends': ['base_phone', 'hr_recruitment'],
+ 'data': [
+ 'security/ir.model.access.csv',
+ 'hr_recruitment_view.xml',
+ ],
+ 'images': [],
+ 'installable': True,
+ 'active': False,
+}
diff --git a/hr_recruitment_phone/hr_recruitment_phone.py b/hr_recruitment_phone/hr_recruitment_phone.py
new file mode 100644
index 0000000..8652e23
--- /dev/null
+++ b/hr_recruitment_phone/hr_recruitment_phone.py
@@ -0,0 +1,53 @@
+# -*- encoding: utf-8 -*-
+##############################################################################
+#
+# HR Recruitment phone module for Odoo/OpenERP
+# Copyright (c) 2012-2014 Akretion (http://www.akretion.com)
+# @author: Alexis de Lattre
+#
+# 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 .
+#
+##############################################################################
+
+from openerp.osv import orm
+
+
+class hr_applicant(orm.Model):
+ _name = 'hr.applicant'
+ _inherit = ['hr.applicant', 'phone.common']
+
+ def create(self, cr, uid, vals, context=None):
+ vals_reformated = self._generic_reformat_phonenumbers(
+ cr, uid, vals, context=context)
+ return super(hr_applicant, self).create(
+ cr, uid, vals_reformated, context=context)
+
+ def write(self, cr, uid, ids, vals, context=None):
+ vals_reformated = self._generic_reformat_phonenumbers(
+ cr, uid, vals, context=context)
+ return super(hr_applicant, self).write(
+ cr, uid, ids, vals_reformated, context=context)
+
+
+class phone_common(orm.AbstractModel):
+ _inherit = 'phone.common'
+
+ def _get_phone_fields(self, cr, uid, context=None):
+ res = super(phone_common, self)._get_phone_fields(
+ cr, uid, context=context)
+ res['hr.applicant'] = {
+ 'phonefields': ['partner_phone', 'partner_mobile'],
+ 'get_name_sequence': 50,
+ }
+ return res
diff --git a/hr_recruitment_phone/hr_recruitment_view.xml b/hr_recruitment_phone/hr_recruitment_view.xml
new file mode 100644
index 0000000..e8a47b3
--- /dev/null
+++ b/hr_recruitment_phone/hr_recruitment_view.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+ hr_recruitment_phone.hr_applicant.form
+ hr.applicant
+
+
+
+ phone
+
+
+ phone
+
+
+
+
+
+
diff --git a/hr_recruitment_phone/security/ir.model.access.csv b/hr_recruitment_phone/security/ir.model.access.csv
new file mode 100644
index 0000000..79cb918
--- /dev/null
+++ b/hr_recruitment_phone/security/ir.model.access.csv
@@ -0,0 +1,2 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+callerid_hr_applicant_read,Read access on hr.applicant,hr_recruitment.model_hr_applicant,base_phone.group_callerid,1,0,0,0