In view dialogs (e.g. click on the external button of a many2one in edit mode), the attribute $buttons of the form controller is undefined (the buttons are rendered by the dialog directly). The code that (de)activate the buttons to prevent concurrent clicks made the assumption that $buttons exist, so it crashed when it doesn't.