Browse Source
Add support for "Create CRM phonecall" on leads (and not only partners)
Add support for "Create CRM phonecall" on leads (and not only partners)
Re-organise the codebase to prepare the arrival of a new module for a telephony system other than Asteriskpull/31/head
Alexis de Lattre
10 years ago
14 changed files with 165 additions and 196 deletions
-
40asterisk_click2dial/asterisk_click2dial.py
-
1asterisk_click2dial_crm/__init__.py
-
2asterisk_click2dial_crm/__openerp__.py
-
35asterisk_click2dial_crm/asterisk_click2dial_crm.py
-
23asterisk_click2dial_crm/wizard/__init__.py
-
61asterisk_click2dial_crm/wizard/create_crm_phonecall.py
-
74base_phone/base_phone.py
-
10base_phone/static/src/js/phone_widget.js
-
2crm_phone/__openerp__.py
-
31crm_phone/crm_phone.py
-
8crm_phone/res_users_view.xml
-
1crm_phone/wizard/__init__.py
-
73crm_phone/wizard/create_crm_phonecall.py
-
0crm_phone/wizard/create_crm_phonecall_view.xml
@ -1,23 +0,0 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Asterisk click2dial CRM module for 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 . import create_crm_phonecall |
@ -1,61 +0,0 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# Asterisk click2dial CRM module for 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 wizard_create_crm_phonecall(orm.TransientModel): |
|||
_name = "wizard.create.crm.phonecall" |
|||
|
|||
def button_create_outgoing_phonecall(self, cr, uid, ids, context=None): |
|||
partner = self.pool['res.partner'].browse( |
|||
cr, uid, context.get('partner_id'), context=context) |
|||
return self._create_open_crm_phonecall( |
|||
cr, uid, partner, crm_categ='Outbound', context=context) |
|||
|
|||
def _create_open_crm_phonecall( |
|||
self, cr, uid, partner, crm_categ, context=None): |
|||
if context is None: |
|||
context = {} |
|||
categ_ids = self.pool['crm.case.categ'].search( |
|||
cr, uid, [('name', '=', crm_categ)], context={'lang': 'en_US'}) |
|||
case_section_ids = self.pool['crm.case.section'].search( |
|||
cr, uid, [('member_ids', 'in', uid)], context=context) |
|||
context.update({ |
|||
'default_partner_id': partner.id or False, |
|||
'default_partner_phone': partner.phone, |
|||
'default_partner_mobile': partner.mobile, |
|||
'default_categ_id': categ_ids and categ_ids[0] or False, |
|||
'default_section_id': |
|||
case_section_ids and case_section_ids[0] or False, |
|||
}) |
|||
|
|||
return { |
|||
'name': partner.name, |
|||
'domain': [('partner_id', '=', partner.id)], |
|||
'res_model': 'crm.phonecall', |
|||
'view_mode': 'form,tree', |
|||
'type': 'ir.actions.act_window', |
|||
'nodestroy': False, # close the pop-up wizard after action |
|||
'target': 'current', |
|||
'context': context, |
|||
} |
@ -0,0 +1,73 @@ |
|||
# -*- encoding: utf-8 -*- |
|||
############################################################################## |
|||
# |
|||
# CRM Phone module for Odoo |
|||
# Copyright (c) 2012-2015 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 import models, api, _ |
|||
import phonenumbers |
|||
|
|||
|
|||
class wizard_create_crm_phonecall(models.TransientModel): |
|||
_name = "wizard.create.crm.phonecall" |
|||
|
|||
@api.multi |
|||
def button_create_outgoing_phonecall(self): |
|||
self.ensure_one() |
|||
return self._create_open_crm_phonecall(crm_categ='Outbound') |
|||
|
|||
@api.model |
|||
def _create_open_crm_phonecall(self, crm_categ): |
|||
categ = self.with_context(lang='en_US').env['crm.case.categ'].search( |
|||
[('name', '=', crm_categ)]) |
|||
case_section = self.env['crm.case.section'].search( |
|||
[('member_ids', 'in', self._uid)]) |
|||
action_ctx = self.env.context.copy() |
|||
action_ctx.update({ |
|||
'default_categ_id': categ and categ[0].id or False, |
|||
'default_section_id': |
|||
case_section and case_section[0].id or False, |
|||
}) |
|||
domain = False |
|||
if self.env.context.get('click2dial_model') == 'res.partner': |
|||
partner_id = self.env.context.get('click2dial_id') |
|||
action_ctx['default_partner_id'] = partner_id |
|||
domain = [('partner_id', '=', partner_id)] |
|||
elif self.env.context.get('click2dial_model') == 'crm.lead': |
|||
lead_id = self.env.context.get('click2dial_id') |
|||
action_ctx['default_opportunity_id'] = lead_id |
|||
domain = [('opportunity_id', '=', lead_id)] |
|||
parsed_num = phonenumbers.parse(self.env.context.get('phone_number')) |
|||
number_type = phonenumbers.number_type(parsed_num) |
|||
if number_type == 1: |
|||
action_ctx['default_partner_mobile'] =\ |
|||
self.env.context.get('phone_number') |
|||
else: |
|||
action_ctx['default_partner_phone'] =\ |
|||
self.env.context.get('phone_number') |
|||
return { |
|||
'name': _('Phone Call'), |
|||
'domain': domain, |
|||
'res_model': 'crm.phonecall', |
|||
'view_mode': 'form,tree', |
|||
'type': 'ir.actions.act_window', |
|||
'nodestroy': False, # close the pop-up wizard after action |
|||
'target': 'current', |
|||
'context': action_ctx, |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue