summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js
diff options
context:
space:
mode:
authorDenis Ledoux <dle@odoo.com>2014-12-08 15:33:43 +0100
committerDenis Ledoux <dle@odoo.com>2014-12-08 15:42:24 +0100
commiteba1c56f9798681eb94496452fb6aed898e7e18c (patch)
treedac4ba9bbc685fad90fa2479e8ea9c60f5d9e85c /addons/web/static/src/js
parent284ca73b1c6fd70352a2829f5b2cea92647348e2 (diff)
[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
Diffstat (limited to 'addons/web/static/src/js')
-rw-r--r--addons/web/static/src/js/view_form.js16
1 files changed, 9 insertions, 7 deletions
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();
},