<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_outgoing_transaction(self, using, created=None, deleted=None):
 """ Serialize the model instance to an AES encrypted json object and saves the json object to the OutgoingTransaction model. """

        OutgoingTransaction = django_apps.get_model(
            "django_collect_offline", "OutgoingTransaction"
        )
        created = True if created is None else created
        action = INSERT if created else UPDATE
        timestamp_datetime = (
            self.instance.created if created else self.instance.modified
        )
        if not timestamp_datetime:
            timestamp_datetime = get_utcnow()
        if deleted:
            timestamp_datetime = get_utcnow()
            action = DELETE
        outgoing_transaction = None
        if self.is_serialized:
            hostname = socket.gethostname()
            outgoing_transaction = OutgoingTransaction.objects.using(using).create(
                tx_name=self.instance._meta.label_lower,
                tx_pk=getattr(self.instance, self.primary_key_field.name),
                tx=self.encrypted_json(),
                timestamp=timestamp_datetime.strftime("%Y%m%d%H%M%S%f"),
                producer=f"{hostname}-{using}",
                action=action,
                using=using,
            )
        return outgoing_transaction