Hide developer tool for non-administrator

Viewed 148

I want to hide the Open Developer Tools button for non-administrators.

enter image description here

When I search the solution on the internet, I find the module to hide that button, but I have to pay about $50. Is there a solution to achieve those things without having to pay?

I have already deactivated developer mode. But the weird thing is, the Open Developer Tools button is hidden for admin, but is shown for non-admin.

enter image description here

1 Answers

You can alter the WebClient.DebugManager template to add a condition on the menu item.

<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
    <t t-extend="WebClient.DebugManager">
        <t t-jquery="li" t-operation="attributes">
            <attribute name="t-if">widget.is_admin</attribute>
        </t>
    </t>
</templates>

Then extend the web.DebugManager widget to set the value of is_admin:

odoo.define('MODULE_NAME.DebugManager', function(require) {
    'use strict';
    var DebugManager = require('web.DebugManager');
    var session = require('web.session');
    DebugManager.include({
        init: function () {
            this._super.apply(this, arguments);
            this.is_admin = session.is_system;
        },
    });
});

You can check how to add a file in an asset bundle and how to extend templates in Odoo documentation.

Related