diff --git a/invenio_accounts/models.py b/invenio_accounts/models.py index 610877ff..b4d940a6 100644 --- a/invenio_accounts/models.py +++ b/invenio_accounts/models.py @@ -86,6 +86,12 @@ def __str__(self): """Return the name and description of the role.""" return "{0.name} - {0.description}".format(self) + def __init__(self, **kwargs): + """Constructor.""" + if kwargs.get("name"): + kwargs.setdefault("id", kwargs["name"]) + super().__init__(**kwargs) + class User(db.Model, Timestamp, UserMixin): """User data model."""