diff --git a/frappe/core/doctype/activity_log/activity_log.js b/frappe/core/doctype/activity_log/activity_log.js index 7df644a86a..39486dac6f 100644 --- a/frappe/core/doctype/activity_log/activity_log.js +++ b/frappe/core/doctype/activity_log/activity_log.js @@ -2,5 +2,8 @@ // For license information, please see license.txt frappe.ui.form.on("Activity Log", { - refresh: function () {}, + refresh: function (frm) { + // Nothing in this form is supposed to be editable. + frm.disable_form(); + }, }); diff --git a/frappe/core/doctype/activity_log/activity_log.json b/frappe/core/doctype/activity_log/activity_log.json index 910baceb5e..b272bab180 100644 --- a/frappe/core/doctype/activity_log/activity_log.json +++ b/frappe/core/doctype/activity_log/activity_log.json @@ -13,6 +13,7 @@ "column_break_5", "additional_info", "communication_date", + "ip_address", "column_break_7", "operation", "status", @@ -148,12 +149,17 @@ "fieldtype": "Data", "in_list_view": 1, "label": "Full Name" + }, + { + "fieldname": "ip_address", + "fieldtype": "Data", + "label": "IP Address" } ], "icon": "fa fa-comment", "index_web_pages_for_search": 1, "links": [], - "modified": "2022-09-13 15:19:42.474114", + "modified": "2023-07-28 13:26:32.281278", "modified_by": "Administrator", "module": "Core", "name": "Activity Log", diff --git a/frappe/core/doctype/activity_log/activity_log.py b/frappe/core/doctype/activity_log/activity_log.py index f7c21f6825..d58899f6cd 100644 --- a/frappe/core/doctype/activity_log/activity_log.py +++ b/frappe/core/doctype/activity_log/activity_log.py @@ -21,6 +21,7 @@ class ActivityLog(Document): communication_date: DF.Datetime | None content: DF.TextEditor | None full_name: DF.Data | None + ip_address: DF.Data | None link_doctype: DF.Link | None link_name: DF.DynamicLink | None operation: DF.Literal["", "Login", "Logout"] @@ -40,6 +41,7 @@ class ActivityLog(Document): def validate(self): self.set_status() set_timeline_doc(self) + self.set_ip_address() def set_status(self): if not self.is_new(): @@ -48,6 +50,10 @@ class ActivityLog(Document): if self.reference_doctype and self.reference_name: self.status = "Linked" + def set_ip_address(self): + if self.operation in ("Login", "Logout"): + self.ip_address = getattr(frappe.local, "request_ip") + @staticmethod def clear_old_logs(days=None): if not days: