[IMP] web: add an option to avoid deleting a o2m records

issue opw-668776
This commit is contained in:
Christophe Matthieu
2016-02-22 09:43:00 +01:00
committed by Goffin Simon
parent 8dd48ae329
commit bf26f0f498
@@ -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));