Merge pull request #5369 from expsa/fix/ui-buttons-readonly-menu-icon-20251112-040000

fix: Disable UI Buttons in Readonly Mode - 20251112
This commit is contained in:
Mohamed Eltayar 2025-11-12 03:55:35 +03:00 committed by GitHub
commit ea823f2806
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 29 additions and 0 deletions

View File

@ -205,11 +205,40 @@
_setupSimpleUI: function () {
var self = this;
var currentData = self.model.localData[self.handle].data;
var isReadonly = currentData.state !== 'draft' || self.mode === 'readonly';
// Remove old event handlers to prevent duplicates
this.$('.record_option').off('click');
this.$('.mechanism_option').off('click');
// Disable buttons if readonly
if (isReadonly) {
this.$('.record_option').css({
'pointer-events': 'none',
'opacity': '0.6',
'cursor': 'not-allowed'
});
this.$('.mechanism_option').css({
'pointer-events': 'none',
'opacity': '0.6',
'cursor': 'not-allowed'
});
return; // Don't attach click handlers if readonly
} else {
// Re-enable buttons if not readonly
this.$('.record_option').css({
'pointer-events': 'auto',
'opacity': '1',
'cursor': 'pointer'
});
this.$('.mechanism_option').css({
'pointer-events': 'auto',
'opacity': '1',
'cursor': 'pointer'
});
}
// Record Type Options - Odoo 14 Compatible Method
this.$('.record_option').on('click', function () {
var $option = $(this);