def save(self, *args, **kwargs):
        super(MessagingSubEvent, self).save(*args, **kwargs)
        parent = self.parent

        # If this event is in an errored state, also set the parent
        # event to an errored state.
        if self.status == MessagingEvent.STATUS_ERROR:
            parent.status = MessagingEvent.STATUS_ERROR
            parent.save()

        # If the parent event had various recipients, mark it as such,
        # unless the source was a keyword in which case the recipient
        # listed should always be the keyword initiator.
        if (parent.source != MessagingEvent.SOURCE_KEYWORD and
                (parent.recipient_id != self.recipient_id or self.recipient_id is None) and
                parent.recipient_type not in (
                    MessagingEvent.RECIPIENT_USER_GROUP,
                    MessagingEvent.RECIPIENT_CASE_GROUP,
                    MessagingEvent.RECIPIENT_VARIOUS,
                    MessagingEvent.RECIPIENT_LOCATION,
                    MessagingEvent.RECIPIENT_LOCATION_PLUS_DESCENDANTS,
                    MessagingEvent.RECIPIENT_VARIOUS_LOCATIONS,
                    MessagingEvent.RECIPIENT_VARIOUS_LOCATIONS_PLUS_DESCENDANTS,
                ) and len(parent.subevents) > 1):
            parent.recipient_type = MessagingEvent.RECIPIENT_VARIOUS
            parent.recipient_id = None
            parent.save()
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/sms/models.py/MessagingSubEvent.save/original