<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def owner_type(self, value):
 """Set ``owner_type`` to the given value. In addition: * Update the internal type of the ``owner`` field. * Update the value of the ``owner`` field if a value is already set. """

        self._owner_type = value
        if value == 'User':
            self._fields['owner'] = entity_fields.OneToOneField(User)
            if hasattr(self, 'owner'):
                # pylint:disable=no-member
                self.owner = User(
                    self._server_config,
                    id=self.owner.id if isinstance(self.owner, Entity)
                    else self.owner
                )
        elif value == 'Usergroup':
            self._fields['owner'] = entity_fields.OneToOneField(UserGroup)
            if hasattr(self, 'owner'):
                # pylint:disable=no-member
                self.owner = UserGroup(
                    self._server_config,
                    id=self.owner.id if isinstance(self.owner, Entity)
                    else self.owner
                )