Browse Source

Improve style of Dial button

Improve messages in notification pop-up
Fix short disconnect upon click2dial
Add active button for asterisk.server form view
Fix add call in CRM wizard
pull/180/head
Alexis de Lattre 6 years ago
parent
commit
91637fd0cf
  1. 13
      asterisk_click2dial/static/src/js/asterisk_click2dial.js
  2. 10
      asterisk_click2dial/views/asterisk_server.xml
  3. 9
      base_phone/static/src/js/phone_widget.js
  4. 5
      crm_phone/wizard/create_crm_phonecall.py

13
asterisk_click2dial/static/src/js/asterisk_click2dial.js

@ -7,7 +7,6 @@ odoo.define('asterisk_click2dial.systray.OpenCaller', function (require) {
var core = require('web.core'); var core = require('web.core');
var SystrayMenu = require('web.SystrayMenu'); var SystrayMenu = require('web.SystrayMenu');
var web_client = require('web.web_client');
var Widget = require('web.Widget'); var Widget = require('web.Widget');
var _t = core._t; var _t = core._t;
@ -42,8 +41,8 @@ var OpenCallerMenu = Widget.extend({
// console.log('RESULT RPC isNaN r='+isNaN(r)); // console.log('RESULT RPC isNaN r='+isNaN(r));
if (r === false) { if (r === false) {
self.do_warn( self.do_warn(
_t('Failure'),
_t('Problem in the connection to Asterisk'),
_t('IPBX error'),
_t('Calling party number not retreived from IPBX or IPBX unreachable by Odoo'),
false); false);
} }
else if (typeof r == 'string' && isNaN(r)) { else if (typeof r == 'string' && isNaN(r)) {
@ -62,13 +61,13 @@ var OpenCallerMenu = Widget.extend({
target: 'new', target: 'new',
context: {'default_calling_number': r}, context: {'default_calling_number': r},
}; };
web_client.action_manager.do_action(action);
self.do_action(action);
} }
else if (typeof r == 'object' && r.length == 3) { else if (typeof r == 'object' && r.length == 3) {
self.do_notify( self.do_notify(
_t('Success'),
_.str.sprintf(_t('Moving to %s ID %d'), r[0], r[1]),
_.str.sprintf(_t("On the phone with '%s'"), r[2]),
_.str.sprintf(_t("Moving to form view of '%s' (%s ID %d)"), r[2], r[0], r[1]),
false); false);
var action = { var action = {
type: 'ir.actions.act_window', type: 'ir.actions.act_window',
@ -86,7 +85,7 @@ var OpenCallerMenu = Widget.extend({
target: 'current', target: 'current',
context: {}, context: {},
}; };
web_client.action_manager.do_action(action);
self.do_action(action);
} }
}); });
}, },

10
asterisk_click2dial/views/asterisk_server.xml

@ -14,6 +14,8 @@
<search string="Asterisk Server Search"> <search string="Asterisk Server Search">
<field name="name" <field name="name"
filter_domain="['|', ('name', 'ilike', self), ('ip_address', 'ilike', self)]"/> filter_domain="['|', ('name', 'ilike', self), ('ip_address', 'ilike', self)]"/>
<separator/>
<filter string="Archived" name="inactive" domain="[('active', '=', False)]"/>
</search> </search>
</field> </field>
</record> </record>
@ -24,6 +26,13 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Asterisk Servers"> <form string="Asterisk Servers">
<sheet> <sheet>
<div class="oe_button_box" name="button_box">
<button name="toggle_active" type="object"
class="oe_stat_button" icon="fa-archive">
<field name="active" widget="boolean_button"
options='{"terminology": "archive"}'/>
</button>
</div>
<div class="oe_title"> <div class="oe_title">
<label for="name" string="Server Name" class="oe_edit_only"/> <label for="name" string="Server Name" class="oe_edit_only"/>
<h1> <h1>
@ -33,7 +42,6 @@
<group name="main"> <group name="main">
<field name="company_id" <field name="company_id"
groups="base.group_multi_company"/> groups="base.group_multi_company"/>
<field name="active" />
</group> </group>
<group name="ami" string="Asterisk Manager Interface"> <group name="ami" string="Asterisk Manager Interface">
<field name="ip_address" /> <field name="ip_address" />

9
base_phone/static/src/js/phone_widget.js

@ -34,7 +34,7 @@ odoo.define('base_phone.updatedphone_widget', function (require) {
var self = this; var self = this;
// create our link // create our link
var dial = $('<a href="#" class="dial">📞 Dial</a>');
var dial = $('<a href="#" class="dial"><div class="label label-primary">☎ Dial</div></a>');
// add a parent element // add a parent element
// it's not possible to append to $el directly // it's not possible to append to $el directly
@ -53,7 +53,7 @@ odoo.define('base_phone.updatedphone_widget', function (require) {
click2dial: function(phone_num) { click2dial: function(phone_num) {
var self = this; var self = this;
this.do_notify( this.do_notify(
_t('Click2dial started'),
_.str.sprintf(_t('Click2dial to %s'), phone_num),
_t('Unhook your ringing phone'), _t('Unhook your ringing phone'),
false); false);
var params = { var params = {
@ -65,13 +65,12 @@ odoo.define('base_phone.updatedphone_widget', function (require) {
params: params, params: params,
}).then(function(r) { }).then(function(r) {
console.log('successfull', r); console.log('successfull', r);
// TODO: check why it never goes in there
if (r === false) { if (r === false) {
self.do_warn("Click2dial failed"); self.do_warn("Click2dial failed");
} else if (typeof r === 'object') { } else if (typeof r === 'object') {
self.do_notify( self.do_notify(
_t('Click2dial successfull'), _t('Click2dial successfull'),
_t('Number dialed:') + ' ' + r.dialed_number,
_.str.sprintf(_t('Number dialed: %s'), r.dialed_number),
false); false);
if (r.action_model) { if (r.action_model) {
var action = { var action = {
@ -83,7 +82,7 @@ odoo.define('base_phone.updatedphone_widget', function (require) {
target: 'new', target: 'new',
context: params, context: params,
}; };
return this.do_action(action);
return self.do_action(action);
} }
} }
}, function (r) { }, function (r) {

5
crm_phone/wizard/create_crm_phonecall.py

@ -30,15 +30,12 @@ class WizardCreateCrmPhonecall(models.TransientModel):
'default_direction': direction, 'default_direction': direction,
'default_team_id': teams and teams[0].id or False, 'default_team_id': teams and teams[0].id or False,
}) })
domain = False
if self.env.context.get('click2dial_model') == 'res.partner': if self.env.context.get('click2dial_model') == 'res.partner':
partner_id = self.env.context.get('click2dial_id') partner_id = self.env.context.get('click2dial_id')
action_ctx['default_partner_id'] = partner_id action_ctx['default_partner_id'] = partner_id
domain = [('partner_id', 'child_of', partner_id)]
elif self.env.context.get('click2dial_model') == 'crm.lead': elif self.env.context.get('click2dial_model') == 'crm.lead':
lead_id = self.env.context.get('click2dial_id') lead_id = self.env.context.get('click2dial_id')
action_ctx['default_opportunity_id'] = lead_id action_ctx['default_opportunity_id'] = lead_id
domain = [('opportunity_id', '=', lead_id)]
parsed_num = phonenumbers.parse(self.env.context.get('phone_number')) parsed_num = phonenumbers.parse(self.env.context.get('phone_number'))
number_type = phonenumbers.number_type(parsed_num) number_type = phonenumbers.number_type(parsed_num)
if number_type == 1: if number_type == 1:
@ -50,8 +47,8 @@ class WizardCreateCrmPhonecall(models.TransientModel):
action = self.env['ir.actions.act_window'].for_xml_id( action = self.env['ir.actions.act_window'].for_xml_id(
'crm_phone', 'crm_phonecall_action') 'crm_phone', 'crm_phonecall_action')
action.update({ action.update({
'domain': domain,
'view_mode': 'form,tree,calendar', 'view_mode': 'form,tree,calendar',
'views': False,
'context': action_ctx, 'context': action_ctx,
}) })
return action return action
Loading…
Cancel
Save