summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/basic
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js/views/basic')
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js21
-rw-r--r--addons/web/static/src/js/views/basic/basic_view.js2
2 files changed, 22 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js
index 3ab3d7f5fa1..7e42ad6cfca 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -1178,6 +1178,27 @@ var BasicModel = AbstractModel.extend({
return Promise.resolve();
},
/**
+ * For a given resource of type 'record', get the active field, if any.
+ *
+ * Since the ORM can support both `active` and `x_active` fields for
+ * the archiving mechanism, check if any such field exists and prioritize
+ * them. The `active` field should always take priority over its custom
+ * version.
+ *
+ * @param {Object} record local resource
+ * @returns {String|undefined} the field name to use for archiving purposes
+ * ('active', 'x_active') or undefined if no such field is present
+ */
+ getActiveField: function (record) {
+ const fields = Object.keys(record.fields);
+ const has_active = fields.includes('active');
+ if (has_active) {
+ return 'active';
+ }
+ const has_x_active = fields.includes('x_active');
+ return has_x_active?'x_active':undefined
+ },
+ /**
* Toggle the active value of given records (to archive/unarchive them)
*
* @param {Array} recordIDs local ids of the records to (un)archive
diff --git a/addons/web/static/src/js/views/basic/basic_view.js b/addons/web/static/src/js/views/basic/basic_view.js
index 5cb293e866b..4566d0b9471 100644
--- a/addons/web/static/src/js/views/basic/basic_view.js
+++ b/addons/web/static/src/js/views/basic/basic_view.js
@@ -45,7 +45,7 @@ var BasicView = AbstractView.extend({
this.rendererParams.viewType = this.viewType;
this.controllerParams.confirmOnDelete = true;
- this.controllerParams.archiveEnabled = 'active' in this.fields;
+ this.controllerParams.archiveEnabled = 'active' in this.fields || 'x_active' in this.fields;
this.controllerParams.hasButtons =
'action_buttons' in params ? params.action_buttons : true;
this.controllerParams.viewId = viewInfo.view_id;