From 9f6e10663b77489ba1f98ede96e30c23682c111a Mon Sep 17 00:00:00 2001 From: marination Date: Mon, 23 May 2022 11:05:55 +0530 Subject: [PATCH] chore: Run `_validate_over_transfer` only if excess transfer is blocked in settings --- erpnext/manufacturing/doctype/job_card/job_card.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/erpnext/manufacturing/doctype/job_card/job_card.py b/erpnext/manufacturing/doctype/job_card/job_card.py index d16281a5ba7..0a9fd8a0996 100644 --- a/erpnext/manufacturing/doctype/job_card/job_card.py +++ b/erpnext/manufacturing/doctype/job_card/job_card.py @@ -531,11 +531,9 @@ class JobCard(Document): def _validate_over_transfer(row, transferred_qty): "Block over transfer of items if not allowed in settings." - allow_excess = frappe.db.get_single_value("Manufacturing Settings", "job_card_excess_transfer") required_qty = frappe.db.get_value("Job Card Item", row.job_card_item, "required_qty") is_excess = flt(transferred_qty) > flt(required_qty) - - if is_excess and not allow_excess: + if is_excess: frappe.throw( _( "Row #{0}: Cannot transfer more than Required Qty {1} for Item {2} against Job Card {3}" @@ -564,7 +562,9 @@ class JobCard(Document): ) ).run()[0][0] - _validate_over_transfer(row, transferred_qty) + allow_excess = frappe.db.get_single_value("Manufacturing Settings", "job_card_excess_transfer") + if not allow_excess: + _validate_over_transfer(row, transferred_qty) frappe.db.set_value("Job Card Item", row.job_card_item, "transferred_qty", flt(transferred_qty))