Adding a button to user preferences

I would like to add a button to the user preferences form.

This appears to work for any users that have write access to the User model, but for users without this access the button is readonly.

So I have a couple of questions:

Firstly, is it a bad idea to try and add a button to the user preferences form?

Secondly, is there a way of making the button usable for users without write access to the User model?

Thanks!

This is the expected behaviour as buttons if you did not set any access rule on the button.

The users model is like any other model so I do not see any reason that should prevent adding a button to it.

Yes, you should create a group to allow access to the button and then add the users to this group.

Did you need that all users from the system should be able to click this button?

Thanks Sergi. I should have realized this myself, this does indeed work properly as expected.

However, I think the answer to this question is probably “Yes”.

For the record, what I have now just realized is that if the user has changed any of the values in their preferences before they click on the button, then Tryton tries to save these before running the click action. If the user does not have write access to the users model then access is denied and the changes are not saved, and so the button action does not run. Normally saving these changes is done when the preferences window is closed and is handled specially by the set_preferences method, which takes care to clean the values before saving them for the user.

Maybe you should consider using an instance button to just modify the record value (if that’s enough for your case).

Yes, that might be a possibility. Thanks for the suggestion.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.