code: def owner_type(self, value):
          
          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
                  )
docs: 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.