diff --git a/mail/mail/doctype/outgoing_mail/outgoing_mail.json b/mail/mail/doctype/outgoing_mail/outgoing_mail.json index 526ed0cb..36b376fe 100644 --- a/mail/mail/doctype/outgoing_mail/outgoing_mail.json +++ b/mail/mail/doctype/outgoing_mail/outgoing_mail.json @@ -42,7 +42,7 @@ "transfer_completed_at", "column_break_fvyv", "submitted_after", - "transferred_after", + "transfer_completed_after", "section_break_aafd", "tracking_id", "first_opened_at", @@ -203,16 +203,6 @@ "read_only": 1, "search_index": 1 }, - { - "depends_on": "eval: doc.transfer_completed_at", - "description": "Transfer Completed At - Submitted At", - "fieldname": "transferred_after", - "fieldtype": "Int", - "label": "Transferred After (Seconds)", - "no_copy": 1, - "non_negative": 1, - "read_only": 1 - }, { "depends_on": "eval: doc.message_size", "fieldname": "message_size", @@ -426,12 +416,22 @@ "label": "Transfer Completed At", "no_copy": 1, "read_only": 1 + }, + { + "depends_on": "eval: doc.transfer_completed_at", + "description": "Transfer Completed At - Submitted At", + "fieldname": "transfer_completed_after", + "fieldtype": "Int", + "label": "Transfer Completed 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:05:48.765359", + "modified": "2024-10-05 10:15:40.832320", "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 2971622a..e193ec5d 100644 --- a/mail/mail/doctype/outgoing_mail/outgoing_mail.py +++ b/mail/mail/doctype/outgoing_mail/outgoing_mail.py @@ -695,11 +695,13 @@ def transfer_now(self) -> None: rmq.publish(constants.OUTGOING_MAIL_QUEUE, json.dumps(data), priority=3) transfer_completed_at = now() - transferred_after = time_diff_in_seconds(transfer_completed_at, self.submitted_at) + transfer_completed_after = time_diff_in_seconds( + transfer_completed_at, self.submitted_at + ) self._db_set( status="Transferred", transfer_completed_at=transfer_completed_at, - transferred_after=transferred_after, + transfer_completed_after=transfer_completed_after, commit=True, ) except Exception: @@ -1049,7 +1051,7 @@ def update_outgoing_mails( status = %s, error_log = NULL, transfer_completed_at = %s, - transferred_after = TIMESTAMPDIFF(SECOND, `submitted_at`, `transfer_completed_at`) + transfer_completed_after = TIMESTAMPDIFF(SECOND, `submitted_at`, `transfer_completed_at`) WHERE docstatus = 1 AND status = %s AND diff --git a/mail/mail/report/outbound_delay/outbound_delay.py b/mail/mail/report/outbound_delay/outbound_delay.py index 19d7fc39..511c8e3c 100644 --- a/mail/mail/report/outbound_delay/outbound_delay.py +++ b/mail/mail/report/outbound_delay/outbound_delay.py @@ -37,7 +37,7 @@ def get_data(filters=None) -> list: OM.via_api, OM.is_newsletter, OM.submitted_after, - OM.transferred_after, + OM.transfer_completed_after.as_("transferred_after"), MR.action_after, OM.agent, OM.domain_name, diff --git a/mail/patches.txt b/mail/patches.txt index 84797aaf..5f6b4bf0 100644 --- a/mail/patches.txt +++ b/mail/patches.txt @@ -4,3 +4,4 @@ mail.patches.v1_0.rename_field_dkim_bits mail.patches.v1_0.create_dkim_key_doc mail.patches.v1_0.rename_field_transferred_at +mail.patches.v1_0.rename_field_transferred_after diff --git a/mail/patches/v1_0/rename_field_transferred_after.py b/mail/patches/v1_0/rename_field_transferred_after.py new file mode 100644 index 00000000..8940831d --- /dev/null +++ b/mail/patches/v1_0/rename_field_transferred_after.py @@ -0,0 +1,10 @@ +import frappe +from frappe.model.utils.rename_field import rename_field + + +def execute(): + doctype = "Outgoing Mail" + old_fieldname, new_fieldname = "transferred_after", "transfer_completed_after" + + if frappe.db.has_column(doctype, old_fieldname): + rename_field(doctype, old_fieldname, new_fieldname)