summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/fields
diff options
context:
space:
mode:
authorkujiu <kujiu@users.noreply.github.com>2017-07-25 13:43:37 +0200
committerged-odoo <ged@odoo.com>2017-07-25 13:43:37 +0200
commit2771b23a35c27165b54904a9e433202a5cd226af (patch)
tree0f876d657f17b18f80400bb504853b3fa3f33d0f /addons/web/static/src/js/fields
parent044b8b1240e6b294d26df10fa4518b97ae4879f0 (diff)
[FIX] web: do not delete records for one2many with widget=many2many
Some one2many fields are called with a many2many widget to unlink records instead of delete them. But this behavior was modified with the new views and the records were deleted anyway. In this commit, we restore the previous behavior, and create a FORGET command in basic model to do that. Note that the widget='many2many' is a hack, and a better way to accomplish this is to use a new custom option. But this would be a fix for master (PR #18413)
Diffstat (limited to 'addons/web/static/src/js/fields')
-rw-r--r--addons/web/static/src/js/fields/relational_fields.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js
index 89fcb4fe406..1935e5804dd 100644
--- a/addons/web/static/src/js/fields/relational_fields.js
+++ b/addons/web/static/src/js/fields/relational_fields.js
@@ -838,8 +838,10 @@ var FieldX2Many = AbstractField.extend({
*/
_onDeleteRecord: function (ev) {
ev.stopPropagation();
+ var shouldForget = this.attrs.widget === 'many2many' || this.field.type === 'many2many';
+ var operation = shouldForget ? 'FORGET' : 'DELETE';
this._setValue({
- operation: 'REMOVE',
+ operation: operation,
ids: [ev.data.id],
});
},
@@ -1290,7 +1292,7 @@ var FieldMany2ManyBinaryMultiFiles = AbstractField.extend({
var record = _.findWhere(this.value.data, {res_id: fileID});
if (record) {
this._setValue({
- operation: 'REMOVE',
+ operation: 'FORGET',
ids: [record.id],
});
var metadata = this.metadata[record.id];
@@ -1469,7 +1471,7 @@ var FieldMany2ManyTags = AbstractField.extend({
_removeTag: function (id) {
var record = _.findWhere(this.value.data, {res_id: id});
this._setValue({
- operation: 'REMOVE',
+ operation: 'FORGET',
ids: [record.id],
});
},