From 6e15a9cd24eb5825ea615512a4ee834f131a60f7 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 24 Apr 2018 10:32:45 +0200 Subject: [FIX] web: one2many form view with action button Assume a one2many field inside a form, displaying field A in its list view, and a field B in its (dialog) form view. Moreover, there is an action button in the dialog, which updates the value of B. Before this rev., B wasn't correctly reloaded when the button was clicked, because the BasicModel reloaded the fields on the list view (i.e. field A), whereas it should reload the fields in both views. This fix is twofold. First, we force the viewType to 'form' when the record is reloaded, instead of the default ('list'), so that fields in the form view are correctly reloaded. Second, when we open the form view in the dialog, we add the fields of the list view to the dict of fields of the form view, so that the form is aware of those fields and can ask the model to reload them (still without displaying them). Fixes #24189 --- addons/web/static/src/js/fields/relational_fields.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'addons/web/static/src/js/fields/relational_fields.js') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 5c670e11c73..c9fe8648c17 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -1293,10 +1293,7 @@ var FieldOne2Many = FieldX2Many.extend({ var self = this; var id = ev.data.id; - var onSaved = function (record, hasChanged) { - if (!hasChanged) { - return; - } + var onSaved = function (record) { if (_.some(self.value.data, {id: record.id})) { // the record already exists in the relation, so trigger an // empty 'UPDATE' operation when the user clicks on 'Save' in -- cgit v1.2.3 From 2bd92cc581463c73760303bba967a0d0fe553786 Mon Sep 17 00:00:00 2001 From: Mohammed Shekha Date: Wed, 6 Dec 2017 16:59:59 +0530 Subject: [FIX] web: use correct href in link for m2o With a better href, many2one in readonly mode can be opened in new tab. Related to task: #32919 --- addons/web/static/src/js/fields/relational_fields.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/web/static/src/js/fields/relational_fields.js') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index c9fe8648c17..377e1b24003 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -340,8 +340,8 @@ var FieldMany2One = AbstractField.extend({ _renderReadonly: function () { var value = _.escape((this.m2o_value || "").trim()).split("\n").join("
"); this.$el.html(value); - if (!this.nodeOptions.no_open) { - this.$el.attr('href', '#'); + if (!this.nodeOptions.no_open && this.value) { + this.$el.attr('href', _.str.sprintf('#id=%s&model=%s', this.value.res_id, this.field.relation)); this.$el.addClass('o_form_uri'); } }, -- cgit v1.2.3