fix(manufacturing): consider process loss qty while validating the work order

This commit is contained in:
Sudharsanan11
2026-01-18 23:03:24 +05:30
parent 96c3fccb05
commit e6366e830c
2 changed files with 2 additions and 2 deletions

View File

@@ -502,7 +502,7 @@ class WorkOrder(Document):
def validate_work_order_against_so(self):
# already ordered qty
ordered_qty_against_so = frappe.db.sql(
"""select sum(qty) from `tabWork Order`
"""select sum(qty - process_loss_qty) from `tabWork Order`
where production_item = %s and sales_order = %s and docstatus < 2 and status != 'Closed' and name != %s""",
(self.production_item, self.sales_order, self.name),
)[0][0]

View File

@@ -1989,7 +1989,7 @@ def get_work_order_items(sales_order, for_raw_material_request=0):
if not for_raw_material_request:
total_work_order_qty = flt(
qb.from_(wo)
.select(Sum(wo.qty))
.select(Sum(wo.qty - wo.process_loss_qty))
.where(
(wo.production_item == i.item_code)
& (wo.sales_order == so.name)