From 81f01f52a1c4d1ea7b4a179c7428b536929fb99f Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 24 May 2016 01:02:02 +0200 Subject: [PATCH] Restore the object crm.phonecall that was dropped in v9 community Proper name_get for callerid for applicants Small bugfixes/enhancements --- asterisk_click2dial/res_users_view.xml | 12 ++ asterisk_click2dial/scripts/set_name_agi.py | 6 +- base_phone/static/src/js/phone_widget.js | 18 +- base_phone/wizard/number_not_found_view.xml | 1 - crm_phone/__openerp__.py | 9 +- crm_phone/crm_phone.py | 152 ++++++++++++++++- crm_phone/demo/crm_phonecall.xml | 59 +++++++ crm_phone/security/ir.model.access.csv | 3 + crm_phone/security/phonecall_security.xml | 28 +++ crm_phone/{crm_view.xml => view/crm_lead.xml} | 16 ++ crm_phone/view/crm_phonecall.xml | 160 ++++++++++++++++++ crm_phone/view/res_partner.xml | 30 ++++ .../res_users.xml} | 0 crm_phone/wizard/create_crm_phonecall.py | 19 +-- crm_phone/wizard/number_not_found_view.xml | 6 +- hr_phone/security/ir.model.access.csv | 1 + hr_recruitment_phone/hr_recruitment_phone.py | 16 ++ 17 files changed, 500 insertions(+), 36 deletions(-) create mode 100644 crm_phone/demo/crm_phonecall.xml create mode 100644 crm_phone/security/phonecall_security.xml rename crm_phone/{crm_view.xml => view/crm_lead.xml} (67%) create mode 100644 crm_phone/view/crm_phonecall.xml create mode 100644 crm_phone/view/res_partner.xml rename crm_phone/{res_users_view.xml => view/res_users.xml} (100%) diff --git a/asterisk_click2dial/res_users_view.xml b/asterisk_click2dial/res_users_view.xml index 31f74c9..f0cc4a9 100644 --- a/asterisk_click2dial/res_users_view.xml +++ b/asterisk_click2dial/res_users_view.xml @@ -35,5 +35,17 @@ + + asterisk_click2dial.users.preferences.form + res.users + + + + 0 + + + + + diff --git a/asterisk_click2dial/scripts/set_name_agi.py b/asterisk_click2dial/scripts/set_name_agi.py index c9c2f9d..f4a8761 100755 --- a/asterisk_click2dial/scripts/set_name_agi.py +++ b/asterisk_click2dial/scripts/set_name_agi.py @@ -1,6 +1,6 @@ #! /usr/bin/python -# -*- encoding: utf-8 -*- -# Copyright (C) 2010-2015 Alexis de Lattre +# -*- coding: utf-8 -*- +# © 2010-2016 Akretion (Alexis de Lattre ) # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -104,7 +104,7 @@ __version__ = "0.6" # Name that will be displayed if there is no match # and no geolocalisation. Set it to False if you don't want # to have a 'not_found_name' when nothing is found -not_found_name = "Not in Odoo" +not_found_name = False # Define command line options options = [ diff --git a/base_phone/static/src/js/phone_widget.js b/base_phone/static/src/js/phone_widget.js index 7202135..1e0ac9a 100644 --- a/base_phone/static/src/js/phone_widget.js +++ b/base_phone/static/src/js/phone_widget.js @@ -7,6 +7,7 @@ odoo.define('base_phone.phone_widget', function (require) { var core = require('web.core'); var formwidgets = require('web.form_widgets'); +var web_client = require('web.web_client'); var _t = core._t; @@ -76,7 +77,7 @@ var FieldPhone = formwidgets.FieldChar.extend({ target: 'new', context: context, }; - formwidgets.client.action_manager.do_action(action); + web_client.action_manager.do_action(action); } } }); @@ -133,7 +134,7 @@ if(!core.form_widget_registry.get('phone')){ } /* -var Column = require('web.list_view.js'); +var Column = require('web.ListView'); var ColumnPhone = Column.extend({ // ability to add widget="phone" in TREE view @@ -141,18 +142,21 @@ var ColumnPhone = Column.extend({ console.log('row_data=' + row_data); console.log('options='); console.log(options); - var value = row_data[this.id].value; - if (value && this.widget === 'phone') { + var value = row_data[this.id].value; + if (value) { readable_space = formatInternational('', value); readable_no_break_space = readable_space.replace(/\s/g, ' '); + console('special return'); return readable_no_break_space; - } + } console.log('return normal'); return this._super(row_data, options); } }); +if (!core.list_widget_registry.get('phone')) { + core.list_widget_registry.add('field.phone', ColumnPhone); +// a mon avis, il y a une mauvaise compréhension : fields.phone signifiera fields.Phone dans le python +} */ -core.list_widget_registry.add('field.phone', ColumnPhone); -*/ }); diff --git a/base_phone/wizard/number_not_found_view.xml b/base_phone/wizard/number_not_found_view.xml index 0df07e0..fc51914 100644 --- a/base_phone/wizard/number_not_found_view.xml +++ b/base_phone/wizard/number_not_found_view.xml @@ -14,7 +14,6 @@
-
+
+ + + + + diff --git a/crm_phone/res_users_view.xml b/crm_phone/view/res_users.xml similarity index 100% rename from crm_phone/res_users_view.xml rename to crm_phone/view/res_users.xml diff --git a/crm_phone/wizard/create_crm_phonecall.py b/crm_phone/wizard/create_crm_phonecall.py index 45570c8..733ffad 100644 --- a/crm_phone/wizard/create_crm_phonecall.py +++ b/crm_phone/wizard/create_crm_phonecall.py @@ -6,33 +6,28 @@ from openerp import models, api, _ import phonenumbers -# TODO : crm.phonecall : doesn't exist any more... what is the replacement ? - class WizardCreateCrmPhonecall(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') + return self._create_open_crm_phonecall('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( + def _create_open_crm_phonecall(self, direction='outbound'): + teams = self.env['crm.team'].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, + 'default_direction': direction, + 'default_team_id': teams and teams[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)] + domain = [('partner_id', 'child_of', 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 @@ -50,7 +45,7 @@ class WizardCreateCrmPhonecall(models.TransientModel): 'type': 'ir.actions.act_window', 'res_model': 'crm.phonecall', 'domain': domain, - 'view_mode': 'form,tree', + 'view_mode': 'form,tree,calendar', 'nodestroy': False, # close the pop-up wizard after action 'target': 'current', 'context': action_ctx, diff --git a/crm_phone/wizard/number_not_found_view.xml b/crm_phone/wizard/number_not_found_view.xml index dcc52a2..0b685b8 100644 --- a/crm_phone/wizard/number_not_found_view.xml +++ b/crm_phone/wizard/number_not_found_view.xml @@ -16,14 +16,16 @@