Skip to content

Commit

Permalink
Merge pull request #45064 from frappe/version-14-hotfix
Browse files Browse the repository at this point in the history
chore: release v14
  • Loading branch information
ruthra-kumar authored Jan 3, 2025
2 parents 6a91f91 + b3d545f commit 9e60f67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 37 deletions.
13 changes: 11 additions & 2 deletions erpnext/manufacturing/doctype/bom_update_tool/bom_update_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import frappe
from frappe.model.document import Document
from frappe.utils import date_diff, get_datetime, now


class BOMUpdateTool(Document):
Expand Down Expand Up @@ -38,13 +39,21 @@ def auto_update_latest_price_in_all_boms() -> None:
if frappe.db.get_single_value("Manufacturing Settings", "update_bom_costs_automatically"):
wip_log = frappe.get_all(
"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,
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")


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(
boms: dict[str, str] | None = None,
update_type: Literal["Replace BOM", "Update Cost"] = "Replace BOM",
Expand Down
35 changes: 0 additions & 35 deletions erpnext/stock/doctype/stock_entry/stock_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def validate(self):
self.validate_purpose()
self.validate_item()
self.validate_customer_provided_item()
self.validate_qty()
self.set_transfer_qty()
self.validate_uom_is_integer("uom", "qty")
self.validate_uom_is_integer("stock_uom", "transfer_qty")
Expand Down Expand Up @@ -385,40 +384,6 @@ def validate_item(self):
frappe.MandatoryError,
)

def validate_qty(self):
manufacture_purpose = ["Manufacture", "Material Consumption for Manufacture"]

if self.purpose in manufacture_purpose and self.work_order:
if not frappe.get_value("Work Order", self.work_order, "skip_transfer"):
item_code = []
for item in self.items:
if cstr(item.t_warehouse) == "":
req_items = frappe.get_all(
"Work Order Item",
filters={"parent": self.work_order, "item_code": item.item_code},
fields=["item_code"],
)

transferred_materials = frappe.db.sql(
"""
select
sum(sed.qty) as qty
from `tabStock Entry` se,`tabStock Entry Detail` sed
where
se.name = sed.parent and se.docstatus=1 and
(se.purpose='Material Transfer for Manufacture' or se.purpose='Manufacture')
and sed.item_code=%s and se.work_order= %s and ifnull(sed.t_warehouse, '') != ''
""",
(item.item_code, self.work_order),
as_dict=1,
)

stock_qty = flt(item.qty)
trans_qty = flt(transferred_materials[0].qty)
if req_items:
if stock_qty > trans_qty:
item_code.append(item.item_code)

def validate_fg_completed_qty(self):
if self.purpose != "Manufacture":
return
Expand Down

0 comments on commit 9e60f67

Please sign in to comment.