From d57b50992b555300048d16f91589cce6d0ead8db Mon Sep 17 00:00:00 2001 From: Raimon Esteve Date: Fri, 1 Jun 2012 11:06:59 +0200 Subject: [PATCH] [ADD] asterisk_click2dial_crm --- asterisk_click2dial_crm/__init__.py | 25 ++++ asterisk_click2dial_crm/__openerp__.py | 44 +++++++ .../i18n/asterisk_click2dial_crm.pot | 38 ++++++ asterisk_click2dial_crm/i18n/ca.po | 44 +++++++ asterisk_click2dial_crm/i18n/es.po | 44 +++++++ .../res_partner_address.py | 110 ++++++++++++++++++ 6 files changed, 305 insertions(+) create mode 100644 asterisk_click2dial_crm/__init__.py create mode 100644 asterisk_click2dial_crm/__openerp__.py create mode 100644 asterisk_click2dial_crm/i18n/asterisk_click2dial_crm.pot create mode 100644 asterisk_click2dial_crm/i18n/ca.po create mode 100644 asterisk_click2dial_crm/i18n/es.po create mode 100644 asterisk_click2dial_crm/res_partner_address.py diff --git a/asterisk_click2dial_crm/__init__.py b/asterisk_click2dial_crm/__init__.py new file mode 100644 index 0000000..2bff310 --- /dev/null +++ b/asterisk_click2dial_crm/__init__.py @@ -0,0 +1,25 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (c) 2011 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. +# Jesús Martín +# $Id$ +# +# 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 . +# +############################################################################## + +import res_partner_address + diff --git a/asterisk_click2dial_crm/__openerp__.py b/asterisk_click2dial_crm/__openerp__.py new file mode 100644 index 0000000..46b6057 --- /dev/null +++ b/asterisk_click2dial_crm/__openerp__.py @@ -0,0 +1,44 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (c) 2011 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. +# Jesús Martín +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +{ + 'name': 'Asterisk Click2dial CRM', + "version": "0.1", + "author": "Zikzakmedia SL", + "website": "http://www.zikzakmedia.com", + "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. + """, + "depends": [ + 'asterisk_click2dial', + 'crm', + ], + "init_xml" : [ ], + "demo_xml" : [ ], + "update_xml" : [ + ], + "installable": True, +} diff --git a/asterisk_click2dial_crm/i18n/asterisk_click2dial_crm.pot b/asterisk_click2dial_crm/i18n/asterisk_click2dial_crm.pot new file mode 100644 index 0000000..970ec47 --- /dev/null +++ b/asterisk_click2dial_crm/i18n/asterisk_click2dial_crm.pot @@ -0,0 +1,38 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * asterisk_click2dial_crm +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.0.2\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2011-11-09 15:28+0000\n" +"PO-Revision-Date: 2011-11-09 15:28+0000\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: asterisk_click2dial_crm +#: model:ir.model,name:asterisk_click2dial_crm.model_res_partner_address +msgid "Partner Addresses" +msgstr "Partner Addresses" + +#. module: asterisk_click2dial_crm +#: model:ir.module.module,description:asterisk_click2dial_crm.module_meta_information +msgid "\n" +" Create a outbound phone call when the user makes a call phone by clicking\n" +" the click2dial button of the partner address view, and opens it in a new tab.\n" +" " +msgstr "\n" +" Create a outbound phone call when the user makes a call phone by clicking\n" +" the click2dial button of the partner address view, and opens it in a new tab.\n" +" " + +#. module: asterisk_click2dial_crm +#: model:ir.module.module,shortdesc:asterisk_click2dial_crm.module_meta_information +msgid "Asterisk Click2dial CRM" +msgstr "Asterisk Click2dial CRM" + diff --git a/asterisk_click2dial_crm/i18n/ca.po b/asterisk_click2dial_crm/i18n/ca.po new file mode 100644 index 0000000..b50b2d9 --- /dev/null +++ b/asterisk_click2dial_crm/i18n/ca.po @@ -0,0 +1,44 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * asterisk_click2dial_crm +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.0.2\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2011-11-09 15:28+0000\n" +"PO-Revision-Date: 2011-11-09 16:30+0100\n" +"Last-Translator: Jesús Martín \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" + +#. module: asterisk_click2dial_crm +#: model:ir.model,name:asterisk_click2dial_crm.model_res_partner_address +msgid "Partner Addresses" +msgstr "Adreça de l'empresa" + +#. module: asterisk_click2dial_crm +#: model:ir.module.module,description:asterisk_click2dial_crm.module_meta_information +msgid "" +"\n" +" Create a outbound phone call when the user makes a call phone by clicking\n" +" the click2dial button of the partner address view, and opens it in a new tab.\n" +" " +msgstr "" +"\n" +" Crea una trucada de telèfon sortint quan l'usuari fa una trucada de telèfon\n" +" mitjançant el botó click2dial de la vista d'adreces de l'empresa i l'obre a una\n" +" nova pestanya.\n" +" " + +#. module: asterisk_click2dial_crm +#: model:ir.module.module,shortdesc:asterisk_click2dial_crm.module_meta_information +msgid "Asterisk Click2dial CRM" +msgstr "Asterisk Click2dial CRM" + +#~ msgid "Reconciliation" +#~ msgstr "Reconciliació" + diff --git a/asterisk_click2dial_crm/i18n/es.po b/asterisk_click2dial_crm/i18n/es.po new file mode 100644 index 0000000..a91196e --- /dev/null +++ b/asterisk_click2dial_crm/i18n/es.po @@ -0,0 +1,44 @@ +# Translation of OpenERP Server. +# This file contains the translation of the following modules: +# * asterisk_click2dial_crm +# +msgid "" +msgstr "" +"Project-Id-Version: OpenERP Server 6.0.2\n" +"Report-Msgid-Bugs-To: support@openerp.com\n" +"POT-Creation-Date: 2011-11-09 15:28+0000\n" +"PO-Revision-Date: 2011-11-09 16:32+0100\n" +"Last-Translator: Jesús Martín \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: \n" + +#. module: asterisk_click2dial_crm +#: model:ir.model,name:asterisk_click2dial_crm.model_res_partner_address +msgid "Partner Addresses" +msgstr "Dirección de la empresa" + +#. module: asterisk_click2dial_crm +#: model:ir.module.module,description:asterisk_click2dial_crm.module_meta_information +msgid "" +"\n" +" Create a outbound phone call when the user makes a call phone by clicking\n" +" the click2dial button of the partner address view, and opens it in a new tab.\n" +" " +msgstr "" +"\n" +" Crea una llamada de teléfono saliente cuando el usuario hace una llamada de\n" +" teléfono mediante el botón click2dial de la vista de direcciones de la empresa y\n" +" la abre a una nueva pestaña.\n" +" " + +#. module: asterisk_click2dial_crm +#: model:ir.module.module,shortdesc:asterisk_click2dial_crm.module_meta_information +msgid "Asterisk Click2dial CRM" +msgstr "Asterisk Click2dial CRM" + +#~ msgid "Reconciliation" +#~ msgstr "Reconciliació" + diff --git a/asterisk_click2dial_crm/res_partner_address.py b/asterisk_click2dial_crm/res_partner_address.py new file mode 100644 index 0000000..aaa54d3 --- /dev/null +++ b/asterisk_click2dial_crm/res_partner_address.py @@ -0,0 +1,110 @@ +# -*- encoding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (c) 2011 Zikzakmedia S.L. (http://zikzakmedia.com) All Rights Reserved. +# Jesús Martín +# $Id$ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import osv, fields +# Lib to translate error messages +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): + ''' + This method open the phone call history when the phone click2dial + button of asterisk_click2dial module is pressed + :return the phone call history view of the partner + ''' + 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, + } + + 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 + ''' + 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, + } + + def create_phonecall(self, cr, uid, ids, context = None): + ''' + This method creates a phone call history when the phone click2dial + button of asterisk_click2dial module is pressed and opens it. + :return True + ''' + if context is None: + context = {} + + crm_phonecall_obj = self.pool.get('crm.phonecall') + partner_address = self.browse(cr, uid, ids[0], 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) + values = { + '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, + 'partner_contact': partner_address.name, + '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, + } + crm_phonecall_id = crm_phonecall_obj.create(cr, uid, values, context) + return crm_phonecall_id + +res_partner_address()