fix: incorrect validation for scrap items (#20109)
This commit is contained in:
parent
8774c869d7
commit
a99f926a4b
@ -585,12 +585,18 @@ class StockEntry(StockController):
|
||||
|
||||
def validate_finished_goods(self):
|
||||
"""validation: finished good quantity should be same as manufacturing quantity"""
|
||||
if not self.work_order: return
|
||||
|
||||
items_with_target_warehouse = []
|
||||
allowance_percentage = flt(frappe.db.get_single_value("Manufacturing Settings",
|
||||
"overproduction_percentage_for_work_order"))
|
||||
|
||||
production_item, wo_qty = frappe.db.get_value("Work Order",
|
||||
self.work_order, ["production_item", "qty"])
|
||||
|
||||
for d in self.get('items'):
|
||||
if self.purpose != "Send to Subcontractor" and d.bom_no and flt(d.transfer_qty) > flt(self.fg_completed_qty) and (d.t_warehouse != getattr(self, "pro_doc", frappe._dict()).scrap_warehouse):
|
||||
if (self.purpose != "Send to Subcontractor" and d.bom_no
|
||||
and flt(d.transfer_qty) > flt(self.fg_completed_qty) and d.item_code == production_item):
|
||||
frappe.throw(_("Quantity in row {0} ({1}) must be same as manufactured quantity {2}"). \
|
||||
format(d.idx, d.transfer_qty, self.fg_completed_qty))
|
||||
|
||||
@ -598,9 +604,6 @@ class StockEntry(StockController):
|
||||
items_with_target_warehouse.append(d.item_code)
|
||||
|
||||
if self.work_order and self.purpose == "Manufacture":
|
||||
production_item, wo_qty = frappe.db.get_value("Work Order",
|
||||
self.work_order, ["production_item", "qty"])
|
||||
|
||||
allowed_qty = wo_qty + (allowance_percentage/100 * wo_qty)
|
||||
if self.fg_completed_qty > allowed_qty:
|
||||
frappe.throw(_("For quantity {0} should not be grater than work order quantity {1}")
|
||||
|
Loading…
Reference in New Issue
Block a user