From 8bc7cebd9c19ae8f77378d115a8401d7b7de56b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Wed, 3 Jan 2018 11:42:39 +0100 Subject: [IMP] web: many2many editable list with X remove icon (#20978) In many2many lists, the remove record from the widget is a trash bin. It is confusing, as people feel they are deleting it when they are only unlinking it. So in many2many, we propose to change the trash icon by a 'X'. This icon appears in many2many relations and in many2many widgets: even though hr.expense.sheet defines the expense lines as a one2many, it uses a many2many widget, so we use a 'X' instead of the trash bin. To avoid ambiguity, we decided to rename 'delete' to 'remove'. --- addons/web/static/src/js/fields/relational_fields.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'addons/web/static/src/js/fields/relational_fields.js') diff --git a/addons/web/static/src/js/fields/relational_fields.js b/addons/web/static/src/js/fields/relational_fields.js index 4ad3dc1a828..52654c4ce3a 100644 --- a/addons/web/static/src/js/fields/relational_fields.js +++ b/addons/web/static/src/js/fields/relational_fields.js @@ -635,11 +635,11 @@ var FieldX2Many = AbstractField.extend({ discard_changes: '_onDiscardChanges', edit_line: '_onEditLine', field_changed: '_onFieldChanged', - kanban_record_delete: '_onDeleteRecord', - list_record_delete: '_onDeleteRecord', open_record: '_onOpenRecord', - save_line: '_onSaveLine', + kanban_record_delete: '_onRemoveRecord', + list_record_remove: '_onRemoveRecord', resequence: '_onResequence', + save_line: '_onSaveLine', toggle_column_order: '_onToggleColumnOrder', }), @@ -661,6 +661,7 @@ var FieldX2Many = AbstractField.extend({ this.operations = []; this.isReadonly = this.mode === 'readonly'; this.view = this.attrs.views[this.attrs.mode]; + this.isMany2Many = this.field.type === 'many2many' || this.attrs.widget === 'many2many'; this.activeActions = {}; this.recordParams = {fieldName: this.name, viewType: this.viewType}; var arch = this.view && this.view.arch; @@ -798,6 +799,7 @@ var FieldX2Many = AbstractField.extend({ mode: this.mode, addCreateLine: !this.isReadonly && this.activeActions.create, addTrashIcon: !this.isReadonly && this.activeActions.delete, + isMany2Many: this.isMany2Many, viewType: viewType, columnInvisibleFields: this.currentColInvisibleFields, }); @@ -947,10 +949,9 @@ var FieldX2Many = AbstractField.extend({ * @private * @param {OdooEvent} ev */ - _onDeleteRecord: function (ev) { + _onRemoveRecord: function (ev) { ev.stopPropagation(); - var shouldForget = this.attrs.widget === 'many2many' || this.field.type === 'many2many'; - var operation = shouldForget ? 'FORGET' : 'DELETE'; + var operation = this.isMany2Many ? 'FORGET' : 'DELETE'; this._setValue({ operation: operation, ids: [ev.data.id], -- cgit v1.2.3