Last active
September 20, 2023 04:56
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<odoo> | |
<record model="res.groups" id="group_archive"> | |
<field name="name">Archive Product & Partner</field> | |
</record> | |
</odoo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
}); | |
} | |
}, | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.