mirror of
https://github.com/frappe/erpnext.git
synced 2026-03-05 03:23:35 +00:00
committed by
Mergify
parent
85ba96e0f3
commit
00102a15e3
@@ -9,6 +9,7 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
from frappe.utils import date_diff, get_datetime, now
|
||||||
|
|
||||||
|
|
||||||
class BOMUpdateTool(Document):
|
class BOMUpdateTool(Document):
|
||||||
@@ -50,13 +51,21 @@ def auto_update_latest_price_in_all_boms() -> None:
|
|||||||
if frappe.db.get_single_value("Manufacturing Settings", "update_bom_costs_automatically"):
|
if frappe.db.get_single_value("Manufacturing Settings", "update_bom_costs_automatically"):
|
||||||
wip_log = frappe.get_all(
|
wip_log = frappe.get_all(
|
||||||
"BOM Update Log",
|
"BOM Update Log",
|
||||||
{"update_type": "Update Cost", "status": ["in", ["Queued", "In Progress"]]},
|
fields=["creation", "status"],
|
||||||
|
filters={"update_type": "Update Cost", "status": ["in", ["Queued", "In Progress"]]},
|
||||||
limit_page_length=1,
|
limit_page_length=1,
|
||||||
|
order_by="creation desc",
|
||||||
)
|
)
|
||||||
if not wip_log:
|
|
||||||
|
if not wip_log or is_older_log(wip_log[0]):
|
||||||
create_bom_update_log(update_type="Update Cost")
|
create_bom_update_log(update_type="Update Cost")
|
||||||
|
|
||||||
|
|
||||||
|
def is_older_log(log: dict) -> bool:
|
||||||
|
no_of_days = date_diff(get_datetime(now()), get_datetime(log.creation))
|
||||||
|
return no_of_days > 10
|
||||||
|
|
||||||
|
|
||||||
def create_bom_update_log(
|
def create_bom_update_log(
|
||||||
boms: dict[str, str] | None = None,
|
boms: dict[str, str] | None = None,
|
||||||
update_type: Literal["Replace BOM", "Update Cost"] = "Replace BOM",
|
update_type: Literal["Replace BOM", "Update Cost"] = "Replace BOM",
|
||||||
|
|||||||
Reference in New Issue
Block a user