so this is my code and working fine, but still when we give user right access group then we refresh it, i have to go another model then back to my prohibited models to make the archive/unarchive available
odoo.define("wpd_inventory", function(require) {
"use strict";
var core = require("web.core");
var Sidebar = require('web.Sidebar'); //location of other options {export, archive, unarchive, delete, etc}
var ListController = require("web.ListController");
var _t = core._t;
var session = require('web.session');
ListController.include({
renderSidebar: function ($node) {
if (this.hasSidebar && !this.sidebar) {
var grant_access = true
if (this.modelName == "product.template" || this.modelName == 'product.product') {
session.user_has_group('wpd_inventory.group_archive_data').then(function(has_group) {
if(!has_group) {
grant_access = false;
}
});
}
console.log({
'current_model': this.modelName,
'super_user': session.is_superuser,
'grant_access_archive_products': grant_access
});
var other = [];
other.push({
label: _t("Export"),
callback: this._onExportData.bind(this)
});
if (this.archiveEnabled) {
if (grant_access || session.is_superuser) {
other.push({
label: _t("Archive"),
callback: this._onToggleArchiveState.bind(this, true)
});
other.push({
label: _t("Unarchive"),
callback: this._onToggleArchiveState.bind(this, false)
});
}
}
if (this.is_action_enabled('delete')) {
other.push({
label: _t('Delete'),
callback: this._onDeleteSelectedRecords.bind(this)
});
}
this.sidebar = new Sidebar(this, {
editable: this.is_action_enabled('edit'),
env: {
context: this.model.get(this.handle, {raw: true}).getContext(),
activeIds: this.getSelectedIds(),
model: this.modelName,
},
actions: _.extend(this.toolbarActions, {other: other}),
});
this.sidebar.appendTo($node);
this._toggleSidebar();
}
}
});
});