0

I would like to remove "Export" in action menu in Odoo 14 Community Edition.

I want to remove it for all views at once if possible; otherwise, one by one for each required model or view would be fine.

Export action menu

I tried:

<xpath expr="//tree" position="attributes">
  <attribute name="export_xlsx">false</attribute>
</xpath>

in individual model. Doesn't work.

Also tried overwriting the Sidebar in javascript. Doesn't work.

holydragon
  • 6,158
  • 6
  • 39
  • 62

3 Answers3

2

Odoo will only show the Export option if the user belongs to the Access to export feature group.

To hide the export option, just remove the user from the list

Overriding the Action menus (previously called Sidebar) or the list controller will make the export group obsolete

Kenly
  • 24,317
  • 7
  • 44
  • 60
  • Do you have a solution without removing the user from the group because I need the group but I don't want the user to see the option? – holydragon Jul 25 '23 at 15:05
  • You can override the `_getActionMenuItems` as you did but set the `isExportEnable` to `false` before calling super so Odoo will not add the `Export` option to other action items – Kenly Jul 26 '23 at 07:36
  • So, the updated part from aekis.dev is a better version of mine, right? – holydragon Jul 26 '23 at 07:40
1

Do it using this js code

odoo.define('disable_export', function (require) {
"use strict";

const ListView = require('web.ListView');
const ListController = require('web.ListController');

ListView.include({
  init: function (viewInfo, params) {
    this._super.apply(this, arguments);
    this.controllerParams.activeActions.export_xlsx = false;
  }
})

ListController.include({
  _getActionMenuItems: function (state) {
    this.isExportEnable = false;
    return this._super.apply(this, arguments);
  }
})

})
Community
  • 1
  • 1
aekis.dev
  • 2,626
  • 1
  • 12
  • 19
0

I finally found the solution for this problem.

odoo.define('remove_export_button', function (require) {
  "use strict";
  
  var core = require('web.core');
  var ListController = require('web.ListController');
  ListController.include({
    /**
     * @override
     * @private
     */
    _getActionMenuItems: function (state) {
      let actionMenus = this._super.apply(this, arguments);
      if (actionMenus?.items){
        actionMenus.items.other = actionMenus?.items?.other.filter(menu => menu.description !== 'Export');
      }
      return actionMenus;
    },
  });
});

It works for all views at once.

holydragon
  • 6,158
  • 6
  • 39
  • 62