In Odoo POS, everything is defined in terms of screens. When coming to Odoo version 15, there are a lot of new features implemented like Limited Partner Loading, Customer, Ship Later, Refund, Open Product Info, etc. In this blog, we can check how to show or hide any button on the POS product screen based on the user’s access rights.
The POS ProductScreen is nothing but the screen where we can see the buttons like Discount, Info, Refund, Reward, etc. We can check how to hide any of these buttons for a specific user. For that, we can check how a button is defined on the product screen. For example, we can check how the RefundButton is defined in the ‘point_of_sale’ module’s RefundButton.js file. It is defined by extending the POS component and then it is added to the product screen as below:
ProductScreen.addControlButton({
component: RefundButton,
condition: function () {
return true;
},
});
refund_employee_ids = fields.Many2many('hr.employee', string='Refund Employees')
ProductScreen.addControlButton({
component: RefundButton,
condition: function () {
var cashier = this.env.pos.get('cashier') || this.env.pos.get_cashier();
has_refund = false;
if (this.env.pos.config.refund_employee_ids.includes(cashier.id)) {
has_refund = true;
}
return has_refund;
},
});