I am working with Odoo v12 and I need to hide the "import" button in a tree view but keeping the create button.
I have tried so far with
<tree string="" import ="false">.
But the import button is still showing.
How can I hide the import button?
On
You can try overriding Javascript like this.
odoo.define('account.invoice_tree', function (require) {
"use strict";
var ListController = require("web.ListController");
var includeDict = {
renderButtons: function () {
this._super.apply(this, arguments);
if (this.modelName === "account.invoice") {
this.$buttons.find('button.o_button_upload_bill').hide();
}
}
};
ListController.include(includeDict);
});
and be sure to include your script in the assets list:
<script type="text/javascript" src="/hr_account/static/src/js/invoice_tree.js"></script>
This will hide the button. In my example, it was the upload button on the invoice.
You can't delete the "Import" button in Odoo because it is generated dynamically in the JavaScript code. I would use some sort of group permissions for users you do want not to be able to access.
Another option is to make a custom module to hide the button. Something like this extends the list controller.