From b25c054c93e7e5123fecf3e0e1165238c423e705 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Wed, 23 Mar 2016 14:50:46 +0100 Subject: [FIX] web: prevent crash in rare case with status field Current behavior before PR: if you create a new record within a one2many field and the model's form has a clickable status bar defined, clicking this status bar will raise an exception because the virtual id (one2many_v_XXXX) will be passed to the model's write method Desired behavior after PR is merged: clicking just changes the cached value --- addons/web/static/src/js/view_form.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 9f89f729a58..72744618fa4 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -6145,13 +6145,20 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({ val = $li.data("id"); } if (val != self.get('value')) { - this.view.recursive_save().done(function() { - var change = {}; - change[self.name] = val; - self.view.dataset.write(self.view.datarecord.id, change).done(function() { - self.view.reload(); + if(!this.view.datarecord.id || + this.view.datarecord.id.toString().match(instance.web.BufferedDataSet.virtual_id_regex)) { + // don't save, only set value for not-yet-saved many2ones + self.set_value(val); + } + else { + this.view.recursive_save().done(function() { + var change = {}; + change[self.name] = val; + self.view.dataset.write(self.view.datarecord.id, change).done(function() { + self.view.reload(); + }); }); - }); + } } }, }); -- cgit v1.2.3 From 6b76b08748ac28bf475747b201e538ae38ac1c59 Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Wed, 13 Apr 2016 15:01:14 +0200 Subject: [FIX] web: don't freeze on form warning escape When the warning on form view is closed by cancel or OK button, all is well. But if the modal is closed by any other way the def will stay pending blocking next operations. This commit set the deferred as dejected if not resolved when the modale is closed. closes #11688 opw-671371 --- addons/web/static/src/js/views/form_view.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views/form_view.js b/addons/web/static/src/js/views/form_view.js index 4eba5e01243..ba181712527 100644 --- a/addons/web/static/src/js/views/form_view.js +++ b/addons/web/static/src/js/views/form_view.js @@ -831,7 +831,10 @@ var FormView = View.extend(common.FieldManagerMixin, { def.reject(); }, }; - Dialog.confirm(this, message, options); + var dialog = Dialog.confirm(this, message, options); + dialog.$modal.on('hidden.bs.modal', function() { + def.reject(); + }); return def; }, /** -- cgit v1.2.3 From 3705a868d1188905dc9c090d57727ba1cd0926b5 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 14 Apr 2016 10:05:37 +0200 Subject: [FIX] web: consistency between list and export Following commit 8276fb585, the data exported should match the data displayed on the list view. Therefore, we need to make sure that the context used match the context of the list view. When a filter is applied in the list view, the context is evaluated thanks to pyeval (see the call to `/web/dataset/search_read`). The fix is to evaluate the context in a similar way. opw-674473 --- addons/web/static/src/js/widgets/data_export.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/widgets/data_export.js b/addons/web/static/src/js/widgets/data_export.js index a73020ce9b2..d1c10098586 100644 --- a/addons/web/static/src/js/widgets/data_export.js +++ b/addons/web/static/src/js/widgets/data_export.js @@ -6,6 +6,7 @@ var crash_manager = require('web.crash_manager'); var data = require('web.data'); var Dialog = require('web.Dialog'); var framework = require('web.framework'); +var pyeval = require('web.pyeval'); var QWeb = core.qweb; var _t = core._t; @@ -427,7 +428,7 @@ var DataExport = Dialog.extend({ fields: exported_fields, ids: this.ids_to_export, domain: this.domain, - context: this.dataset.context, + context: pyeval.eval('contexts', [this.dataset._model.context()]), import_compat: !!this.$el.find("#import_compat").val(), })}, complete: framework.unblockUI, -- cgit v1.2.3 From 8aee655825262c5a1b14576a239abd9496fe785e Mon Sep 17 00:00:00 2001 From: Jeremy Kersten Date: Fri, 15 Apr 2016 16:55:34 +0200 Subject: [FIX] web: don't display view metadata for new record Close #11584 --- addons/web/static/src/js/widgets/debug_manager.js | 4 ++++ addons/web/static/src/xml/base.xml | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/widgets/debug_manager.js b/addons/web/static/src/js/widgets/debug_manager.js index 36a3a205632..5c6cfa60cfc 100644 --- a/addons/web/static/src/js/widgets/debug_manager.js +++ b/addons/web/static/src/js/widgets/debug_manager.js @@ -85,6 +85,10 @@ if (core.debug) { }, get_metadata: function() { var ds = this.dataset; + if (!this.view.get_selected_ids().length) { + console.warn(_t("No metadata available")); + return + } ds.call('get_metadata', [this.view.get_selected_ids()]).done(function(result) { new Dialog(this, { title: _.str.sprintf(_t("Metadata (%s)"), ds.model), diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 610fb2f1196..6049c64c9c0 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -204,7 +204,9 @@ - + + +
  • Toggle Form Layout Outline
  • Set Defaults
  • -- cgit v1.2.3 From e18660c3308e7fb17590e72e6b5e9aadc8ca0517 Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Fri, 8 Apr 2016 13:46:27 +0200 Subject: [FIX] web: fix iOS file downloading e8a00bc50da435d3859118ca127d20a2eb9a0cab moved the get_file function from web.session to web.ajax. The issue is that get_file uses session.url() for iOS devices. Also, in order to prevent an infinite spinner options.complete() is called before actually opening up the new window. Although this resolves the issue it still requires the user to configure Safari to allow pop-ups, otherwise they are silently ignored. opw-672882 --- addons/web/static/src/js/framework/ajax.js | 4 +++- addons/web/static/src/js/framework/session.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/framework/ajax.js b/addons/web/static/src/js/framework/ajax.js index 869e0214ad9..87fd08c7786 100644 --- a/addons/web/static/src/js/framework/ajax.js +++ b/addons/web/static/src/js/framework/ajax.js @@ -203,7 +203,9 @@ function get_file(options) { // opening a new window seems the best way to workaround if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) { var params = _.extend({}, options.data || {}, {token: token}); - var url = this.url(options.url, params); + var url = options.session.url(options.url, params); + if (options.complete) { options.complete(); } + return window.open(url); } diff --git a/addons/web/static/src/js/framework/session.js b/addons/web/static/src/js/framework/session.js index 7eae8b20a65..e16b3767e64 100644 --- a/addons/web/static/src/js/framework/session.js +++ b/addons/web/static/src/js/framework/session.js @@ -271,6 +271,7 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, { if (this.override_session){ options.data.session_id = this.session_id; } + options.session = this; ajax.get_file(options); }, synchronized_mode: function(to_execute) { -- cgit v1.2.3 From 17d0117edc01c3c28f6c035f95b1975804f164a5 Mon Sep 17 00:00:00 2001 From: fossoult Date: Tue, 5 Apr 2016 11:16:55 +0200 Subject: [FIX] web: expose list view Column widget The list view Column widget should be exposed, so it can be extended. This is required to allow the creation of other kind of list widgets. The _format method is not extendable if we don't add this line. (comment from ged) The file list_view.js should be split in two, and reorganized, but this should not be done in 9.0. --- addons/web/static/src/js/views/list_view.js | 1 + 1 file changed, 1 insertion(+) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/views/list_view.js b/addons/web/static/src/js/views/list_view.js index cb6daf093ce..229ecb86d83 100644 --- a/addons/web/static/src/js/views/list_view.js +++ b/addons/web/static/src/js/views/list_view.js @@ -1901,6 +1901,7 @@ var Column = Class.extend({ row_data[this.id].value, this, options.value_if_empty)); } }); +ListView.Column = Column; var MetaColumn = Column.extend({ meta: true, -- cgit v1.2.3 From ab8a93c85268a4d7fc0bef10c0f39fb25d1530c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 20 Apr 2016 15:25:15 +0200 Subject: [FIX] web: fix dataset to avoid race conditions The read_slice method in dataset is problematic, because it alters the dataset ids. So, if 2 consecutive read_slice are started, but the first one ends after the second one, we don't have the correct ids in the dataset. This commit just make sure that previous read_slice do not alter the ids of the next read_slice. --- addons/web/static/src/js/framework/data.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/framework/data.js b/addons/web/static/src/js/framework/data.js index a1b8e1602e9..3e9396a4e96 100644 --- a/addons/web/static/src/js/framework/data.js +++ b/addons/web/static/src/js/framework/data.js @@ -320,6 +320,7 @@ var DataSet = Class.extend(mixins.PropertiesMixin, { this.index = null; this._sort = []; this._model = new Model(model, context); + this.orderer = new utils.DropMisordered(); }, previous: function () { this.index -= 1; @@ -408,10 +409,11 @@ var DataSet = Class.extend(mixins.PropertiesMixin, { read_slice: function (fields, options) { var self = this; options = options || {}; - return this._model.query(fields) + var query = this._model.query(fields) .limit(options.limit || false) .offset(options.offset || 0) - .all().done(function (records) { + .all(); + return this.orderer.add(query).done(function (records) { self.ids = _(records).pluck('id'); }); }, -- cgit v1.2.3