From bf26f0f4982b8e95c43bad5aa39d378a1baf5dc4 Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Fri, 19 Feb 2016 13:53:46 +0100 Subject: [PATCH] [IMP] web: add an option to avoid deleting a o2m records issue opw-668776 --- addons/web/static/src/js/views/form_relational_widgets.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/addons/web/static/src/js/views/form_relational_widgets.js b/addons/web/static/src/js/views/form_relational_widgets.js index 3f39b45de78..dddda9f8578 100644 --- a/addons/web/static/src/js/views/form_relational_widgets.js +++ b/addons/web/static/src/js/views/form_relational_widgets.js @@ -632,6 +632,7 @@ var AbstractManyField = common.AbstractField.extend({ get_value: function() { var self = this, is_one2many = this.field.type === "one2many", + not_delete = this.options.not_delete, starting_ids = this.starting_ids.slice(), replace_with_ids = [], add_ids = [], @@ -663,13 +664,13 @@ var AbstractManyField = common.AbstractField.extend({ } return; } - if (!is_one2many || self.dataset.delete_all) { + if (!is_one2many || not_delete || self.dataset.delete_all) { replace_with_ids.push(id); } else { command_list.push(COMMANDS.link_to(id)); } }); - if ((!is_one2many || self.dataset.delete_all) && (replace_with_ids.length || starting_ids.length)) { + if ((!is_one2many || not_delete || self.dataset.delete_all) && (replace_with_ids.length || starting_ids.length)) { _.each(command_list, function (command) { if (command[0] === COMMANDS.UPDATE) { replace_with_ids.push(command[1]); @@ -679,7 +680,7 @@ var AbstractManyField = common.AbstractField.extend({ } _.each(starting_ids, function(id) { - if (is_one2many) { + if (is_one2many && !not_delete) { command_list.push(COMMANDS.delete(id)); } else if (is_one2many && !self.dataset.delete_all) { command_list.push(COMMANDS.forget(id));