From f8b48c8d61f587aa3be0d249efefc313dde1f574 Mon Sep 17 00:00:00 2001 From: Mohammed Shekha Date: Wed, 10 Sep 2014 16:18:54 +0200 Subject: [PATCH] [FIX] web: focus field in editable listview If one click on empty area of button at that time we should set focus of the field based on field order. Do not evict record from dataset, otherwise it will go to read from database and will do server call for read, if user is cancelling in one2many then there is no need to read record from database, this will also fix the issue of unorder execution of event trigger. (opw 613100) --- addons/web/static/src/js/view_form.js | 8 +++++--- addons/web/static/src/js/view_list_editable.js | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 5f5fb401d8e..58bf4d4bb4e 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -4487,9 +4487,11 @@ instance.web.form.One2ManyListView = instance.web.ListView.extend({ window.confirm = confirm; } }, - reload_record: function (record) { - // Evict record.id from cache to ensure it will be reloaded correctly - this.dataset.evict_record(record.get('id')); + reload_record: function (record, options) { + if (!options || !options['do_not_evict']) { + // Evict record.id from cache to ensure it will be reloaded correctly + this.dataset.evict_record(record.get('id')); + } return this._super(record); } diff --git a/addons/web/static/src/js/view_list_editable.js b/addons/web/static/src/js/view_list_editable.js index 62a0717d374..831d383c731 100644 --- a/addons/web/static/src/js/view_list_editable.js +++ b/addons/web/static/src/js/view_list_editable.js @@ -255,7 +255,7 @@ $recordRow.addClass('oe_edition'); self.resize_fields(); var focus_field = options && options.focus_field ? options.focus_field : undefined; - if (!focus_field){ + if (!focus_field || !fields[focus_field]){ focus_field = _.find(self.editor.form.fields_order, function(field){ return fields[field] && fields[field].$el.is(':visible:has(input)'); }); } if (focus_field && fields[focus_field]) fields[focus_field].$el.find('input').select(); @@ -364,7 +364,7 @@ // Record removed by third party during edition return; } - return self.reload_record(record); + return self.reload_record(record, {do_not_evict: true}); } var to_delete = self.records.find(function (r) { return !r.get('id'); @@ -805,7 +805,7 @@ var record_id = $(event.currentTarget).data('id'); return this.view.start_edition( record_id ? this.records.get(record_id) : null, { - focus_field: $(event.target).data('field') + focus_field: $(event.target).not(".oe_readonly").data('field') }); }, /**