diff --git a/addons/crm/static/src/js/crm_case_section.js b/addons/crm/static/src/js/crm_case_section.js index 05b71ade809..22d042c4f3e 100644 --- a/addons/crm/static/src/js/crm_case_section.js +++ b/addons/crm/static/src/js/crm_case_section.js @@ -32,18 +32,18 @@ openerp.crm = function(openerp) { ], }); + var flag_open = false; if ($el.data('action')) { $el.click(function (event) { event.stopPropagation(); + flag_open = false; if (!self.view.is_action_enabled('edit')) { return; } - if ($el.find(".oe_justgage_edit").size()) { - $el.find(".oe_justgage_edit").remove(); - } else { + if (!$el.find(".oe_justgage_edit").size()) { var $svg = $el.find('svg'); - $div = $('
'); - $input = $('').val($el.data('value')); + $div = $(''); + $input = $('').val($el.data('value')); $div.append($input); $el.prepend($div) $input.focus() @@ -59,8 +59,21 @@ openerp.crm = function(openerp) { } } }) - .click(function (event) {event.stopPropagation();}); + .click(function (event) { + event.stopPropagation(); + flag_open = false; + }) + .blur(function (event) { + if(!flag_open) { + $el.find(".oe_justgage_edit").remove(); + } else { + flag_open = false; + setTimeout(function () {$input.focus();}, 0); + } + }); } + }).mousedown(function () { + flag_open = true; }); } });