mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-02 11:49:10 +00:00
chore: Implement Log clearing interface in BOM Update Log
- Implement Log clearing interface in BOM Update Log - Add additional info in sidebar: Log clearing only happens for 'Update Cost' type logs - 'Replace BOM' logs have important info and is used in BOM timeline, so we'll let users decide if they wanna keep or discard it
This commit is contained in:
@@ -6,6 +6,8 @@ from typing import Any, Dict, List, Optional, Tuple, Union
|
|||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from frappe.query_builder import DocType, Interval
|
||||||
|
from frappe.query_builder.functions import Now
|
||||||
from frappe.utils import cint, cstr
|
from frappe.utils import cint, cstr
|
||||||
|
|
||||||
from erpnext.manufacturing.doctype.bom_update_log.bom_updation_utils import (
|
from erpnext.manufacturing.doctype.bom_update_log.bom_updation_utils import (
|
||||||
@@ -22,6 +24,17 @@ class BOMMissingError(frappe.ValidationError):
|
|||||||
|
|
||||||
|
|
||||||
class BOMUpdateLog(Document):
|
class BOMUpdateLog(Document):
|
||||||
|
@staticmethod
|
||||||
|
def clear_old_logs(days=None):
|
||||||
|
days = days or 90
|
||||||
|
table = DocType("BOM Update Log")
|
||||||
|
frappe.db.delete(
|
||||||
|
table,
|
||||||
|
filters=(
|
||||||
|
(table.modified < (Now() - Interval(days=days))) & (table.update_type == "Update Cost")
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
if self.update_type == "Replace BOM":
|
if self.update_type == "Replace BOM":
|
||||||
self.validate_boms_are_specified()
|
self.validate_boms_are_specified()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
frappe.listview_settings['BOM Update Log'] = {
|
frappe.listview_settings['BOM Update Log'] = {
|
||||||
add_fields: ["status"],
|
add_fields: ["status"],
|
||||||
get_indicator: function(doc) {
|
get_indicator: (doc) => {
|
||||||
let status_map = {
|
let status_map = {
|
||||||
"Queued": "orange",
|
"Queued": "orange",
|
||||||
"In Progress": "blue",
|
"In Progress": "blue",
|
||||||
@@ -9,5 +9,22 @@ frappe.listview_settings['BOM Update Log'] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return [__(doc.status), status_map[doc.status], "status,=," + doc.status];
|
return [__(doc.status), status_map[doc.status], "status,=," + doc.status];
|
||||||
}
|
},
|
||||||
|
onload: () => {
|
||||||
|
if (!frappe.model.can_write("Log Settings")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let sidebar_entry = $(
|
||||||
|
'<ul class="list-unstyled sidebar-menu log-retention-note"></ul>'
|
||||||
|
).appendTo(cur_list.page.sidebar);
|
||||||
|
let message = __("Note: Automatic log deletion only applies to logs of type <i>Update Cost</i>");
|
||||||
|
$(`<hr><div class='text-muted'>${message}</div>`).appendTo(sidebar_entry);
|
||||||
|
|
||||||
|
frappe.require("logtypes.bundle.js", () => {
|
||||||
|
frappe.utils.logtypes.show_log_retention_message(cur_list.doctype);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user