Browse Source
Merge pull request #31 from akretion/8.0-cleanup-and-restructure
Merge pull request #31 from akretion/8.0-cleanup-and-restructure
Cleanup, restructure, add YAML tests, take country of partner into accountpull/33/head
Alexis de Lattre
10 years ago
24 changed files with 413 additions and 411 deletions
-
2asterisk_click2dial/__openerp__.py
-
42asterisk_click2dial/asterisk_click2dial.py
-
1asterisk_click2dial_crm/__init__.py
-
2asterisk_click2dial_crm/__openerp__.py
-
35asterisk_click2dial_crm/asterisk_click2dial_crm.py
-
18asterisk_click2dial_crm/res_users_view.xml
-
23asterisk_click2dial_crm/wizard/__init__.py
-
61asterisk_click2dial_crm/wizard/create_crm_phonecall.py
-
244base_phone/base_phone.py
-
10base_phone/static/src/js/phone_widget.js
-
8base_phone/test/phonenum.yml
-
45base_phone/wizard/reformat_all_phonenumbers.py
-
19base_phone/wizard/reformat_all_phonenumbers_view.xml
-
19crm_claim_phone/crm_claim_phone.py
-
3crm_phone/__openerp__.py
-
55crm_phone/crm_phone.py
-
37crm_phone/res_users_view.xml
-
41crm_phone/test/phonenum.yml
-
1crm_phone/wizard/__init__.py
-
73crm_phone/wizard/create_crm_phonecall.py
-
0crm_phone/wizard/create_crm_phonecall_view.xml
-
21event_phone/event_phone.py
-
21hr_phone/hr_phone.py
-
21hr_recruitment_phone/hr_recruitment_phone.py
@ -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,37 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<!-- |
||||
|
Copyright (C) 2012-2015 Akretion (http://www.akretion.com/) |
||||
|
@author: Alexis de Lattre <alexis.delattre@akretion.com> |
||||
|
The licence is in the file __openerp__.py |
||||
|
--> |
||||
|
|
||||
|
<openerp> |
||||
|
<data> |
||||
|
|
||||
|
<!-- Add option on user form view --> |
||||
|
<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="base_phone.view_users_form"/> |
||||
|
<field name="arch" type="xml"> |
||||
|
<!-- Phone tab is already invisible, cf base_phone --> |
||||
|
<group name="phone-preferences" position="inside"> |
||||
|
<field name="context_propose_creation_crm_call"/> |
||||
|
</group> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
<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="base_phone.view_users_form_simple_modif" /> |
||||
|
<field name="arch" type="xml"> |
||||
|
<!-- phone group is already invisible, cf base_phone --> |
||||
|
<group name="phone" position="inside"> |
||||
|
<field name="context_propose_creation_crm_call" readonly="0"/> |
||||
|
</group> |
||||
|
</field> |
||||
|
</record> |
||||
|
|
||||
|
</data> |
||||
|
</openerp> |
@ -0,0 +1,41 @@ |
|||||
|
- |
||||
|
Write french phone numbers in national format |
||||
|
- |
||||
|
!record {model: crm.lead, id: lead1}: |
||||
|
name: Jacques Toufaux |
||||
|
mobile: 06 42 77 42 77 |
||||
|
fax: (0) 1 45 44 42 43 |
||||
|
country_id: base.fr |
||||
|
- |
||||
|
Write swiss phone numbers in national format |
||||
|
- |
||||
|
!record {model: crm.lead, id: lead2}: |
||||
|
name: Michel Content |
||||
|
country_id: base.ch |
||||
|
phone: 04 31 23 45 67 |
||||
|
- |
||||
|
Create a german lead |
||||
|
- |
||||
|
!record {model: crm.lead, id: lead3}: |
||||
|
name: Angela Strasse |
||||
|
country_id: base.de |
||||
|
- |
||||
|
Check that valid phone numbers have been converted to E.164 |
||||
|
- |
||||
|
!python {model: crm.lead}: | |
||||
|
lead1 = self.browse(cr, uid, ref('lead1'), context=context) |
||||
|
assert lead1.mobile == '+33642774277', 'Mobile number not written in E.164 format (lead1)' |
||||
|
assert lead1.fax == '+33145444243', 'Fax number not written in E.164 format (lead1)' |
||||
|
lead2 = self.browse(cr, uid, ref('lead2'), context=context) |
||||
|
assert lead2.phone == '+41431234567', 'Phone number not written in E.164 format (lead2)' |
||||
|
self.write(cr, uid, ref('lead3'), {'phone': '0891234567'}) |
||||
|
lead3 = self.browse(cr, uid, ref('lead3'), context=context) |
||||
|
assert lead3.phone == '+49891234567', 'Phone number not written in E.164 format (lead3)' |
||||
|
- |
||||
|
Get name from phone number |
||||
|
- |
||||
|
!python {model: phone.common}: | |
||||
|
name = self.get_name_from_phone_number(cr, uid, '0642774277') |
||||
|
assert name == 'Jacques Toufaux', 'Wrong result for get_name_from_phone_number (lead1)' |
||||
|
name2 = self.get_name_from_phone_number(cr, uid, '0041431234567') |
||||
|
assert name2 == 'Michel Content', 'Wrong result for get_name_from_phone_number (lead2)' |
@ -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