Skip to content

Instantly share code, notes, and snippets.

@goliveirab
Last active September 20, 2023 04:56
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save goliveirab/a3dafb432338d7250d32e548151bfd9c to your computer and use it in GitHub Desktop.
Save goliveirab/a3dafb432338d7250d32e548151bfd9c to your computer and use it in GitHub Desktop.
Remove Archive and Unarchive options from menu 'Action' for users with no access rights - Odoo v11
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record model="res.groups" id="group_archive">
<field name="name">Archive Product & Partner</field>
</record>
</odoo>
odoo.define('test_modulo.BasicView', function (require) {
"use strict";
var session = require('web.session');
var BasicView = require('web.BasicView');
BasicView.include({
init: function(viewInfo, params) {
var self = this;
this._super.apply(this, arguments);
var model = self.controllerParams.modelName in ['res.partner','product.template'] ? 'True' : 'False';
if(model) {
session.user_has_group('test_modulo.group_archive').then(function(has_group) {
if(!has_group) {
self.controllerParams.archiveEnabled = 'False' in viewInfo.fields;
}
});
}
},
});
});
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="test_modulo_assets_backend" name="test modulo assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/test_modulo/static/src/js/basic_view.js"/>
</xpath>
</template>
</odoo>
@onuh
Copy link

onuh commented Aug 13, 2023

You will need to extend the view controller with js_class to either the tree or form or Kannan view which you want the button hidden in v16. This solution is outdated for v16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment