Browse Source

Port asterisk_click2dial_crm to version 6.1 :

- code re-factoring
- add "open CRM call" from the "open calling partner" wizard
pull/26/head
Alexis de Lattre 12 years ago
parent
commit
f369629f4c
  1. 4
      asterisk_click2dial/asterisk_click2dial.py
  2. 9
      asterisk_click2dial_crm/__openerp__.py
  3. 28
      asterisk_click2dial_crm/open_calling_partner_view.xml
  4. 69
      asterisk_click2dial_crm/res_partner_address.py

4
asterisk_click2dial/asterisk_click2dial.py

@ -489,9 +489,9 @@ class wizard_open_calling_partner(osv.osv_memory):
'''Thanks to the default_get method, we are able to query Asterisk and
get the corresponding partner when we launch the wizard'''
res = {}
calling_number = self.pool.get('asterisk.server')._connect_to_asterisk(cr, uid, method='get_calling_number', context=context)
#calling_number = self.pool.get('asterisk.server')._connect_to_asterisk(cr, uid, method='get_calling_number', context=context)
#To test the code without Asterisk server
#calling_number = "0141981242"
calling_number = "0141981242"
if calling_number:
res['calling_number'] = calling_number
# We match only on the end of the phone number

9
asterisk_click2dial_crm/__openerp__.py

@ -29,8 +29,12 @@
"license" : "AGPL-3",
'category': 'Generic Modules/Others',
"description": """
Create a outbound phone call when the user makes a call phone by clicking
the click2dial button of the partner address view, and opens it in a new tab.
Create a outbound phone call in the CRM when the user makes a call phone
by clicking the click2dial button of the partner address view,
and opens it in a new tab.
Also proposes to create an inbound phone call in the CRM when the user receives
a phone calls and clicks on "Open calling partner".
""",
"depends": [
'asterisk_click2dial',
@ -39,6 +43,7 @@
"init_xml" : [ ],
"demo_xml" : [ ],
"update_xml" : [
'open_calling_partner_view.xml',
],
"installable": True,
}

28
asterisk_click2dial_crm/open_calling_partner_view.xml

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Asterisk Click2dial CRM module for OpenERP
Copyright (C) 2012 Akretion (http://www.akretion.com)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
The licence is in the file __openerp__.py
-->
<openerp>
<data>
<!-- Add button on the "Get partner from incoming phone call view" -->
<record id="asterisk_click2dial_crm_open_calling_partner_view" model="ir.ui.view">
<field name="name">asterisk_click2dial_crm.open_calling_partner.view</field>
<field name="model">wizard.open.calling.partner</field>
<field name="inherit_id" ref="asterisk_click2dial.view_open_calling_partner"/>
<field name="type">form</field>
<field name="arch" type="xml">
<button name="open_invoices" position="after">
<button name="create_incoming_phonecall" icon="gtk-new" string="Create call in CRM" type="object" />
</button>
</field>
</record>
</data>
</openerp>

69
asterisk_click2dial_crm/res_partner_address.py

@ -3,8 +3,9 @@
#
# OpenERP, Open Source Management Solution
# Copyright (c) 2011 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved.
# Jesús Martín <jmartin@zikzakmedia.com>
# $Id$
# Copyright (c) 2012 Akretion (http://www.akretion.com)
# @author: Jesús Martín <jmartin@zikzakmedia.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
@ -26,10 +27,9 @@ from osv import osv, fields
from tools.translate import _
class res_partner_address(osv.osv):
_name = "res.partner.address"
_inherit = "res.partner.address"
def action_dial_phone(self, cr, uid, ids, context=None):
def dial(self, cr, uid, ids, phone_field='phone', context=None):
'''
This method open the phone call history when the phone click2dial
button of asterisk_click2dial module is pressed
@ -37,49 +37,30 @@ class res_partner_address(osv.osv):
'''
if context is None:
context = {}
super(res_partner_address, self).action_dial_phone(cr, uid, ids, context)
crm_phonecall_id = self.create_phonecall(cr, uid, ids, context)
partner = self.browse(cr, uid, ids[0], context).partner_id
return {
'name': partner.name,
'domain': "[('partner_address_id.partner_id.id', '=', %s)]" % partner.id,
'res_model': 'crm.phonecall',
'res_id': crm_phonecall_id,
'view_type': 'form',
'view_mode': 'form,tree',
'view_id': False,
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'current',
'context': context,
}
super(res_partner_address, self).dial(cr, uid, ids, phone_field=phone_field, context=context)
return self.create_open_phonecall(cr, uid, ids, crm_categ='Outbound', context=context)
def action_dial_mobile(self, cr, uid, ids, context=None):
'''
This method open the phone call history when the mobile click2dial
button of asterisk_click2dial module is pressed
:return the phone call history view of the partner
'''
def create_open_phonecall(self, cr, uid, ids, crm_categ, context=None):
if context is None:
context = {}
super(res_partner_address, self).action_dial_mobile(cr, uid, ids, context)
crm_phonecall_id = self.create_phonecall(cr, uid, ids, context)
partner = self.browse(cr, uid, ids[0], context).partner_id
crm_phonecall_id = self.create_phonecall(cr, uid, ids, crm_categ=crm_categ, context=context)
partner = self.browse(cr, uid, ids[0], context=context).partner_id
return {
'name': partner.name,
'domain': "[('partner_address_id.partner_id.id', '=', %s)]" % partner.id,
'res_model': 'crm.phonecall',
'res_id': crm_phonecall_id,
'res_id': [crm_phonecall_id],
'view_type': 'form',
'view_mode': 'form,tree',
'view_id': False,
'type': 'ir.actions.act_window',
'nodestroy': True,
'target': 'current',
'context': context,
}
def create_phonecall(self, cr, uid, ids, context = None):
def create_phonecall(self, cr, uid, ids, crm_categ='Outbound', context=None):
'''
This method creates a phone call history when the phone click2dial
button of asterisk_click2dial module is pressed and opens it.
@ -89,12 +70,12 @@ class res_partner_address(osv.osv):
context = {}
crm_phonecall_obj = self.pool.get('crm.phonecall')
partner_address = self.browse(cr, uid, ids[0], context)
partner_address = self.browse(cr, uid, ids[0], context=context)
categ_ids = self.pool.get('crm.case.categ').search(cr, uid, [('name','=','Outbound')], context={'lang': 'en_US'})
case_seccion_ids = self.pool.get('crm.case.section').search(cr, uid, [('member_ids', 'in', uid)], context = context)
categ_ids = self.pool.get('crm.case.categ').search(cr, uid, [('name','=',crm_categ)], context={'lang': 'en_US'})
case_section_ids = self.pool.get('crm.case.section').search(cr, uid, [('member_ids', 'in', uid)], context=context)
values = {
'name': "",
'name': "CRM Call", # TODO check name
'partner_id': partner_address.partner_id and partner_address.partner_id.id or False,
'partner_address_id': partner_address.id,
'partner_phone': partner_address.phone,
@ -102,9 +83,21 @@ class res_partner_address(osv.osv):
'partner_mobile': partner_address.mobile,
'user_id': uid,
'categ_id': categ_ids and categ_ids[0] or False,
'section_id': case_seccion_ids and case_seccion_ids[0] or False,
'section_id': case_section_ids and case_section_ids[0] or False,
}
crm_phonecall_id = crm_phonecall_obj.create(cr, uid, values, context)
crm_phonecall_id = crm_phonecall_obj.create(cr, uid, values, context=context)
return crm_phonecall_id
res_partner_address()
class wizard_open_calling_partner(osv.osv_memory):
_inherit = "wizard.open.calling.partner"
def create_incoming_phonecall(self, cr, uid, ids, crm_categ, context=None):
'''Started by button on 'open calling partner wizard'''
partner_address_id = self.browse(cr, uid, ids[0], context=context).partner_address_id.id
action = self.pool.get('res.partner.address').create_open_phonecall(cr, uid, [partner_address_id], crm_categ='Inbound', context=context)
action['nodestroy'] = False
return action
wizard_open_calling_partner()
Loading…
Cancel
Save