Browse Source

Very large changes in the structure of the project :

- move more asterisk-independant code to base_phone module and create new asterisk-independant modules
- rename module asterisk_popup to base_phone_popup
- add ability to get callerid names not only from partners, but also from leads, employees, applicants, etc...
- same for auto pop-up : not only for partners, but also for leads, employees, etc...
pull/7/head
Alexis de Lattre 10 years ago
parent
commit
09b4feacee
  1. 3
      asterisk_click2dial/__openerp__.py
  2. 86
      asterisk_click2dial/asterisk_click2dial.py
  3. 29
      asterisk_click2dial/asterisk_server_view.xml
  4. 7
      asterisk_click2dial/res_partner_view.xml
  5. 51
      asterisk_click2dial/res_users_view.xml
  6. 26
      asterisk_click2dial/scripts/get_cid_name.py
  7. 2
      asterisk_click2dial/security/ir.model.access.csv
  8. 31
      asterisk_click2dial/wizard/open_calling_partner.py
  9. 5
      asterisk_click2dial_crm/__openerp__.py
  10. 17
      asterisk_click2dial_crm/asterisk_click2dial_crm.py
  11. 6
      asterisk_click2dial_crm/crm_lead_view.xml
  12. 23
      asterisk_click2dial_crm/res_users_view.xml
  13. 1
      asterisk_click2dial_crm/wizard/__init__.py
  14. 1
      asterisk_click2dial_crm/wizard/create_crm_phonecall_view.xml
  15. 39
      asterisk_click2dial_crm/wizard/reformat_all_phonenumbers.py
  16. 1
      asterisk_click2dial_crm_claim/__init__.py
  17. 4
      asterisk_click2dial_crm_claim/__openerp__.py
  18. 4
      asterisk_click2dial_crm_claim/crm_claim_view.xml
  19. 1
      asterisk_click2dial_crm_claim/wizard/__init__.py
  20. 2
      asterisk_click2dial_crm_claim/wizard/open_calling_partner.py
  21. 39
      asterisk_click2dial_crm_claim/wizard/reformat_all_phonenumbers.py
  22. 1
      asterisk_click2dial_event/__init__.py
  23. 4
      asterisk_click2dial_event/__openerp__.py
  24. 0
      asterisk_click2dial_event/asterisk_click2dial_registration.py
  25. 20
      asterisk_click2dial_event/registration_view.xml
  26. 0
      asterisk_click2dial_event/wizard/__init__.py
  27. 2
      asterisk_click2dial_event/wizard/open_calling_partner.py
  28. 0
      asterisk_click2dial_event/wizard/open_calling_partner_view.xml
  29. 36
      asterisk_popup/res_users_view.xml
  30. 2
      base_phone/__init__.py
  31. 6
      base_phone/__openerp__.py
  32. 153
      base_phone/base_phone.py
  33. 27
      base_phone/res_company_view.xml
  34. 40
      base_phone/res_users_view.xml
  35. 2
      base_phone/security/ir.model.access.csv
  36. 8
      base_phone/security/phone_security.xml
  37. 63
      base_phone/wizard/reformat_all_phonenumbers.py
  38. 13
      base_phone/wizard/reformat_all_phonenumbers_view.xml
  39. 2
      base_phone_popup/__init__.py
  40. 17
      base_phone_popup/__openerp__.py
  41. 0
      base_phone_popup/i18n/asterisk_popup.pot
  42. 0
      base_phone_popup/i18n/fr.po
  43. 39
      base_phone_popup/popup.py
  44. 39
      base_phone_popup/res_users_view.xml
  45. 22
      crm_claim_phone/__init__.py
  46. 46
      crm_claim_phone/__openerp__.py
  47. 39
      crm_claim_phone/crm_claim_phone.py
  48. 23
      crm_claim_phone/crm_claim_view.xml
  49. 22
      crm_phone/__init__.py
  50. 49
      crm_phone/__openerp__.py
  51. 98
      crm_phone/crm_phone.py
  52. 59
      crm_phone/crm_view.xml
  53. 2
      crm_phone/security/ir.model.access.csv
  54. 22
      event_phone/__init__.py
  55. 49
      event_phone/__openerp__.py
  56. 53
      event_phone/event_phone.py
  57. 34
      event_phone/event_view.xml
  58. 2
      event_phone/security/ir.model.access.csv
  59. 22
      hr_phone/__init__.py
  60. 49
      hr_phone/__openerp__.py
  61. 53
      hr_phone/hr_phone.py
  62. 25
      hr_phone/hr_view.xml
  63. 2
      hr_phone/security/ir.model.access.csv
  64. 22
      hr_recruitment_phone/__init__.py
  65. 49
      hr_recruitment_phone/__openerp__.py
  66. 53
      hr_recruitment_phone/hr_recruitment_phone.py
  67. 25
      hr_recruitment_phone/hr_recruitment_view.xml
  68. 2
      hr_recruitment_phone/security/ir.model.access.csv

3
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'],

86
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

29
asterisk_click2dial/asterisk_server_view.xml

@ -8,28 +8,14 @@
<openerp>
<data>
<!-- Inherit res.company to add tab for Asterisk servers -->
<record id="view_asterisk_server_company_form" model="ir.ui.view">
<field name="name">asterisk.server.company</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form" />
<field name="arch" type="xml">
<notebook position="inside">
<page name="asterisk" string="IPBX">
<field nolabel="1" name="asterisk_server_ids" />
</page>
</notebook>
</field>
</record>
<!-- Search view for asterisk.server -->
<record id="view_asterisk_server_search" model="ir.ui.view">
<field name="name">asterisk.server.search</field>
<field name="model">asterisk.server</field>
<field name="arch" type="xml">
<search string="Asterisk Server Search">
<field name="name" />
<field name="ip_address" />
<field name="name"
filter_domain="['|', ('name', 'ilike', self), ('ip_address', 'ilike', self)]"/>
</search>
</field>
</record>
@ -48,7 +34,9 @@
</h1>
</div>
<group name="main">
<field name="company_id" invisible="not context.get('asterisk_server_main_view', False)" groups="base.group_multi_company"/>
<field name="company_id"
invisible="not context.get('asterisk_server_main_view')"
groups="base.group_multi_company"/>
<field name="active" />
<field name="ip_address" />
<field name="port" />
@ -62,7 +50,6 @@
<field name="country_prefix" />
<field name="alert_info" />
<field name="wait_time" />
<field name="number_of_digits_to_match_from_end" />
</group>
</sheet>
</form>
@ -75,10 +62,11 @@
<field name="model">asterisk.server</field>
<field name="arch" type="xml">
<tree string="Asterisk Servers">
<field name="company_id" invisible="not context.get('asterisk_server_main_view', False)"/>
<field name="name" />
<field name="ip_address" />
<field name="port" />
<field name="company_id"
invisible="not context.get('asterisk_server_main_view')"
groups="base.group_multi_company" />
<field name="country_prefix" />
</tree>
</field>
@ -88,7 +76,6 @@
<record id="action_asterisk_server" model="ir.actions.act_window">
<field name="name">Asterisk Servers</field>
<field name="res_model">asterisk.server</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{'asterisk_server_main_view': True}</field>
</record>

7
asterisk_click2dial/res_partner_view.xml

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Asterisk Click2dial module for OpenERP
Copyright (C) 2010-2013 Alexis de Lattre <alexis@via.ecp.fr>
Asterisk Click2dial module for Odoo/OpenERP
Copyright (C) 2010-2014 Alexis de Lattre <alexis@via.ecp.fr>
The licence is in the file __openerp__.py
Inherit partner views to add 'Dial' button next to 'phone'
@ -50,9 +50,6 @@
<button name="action_dial" context="{'field2dial': 'mobile'}" string="Dial" type="object" attrs="{'invisible':[('mobile','=',False)]}"/>
</group>
</xpath>
<xpath expr="//group/group/field[@name='fax']" position="attributes">
<attribute name="widget">fax</attribute>
</xpath>
<xpath expr="//form[@string='Contact']/sheet/group/field[@name='phone']" position="replace">
<group colspan="2" col="8">
<field name="phone" widget="phone" colspan="7" />

51
asterisk_click2dial/res_users_view.xml

@ -10,44 +10,31 @@
<openerp>
<data>
<record id="asterisk_res_users_internal_number" model="ir.ui.view">
<field name="name">asterisk.res.users.telephony_tab</field>
<record id="view_users_form" model="ir.ui.view">
<field name="name">asterisk_click2dial.res.users.form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="inherit_id" ref="base_phone.view_users_form"/>
<field name="arch" type="xml">
<notebook>
<page string="Telephony" position="inside">
<group name="standard_params" string="Standard parameters">
<field name="asterisk_chan_type"/>
<field name="resource"/>
<field name="internal_number"/>
<field name="callerid"/>
<field name="asterisk_server_id"/>
</group>
<group name="optional_params" string="Optional parameters - for experts only, can be left empty">
<field name="cdraccount"/>
<field name="dial_suffix"/>
<field name="alert_info"/>
<field name="variable"/>
</group>
</page>
</notebook>
</field>
</record>
<record id="view_users_form_simple_modif" model="ir.ui.view">
<field name="name">asterisk.preferences.view</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form_simple_modif" />
<field name="arch" type="xml">
<group string="Email Preferences" position="after">
<group name="telephony">
<!-- Empty group, that is used by other Asterisk modules -->
<page name="phone" position="attributes">
<attribute name="invisible">0</attribute>
</page>
<group name="phone-preferences" position="after">
<group name="asterisk-standard" string="Standard Asterisk Parameters">
<field name="asterisk_chan_type"/>
<field name="resource"/>
<field name="internal_number"/>
<field name="callerid"/>
<field name="asterisk_server_id"/>
</group>
<group name="asterisk-optional" string="Optional Asterisk Parameters - for experts only, can be left empty">
<field name="cdraccount"/>
<field name="dial_suffix"/>
<field name="alert_info"/>
<field name="variable"/>
</group>
</group>
</field>
</record>
</data>
</openerp>

26
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 <OPTIONS>
# timeout 2s get_cid_name.py <OPTIONS>
See my sample wrapper "get_cid_name_timeout.sh"
@ -41,10 +43,10 @@
"""
__author__ = "Alexis de Lattre <alexis.delattre@akretion.com>"
__date__ = "December 2010"
__version__ = "0.3"
__date__ = "July 2014"
__version__ = "0.4"
# Copyright (C) 2010-2012 Alexis de Lattre <alexis.delattre@akretion.com>
# Copyright (C) 2010-2014 Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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')

2
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

31
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,

5
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,

17
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)

6
asterisk_click2dial_crm/crm_lead_view.xml

@ -29,9 +29,6 @@
<button name="action_dial" context="{'field2dial': 'mobile'}" string="Dial" type="object" attrs="{'invisible':[('mobile','=',False)]}"/>
</group>
</field>
<field name="fax" position="attributes">
<attribute name="widget">fax</attribute>
</field>
</field>
</record>
@ -53,9 +50,6 @@
<button name="action_dial" context="{'field2dial': 'mobile'}" string="Dial" type="object" attrs="{'invisible':[('mobile','=',False)]}"/>
</group>
</field>
<field name="fax" position="attributes">
<attribute name="widget">fax</attribute>
</field>
</field>
</record>

23
asterisk_click2dial_crm/res_users_view.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2012-2013 Akretion (http://www.akretion.com/)
Copyright (C) 2012-2014 Akretion (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
@ -9,27 +9,28 @@
<data>
<!-- Add option on user form view -->
<record id="asterisk_crm_option_view" model="ir.ui.view">
<field name="name">asterisk.crm.option.view</field>
<record id="view_users_form" model="ir.ui.view">
<field name="name">asterisk.crm.res.users.form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="asterisk_click2dial.asterisk_res_users_internal_number"/>
<field name="inherit_id" ref="base_phone.view_users_form"/>
<field name="arch" type="xml">
<field name="asterisk_server_id" position="after">
<!-- Phone tab is already visible thanks to asterisk_click2dial -->
<group name="phone-preferences" position="inside">
<field name="context_propose_creation_crm_call"/>
</field>
</group>
</field>
</record>
<record id="asterisk_crm_preferences_option_view" model="ir.ui.view">
<record id="view_users_form_simple_modif" model="ir.ui.view">
<field name="name">asterisk.crm.preferences.option.view</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="asterisk_click2dial.view_users_form_simple_modif" />
<field name="inherit_id" ref="base_phone.view_users_form_simple_modif" />
<field name="arch" type="xml">
<group name="telephony" position="inside">
<group name="phone" position="inside">
<field name="context_propose_creation_crm_call" readonly="0"/>
</group>
<group name="telephony" position="attributes">
<attribute name="string">Telephony Preferences</attribute>
<group name="phone" position="attributes">
<attribute name="invisible">0</attribute>
</group>
</field>
</record>

1
asterisk_click2dial_crm/wizard/__init__.py

@ -21,4 +21,3 @@
##############################################################################
from . import create_crm_phonecall
from . import reformat_all_phonenumbers

1
asterisk_click2dial_crm/wizard/create_crm_phonecall_view.xml

@ -27,7 +27,6 @@
<record id="action_create_crm_phonecall" model="ir.actions.act_window">
<field name="name">Create CRM phonecall</field>
<field name="res_model">wizard.create.crm.phonecall</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>

39
asterisk_click2dial_crm/wizard/reformat_all_phonenumbers.py

@ -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 <alexis.delattre@akretion.com>
#
# 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 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

1
asterisk_click2dial_crm_claim/__init__.py

@ -21,4 +21,3 @@
##############################################################################
from . import wizard
from . import asterisk_click2dial_crm_claim

4
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": [

4
asterisk_click2dial_crm_claim/crm_claim_view.xml

@ -14,11 +14,11 @@
<record id="asterisk_crm_claim_form_dial" model="ir.ui.view">
<field name="name">asterisk.crm_claim.form.dial</field>
<field name="model">crm.claim</field>
<field name="inherit_id" ref="crm_claim.crm_case_claims_form_view"/>
<field name="inherit_id" ref="crm_claim_phone.crm_case_claims_form_view"/>
<field name="arch" type="xml">
<field name="partner_phone" position="replace">
<group colspan="2" col="3">
<field name="partner_phone" colspan="2" />
<field name="partner_phone" colspan="2" widget="phone"/>
<button name="action_dial" context="{'field2dial': 'partner_phone'}" string="Dial" type="object" attrs="{'invisible':[('partner_phone','=',False)]}"/>
</group>
</field>

1
asterisk_click2dial_crm_claim/wizard/__init__.py

@ -21,4 +21,3 @@
##############################################################################
from . import open_calling_partner
from . import reformat_all_phonenumbers

2
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)

39
asterisk_click2dial_crm_claim/wizard/reformat_all_phonenumbers.py

@ -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 <alexis.delattre@akretion.com>
#
# 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 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

1
asterisk_click2dial_registration/__init__.py → asterisk_click2dial_event/__init__.py

@ -20,4 +20,3 @@
##############################################################################
from . import wizard
from . import asterisk_click2dial_registration

4
asterisk_click2dial_registration/__openerp__.py → 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": [

0
asterisk_click2dial_registration/asterisk_click2dial_registration.py → asterisk_click2dial_event/asterisk_click2dial_registration.py

20
asterisk_click2dial_registration/registration_view.xml → asterisk_click2dial_event/registration_view.xml

@ -11,10 +11,10 @@
<openerp>
<data>
<record id="asterisk_event_registration_form_dial" model="ir.ui.view">
<record id="view_event_registration_form" model="ir.ui.view">
<field name="name">asterisk.event.registration.form.dial</field>
<field name="model">event.registration</field>
<field name="inherit_id" ref="event.view_event_registration_form"/>
<field name="inherit_id" ref="event_phone.view_event_registration_form"/>
<field name="arch" type="xml">
<field name="phone" position="replace">
<group colspan="2" col="3">
@ -25,24 +25,16 @@
</field>
</record>
<record id="asterisk_event_form_registration_tree_dial" model="ir.ui.view">
<record id="view_event_form" model="ir.ui.view">
<field name="name">asterisk.event.form.registration.tree.dial</field>
<field name="model">event.event</field>
<field name="inherit_id" ref="event.view_event_form"/>
<field name="inherit_id" ref="event_phone.view_event_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='registration_ids']/tree/field[@name='phone']" position="replace">
<field name="phone" widget="phone" colspan="2" />
<field name="phone" colspan="2" />
<button name="action_dial" context="{'field2dial': 'phone'}" string="Dial" type="object" icon="terp-call-start" attrs="{'invisible':[('phone','=',False)]}"/>
</xpath>
</field>
</record>
<record id="asterisk_event_form_registration_form_dial" model="ir.ui.view">
<field name="name">asterisk.event.form.registration.form.dial</field>
<field name="model">event.event</field>
<field name="inherit_id" ref="event.view_event_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='registration_ids']/form/group/field[@name='phone']" position="replace">
<xpath expr="//field[@name='registration_ids']/form//field[@name='phone']" position="replace">
<group colspan="2" col="3">
<field name="phone" widget="phone" colspan="2" />
<button name="action_dial" context="{'field2dial': 'phone'}" string="Dial" type="object" attrs="{'invisible':[('phone','=',False)]}"/>

0
asterisk_click2dial_registration/wizard/__init__.py → asterisk_click2dial_event/wizard/__init__.py

2
asterisk_click2dial_registration/wizard/open_calling_partner.py → 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)

0
asterisk_click2dial_registration/wizard/open_calling_partner_view.xml → asterisk_click2dial_event/wizard/open_calling_partner_view.xml

36
asterisk_popup/res_users_view.xml

@ -1,36 +0,0 @@
<?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
-->
<openerp>
<data>
<record id="asterisk_res_users" model="ir.ui.view">
<field name="name">asterisk.popup.res.users.form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="asterisk_click2dial.asterisk_res_users_internal_number"/>
<field name="arch" type="xml">
<field name="asterisk_server_id" position="after">
<field name="context_incall_popup"/>
</field>
</field>
</record>
<record id="view_users_form_simple_modif" model="ir.ui.view">
<field name="name">asterisk.popup.preferences.view</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="asterisk_click2dial.view_users_form_simple_modif" />
<field name="arch" type="xml">
<group name="telephony" position="inside">
<field name="context_incall_popup" readonly="0"/>
</group>
<group name="telephony" position="attributes">
<attribute name="string">Telephony Preferences</attribute>
</group>
</field>
</record>
</data>
</openerp>

2
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 <alexis@via.ecp.fr>
#
# This program is free software: you can redistribute it and/or modify

6
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 <alexis.delattre@akretion.com> 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': [

153
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 <alexis@via.ecp.fr>
#
# 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."),
]

27
base_phone/res_company_view.xml

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2014 Akretion (http://www.akretion.com/)
@author Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="view_company_form" model="ir.ui.view">
<field name="name">base_phone.company.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form" />
<field name="arch" type="xml">
<group name="account_grp" position="after">
<group name="phone" string="Phone">
<field name="number_of_digits_to_match_from_end" />
</group>
</group>
</field>
</record>
</data>
</openerp>

40
base_phone/res_users_view.xml

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Base Phone module for OpenERP
Copyright (C) 2010-2014 Alexis de Lattre <alexis@via.ecp.fr>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="view_users_form" model="ir.ui.view">
<field name="name">base_phone.res.users.telephony_tab</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form"/>
<field name="arch" type="xml">
<notebook>
<page string="Telephony" name="phone" invisible="1" position="inside">
<!-- Empty page, which will be used by other phone modules -->
<group name="phone-preferences" string="Telephony Preferences">
</group>
</page>
</notebook>
</field>
</record>
<record id="view_users_form_simple_modif" model="ir.ui.view">
<field name="name">base_phone.user_preferences.view</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form_simple_modif" />
<field name="arch" type="xml">
<group string="Email Preferences" position="after">
<group name="phone" string="Telephony Preferences" invisible="1">
<!-- Empty group, that is used by other phone modules -->
</group>
</group>
</field>
</record>
</data>
</openerp>

2
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

8
asterisk_click2dial/security/asterisk_server_security.xml → base_phone/security/phone_security.xml

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Asterisk Click2dial module for OpenERP
Copyright (C) 2010-2013 Alexis de Lattre <alexis@via.ecp.fr>
Base Phone module for Odoo/OpenERP
Copyright (C) 2010-2014 Alexis de Lattre <alexis@via.ecp.fr>
The licence is in the file __openerp__.py
-->
@ -9,8 +9,8 @@
<data noupdate="1">
<!-- New group dedicated to the "Get CallerID name from OpenERP" feature -->
<record id="group_asterisk_cid" model="res.groups">
<field name="name">Asterisk CallerID</field>
<record id="group_callerid" model="res.groups">
<field name="name">Phone CallerID</field>
</record>
</data>

63
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

13
base_phone/wizard/reformat_all_phonenumbers_view.xml

@ -14,17 +14,15 @@
<field name="arch" type="xml">
<form string="Reformat all phone numbers" version="7.0">
<!-- TODO : add a "state" and display fields accordingly -->
<group>
<group name="main">
<label string="This wizard reformats the phone, mobile and fax numbers of all partners in standard international format e.g. +33141981242" colspan="4"/>
</group>
<group>
<button name="run_reformat_all_phonenumbers" string="Reformat all phone numbers" type="object" class="oe_highlight"/>
<button special="cancel" string="Cancel" class="oe_link" />
</group>
<group>
<label colspan="4" string="Phone numbers that couldn't be reformatted:"/>
<field name="phonenumbers_not_reformatted" colspan="4" nolabel="1"/>
</group>
<footer>
<button name="run_reformat_all_phonenumbers" string="Reformat all phone numbers" type="object" class="oe_highlight"/>
<button special="cancel" string="Cancel" class="oe_link" />
</footer>
</form>
</field>
</record>
@ -32,7 +30,6 @@
<record id="reformat_all_phonenumbers_action" model="ir.actions.act_window">
<field name="name">Reformat Phone Numbers</field>
<field name="res_model">reformat.all.phonenumbers</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>

2
asterisk_popup/__init__.py → 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 <alexis@via.ecp.fr>
#
# This program is free software: you can redistribute it and/or modify

17
asterisk_popup/__openerp__.py → 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 <alexis@via.ecp.fr>
#
# 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,
}

0
asterisk_popup/i18n/asterisk_popup.pot → base_phone_popup/i18n/asterisk_popup.pot

0
asterisk_popup/i18n/fr.po → base_phone_popup/i18n/fr.po

39
asterisk_popup/popup.py → 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 <alexis@via.ecp.fr>
#
# 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):

39
base_phone_popup/res_users_view.xml

@ -0,0 +1,39 @@
<?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
-->
<openerp>
<data>
<record id="view_users_form" model="ir.ui.view">
<field name="name">base_phone_popup.res.users.form</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base_phone.view_users_form"/>
<field name="arch" type="xml">
<page name="phone" position="attributes">
<attribute name="invisible">0</attribute>
</page>
<group name="phone-preferences" position="inside">
<field name="context_incall_popup"/>
</group>
</field>
</record>
<record id="view_users_form_simple_modif" model="ir.ui.view">
<field name="name">base_phone_popup.users.preferences.view</field>
<field name="model">res.users</field>
<field name="inherit_id" ref="base_phone.view_users_form_simple_modif" />
<field name="arch" type="xml">
<group name="phone" position="inside">
<field name="context_incall_popup" readonly="0"/>
</group>
<group name="phone" position="attributes">
<attribute name="invisible">0</attribute>
</group>
</field>
</record>
</data>
</openerp>

22
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 <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 crm_claim_phone

46
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 <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/>.
#
##############################################################################
{
'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 <alexis.delattre@akretion.com> 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,
}

39
asterisk_click2dial_crm_claim/asterisk_click2dial_crm_claim.py → 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 <contact@invitu.com>
# CRM Claim Phone module for Odoo/OpenERP
# Copyright (c) 2012-2014 Akretion (http://www.akretion.com)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
#
# 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

23
crm_claim_phone/crm_claim_view.xml

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
CRM Claim Phone module for OpenERP
Copyright (C) 2014 Alexis de Lattre <alexis@via.ecp.fr>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<record id="crm_case_claims_form_view" model="ir.ui.view">
<field name="name">crm_claim_phone.crm_claim.form</field>
<field name="model">crm.claim</field>
<field name="inherit_id" ref="crm_claim.crm_case_claims_form_view"/>
<field name="arch" type="xml">
<field name="partner_phone" position="attributes">
<attribute name="widget">phone</attribute>
</field>
</field>
</record>
</data>
</openerp>

22
crm_phone/__init__.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# CRM Phone 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 crm_phone

49
crm_phone/__openerp__.py

@ -0,0 +1,49 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# CRM Phone module for 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/>.
#
##############################################################################
{
'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 <alexis.delattre@akretion.com> 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,
}

98
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 <alexis.delattre@akretion.com>
#
# 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 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

59
crm_phone/crm_view.xml

@ -0,0 +1,59 @@
<?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
-->
<openerp>
<data>
<record id="crm_case_form_view_leads" model="ir.ui.view">
<field name="name">crm_phone.crm_lead.form</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_leads"/>
<field name="arch" type="xml">
<field name="phone" position="attributes">
<attribute name="widget">phone</attribute>
</field>
<field name="mobile" position="attributes">
<attribute name="widget">phone</attribute>
</field>
<field name="fax" position="attributes">
<attribute name="widget">fax</attribute>
</field>
</field>
</record>
<record id="crm_case_form_view_oppor" model="ir.ui.view">
<field name="name">crm_phone.case.view_opportuniy.form</field>
<field name="model">crm.lead</field>
<field name="inherit_id" ref="crm.crm_case_form_view_oppor"/>
<field name="arch" type="xml">
<field name="phone" position="attributes">
<attribute name="widget">phone</attribute>
</field>
<field name="mobile" position="attributes">
<attribute name="widget">phone</attribute>
</field>
<field name="fax" position="attributes">
<attribute name="widget">fax</attribute>
</field>
</field>
</record>
<record id="crm_case_phone_form_view" model="ir.ui.view">
<field name="name">crm_phone.crm_phonecall.form</field>
<field name="model">crm.phonecall</field>
<field name="inherit_id" ref="crm.crm_case_phone_form_view"/>
<field name="arch" type="xml">
<field name="partner_phone" position="attributes">
<attribute name="widget">phone</attribute>
</field>
<field name="partner_mobile" position="attributes">
<attribute name="widget">phone</attribute>
</field>
</field>
</record>
</data>
</openerp>

2
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

22
event_phone/__init__.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# Event Phone 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 event_phone

49
event_phone/__openerp__.py

@ -0,0 +1,49 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# Event Phone 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/>.
#
##############################################################################
{
'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 <alexis.delattre@akretion.com> 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,
}

53
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 <alexis.delattre@akretion.com>
#
# 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 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

34
event_phone/event_view.xml

@ -0,0 +1,34 @@
<?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
-->
<openerp>
<data>
<record id="view_event_registration_form" model="ir.ui.view">
<field name="name">event_phone.event_registration.form</field>
<field name="model">event.registration</field>
<field name="inherit_id" ref="event.view_event_registration_form"/>
<field name="arch" type="xml">
<field name="phone" position="attributes">
<attribute name="widget">phone</attribute>
</field>
</field>
</record>
<record id="view_event_form" model="ir.ui.view">
<field name="name">event_phone.event.form</field>
<field name="model">event.event</field>
<field name="inherit_id" ref="event.view_event_form"/>
<field name="arch" type="xml">
<xpath expr="//field[@name='registration_ids']/form//field[@name='phone']" position="attributes">
<attribute name="widget">phone</attribute>
</xpath>
</field>
</record>
</data>
</openerp>

2
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

22
hr_phone/__init__.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
##############################################################################
#
# HR Phone 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 hr_phone

49
hr_phone/__openerp__.py

@ -0,0 +1,49 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# HR Phone module for 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/>.
#
##############################################################################
{
'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 <alexis.delattre@akretion.com> 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,
}

53
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 <alexis.delattre@akretion.com>
#
# 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 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

25
hr_phone/hr_view.xml

@ -0,0 +1,25 @@
<?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
-->
<openerp>
<data>
<record id="view_employee_form" model="ir.ui.view">
<field name="name">hr_phone.hr_employee.form</field>
<field name="model">hr.employee</field>
<field name="inherit_id" ref="hr.view_employee_form"/>
<field name="arch" type="xml">
<field name="work_phone" position="attributes">
<attribute name="widget">phone</attribute>
</field>
<field name="mobile_phone" position="attributes">
<attribute name="widget">phone</attribute>
</field>
</field>
</record>
</data>
</openerp>

2
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

22
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 <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 hr_recruitment_phone

49
hr_recruitment_phone/__openerp__.py

@ -0,0 +1,49 @@
# -*- encoding: utf-8 -*-
##############################################################################
#
# HR Recruitment Phone module for 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/>.
#
##############################################################################
{
'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 <alexis.delattre@akretion.com> 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,
}

53
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 <alexis.delattre@akretion.com>
#
# 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 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

25
hr_recruitment_phone/hr_recruitment_view.xml

@ -0,0 +1,25 @@
<?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
-->
<openerp>
<data>
<record id="crm_case_form_view_job" model="ir.ui.view">
<field name="name">hr_recruitment_phone.hr_applicant.form</field>
<field name="model">hr.applicant</field>
<field name="inherit_id" ref="hr_recruitment.crm_case_form_view_job"/>
<field name="arch" type="xml">
<field name="partner_phone" position="attributes">
<attribute name="widget">phone</attribute>
</field>
<field name="partner_mobile" position="attributes">
<attribute name="widget">phone</attribute>
</field>
</field>
</record>
</data>
</openerp>

2
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
Loading…
Cancel
Save