From eba1c56f9798681eb94496452fb6aed898e7e18c Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Mon, 8 Dec 2014 15:33:43 +0100 Subject: [FIX] web: ensure one2many field destruction on button cancel The destruction of one2many fields is forced with the event change:effective_readonly This revision add the forced destruction for cancel(discard) button as well Otherwise, one2many fields are not properly destroyed when hitting the button "discard" (from save or discard). This can be problematic for one2many editable list views (such as invoice lines) if you discard while having a mandatory field not filled in the invoice line: You can't recreate an invoice, the one2many editable list is messed up Use case: Create an invoice, create a line, leave the description, required field, empty. Then, discard. Then, click on create. opw-616946 --- addons/web/static/src/js/view_form.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'addons/web/static/src/js/view_form.js') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index be16faa309a..ed246e58da6 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -3540,16 +3540,18 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({ var self = this; self.load_views(); - this.is_loaded.done(function() { - self.on("change:effective_readonly", self, function() { - self.is_loaded = self.is_loaded.then(function() { - self.viewmanager.destroy(); - return $.when(self.load_views()).done(function() { - self.reload_current_view(); - }); + var destroy = function() { + self.is_loaded = self.is_loaded.then(function() { + self.viewmanager.destroy(); + return $.when(self.load_views()).done(function() { + self.reload_current_view(); }); }); + }; + this.is_loaded.done(function() { + self.on("change:effective_readonly", self, destroy); }); + this.view.on("on_button_cancel", self, destroy); this.is_started = true; this.reload_current_view(); }, -- cgit v1.2.3 From 9f9e7ef0e1ca1d2f5fc5e0a166499c95359dbbf3 Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Tue, 9 Dec 2014 12:40:32 +0100 Subject: [FIX] web: user lang has the priority on partner lang Potentialy, the timezone too. On item action click (such as menus in More.. and Print..), the data in form view had the priority on user context (through the sidebar_eval_context) Therefore, if a field "lang" was present in the form view (like in partner form), the web/action/load xmlrpc call was using the partner language instead of the user language. Example of wrong use case before the fix: - Set the user language in French, then go to a partner form of a partner with English set as language - Click on any button of the partner form, such as the "Invoices" button, notice that the last item of the breadcrumb is in English, instead of Frenh (the user language) - Click on any menu opening a wizard in the More.. dropdown menu, notice that the wizard title is in English instead of French - Print any report from the Print dropdown menu, notice that the report file name is in English. If you print the same report for the same partner but from the list view, the report file name is in French. --- addons/web/static/src/js/view_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js/view_form.js') diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index ed246e58da6..aceb3e665fd 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -1165,7 +1165,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM }, build_eval_context: function() { var a_dataset = this.dataset; - return new instance.web.CompoundContext(a_dataset.get_context(), this._build_view_fields_values()); + return new instance.web.CompoundContext(this._build_view_fields_values(), a_dataset.get_context()); }, }); -- cgit v1.2.3