Get allowed_modules from User DocType

I would like to automatically set the allowed modules a user has based on its role profile.

I added a hook:

doc_events = {
	"User": {
		"on_update": "test_app.api.set_allowed_modules_based_on_role_profile"

In the related method I can get the role profile, but I do not know how to modify the modules_html field which contains the allowed modules.

def set_allowed_modules_based_on_role_profile(self, method):

Says modules html does not exist.

Well it seems I do not get allowed_modules, but blocked modules instead.
The “User” DocType has a childtable “blocked_modules” which contains all not allowed modules.

I therefore clear all blocked module items and set them to what I need.

for d in self.block_modules:
self.append("block_modules", {
    'module': "Website"