diff --git a/mail/mail/doctype/outgoing_mail/outgoing_mail.json b/mail/mail/doctype/outgoing_mail/outgoing_mail.json index 36b376fe..0eb79d73 100644 --- a/mail/mail/doctype/outgoing_mail/outgoing_mail.json +++ b/mail/mail/doctype/outgoing_mail/outgoing_mail.json @@ -39,9 +39,11 @@ "section_break_093p", "created_at", "submitted_at", + "transfer_started_at", "transfer_completed_at", "column_break_fvyv", "submitted_after", + "transfer_started_after", "transfer_completed_after", "section_break_aafd", "tracking_id", @@ -419,19 +421,36 @@ }, { "depends_on": "eval: doc.transfer_completed_at", - "description": "Transfer Completed At - Submitted At", + "description": "Transfer Completed At - Transfer Started At", "fieldname": "transfer_completed_after", "fieldtype": "Int", "label": "Transfer Completed After (Seconds)", "no_copy": 1, "non_negative": 1, "read_only": 1 + }, + { + "fieldname": "transfer_started_at", + "fieldtype": "Datetime", + "label": "Transfer Started At", + "no_copy": 1, + "read_only": 1 + }, + { + "depends_on": "eval: doc.transfer_started_at", + "description": "Transfer Started At - Submitted At", + "fieldname": "transfer_started_after", + "fieldtype": "Int", + "label": "Transfer Started After (Seconds)", + "no_copy": 1, + "non_negative": 1, + "read_only": 1 } ], "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2024-10-05 10:15:40.832320", + "modified": "2024-10-05 12:34:39.544599", "modified_by": "Administrator", "module": "Mail", "name": "Outgoing Mail", diff --git a/mail/mail/doctype/outgoing_mail/outgoing_mail.py b/mail/mail/doctype/outgoing_mail/outgoing_mail.py index e193ec5d..bfaf0743 100644 --- a/mail/mail/doctype/outgoing_mail/outgoing_mail.py +++ b/mail/mail/doctype/outgoing_mail/outgoing_mail.py @@ -680,7 +680,14 @@ def transfer_now(self) -> None: if not (self.docstatus == 1 and self.status == "Pending"): return - self._db_set(status="Transferring", commit=True) + transfer_started_at = now() + transfer_started_after = time_diff_in_seconds(transfer_started_at, self.submitted_at) + self._db_set( + status="Transferring", + transfer_started_at=transfer_started_at, + transfer_started_after=transfer_started_after, + commit=True, + ) recipients = [formataddr((r.display_name, r.email)) for r in self.recipients] data = { @@ -696,7 +703,7 @@ def transfer_now(self) -> None: transfer_completed_at = now() transfer_completed_after = time_diff_in_seconds( - transfer_completed_at, self.submitted_at + transfer_completed_at, transfer_started_at ) self._db_set( status="Transferred", @@ -1021,6 +1028,7 @@ def update_outgoing_mails( outgoing_mails, current_status=current_status, status="Transferring", + transfer_started_at=now(), error_log=None, commit=True, ) @@ -1051,7 +1059,7 @@ def update_outgoing_mails( status = %s, error_log = NULL, transfer_completed_at = %s, - transfer_completed_after = TIMESTAMPDIFF(SECOND, `submitted_at`, `transfer_completed_at`) + transfer_completed_after = TIMESTAMPDIFF(SECOND, `transfer_started_at`, `transfer_completed_at`) WHERE docstatus = 1 AND status = %s AND