chore: subcontracting validations (backport #33621) (#33626)

* fix: `ZeroDivisionError: float division by zero` in SCR

(cherry picked from commit 434aa594d5)

* chore: add row-index in error msgs

(cherry picked from commit 6878f40d1d)

* chore: update error msgs for Subcontracted PO

(cherry picked from commit a0e2a93f3f)

* fix: validate accepted and rejected qty in SCR Item

(cherry picked from commit f028bd6e69)

* chore: linter

(cherry picked from commit b26e96cdf4)

Co-authored-by: s-aga-r <sagarsharma.s312@gmail.com>
This commit is contained in:
mergify[bot]
2023-01-12 20:31:24 +05:30
committed by GitHub
parent c9edf10693
commit 120dca44ad
3 changed files with 24 additions and 19 deletions

View File

@@ -74,24 +74,25 @@ class SubcontractingController(StockController):
)
if not is_stock_item:
msg = f"Item {item.item_name} must be a stock item."
frappe.throw(_(msg))
frappe.throw(_("Row {0}: Item {1} must be a stock item.").format(item.idx, item.item_name))
if not is_sub_contracted_item:
msg = f"Item {item.item_name} must be a subcontracted item."
frappe.throw(_(msg))
frappe.throw(
_("Row {0}: Item {1} must be a subcontracted item.").format(item.idx, item.item_name)
)
if item.bom:
bom = frappe.get_doc("BOM", item.bom)
if not bom.is_active:
msg = f"Please select an active BOM for Item {item.item_name}."
frappe.throw(_(msg))
frappe.throw(
_("Row {0}: Please select an active BOM for Item {1}.").format(item.idx, item.item_name)
)
if bom.item != item.item_code:
msg = f"Please select an valid BOM for Item {item.item_name}."
frappe.throw(_(msg))
frappe.throw(
_("Row {0}: Please select an valid BOM for Item {1}.").format(item.idx, item.item_name)
)
else:
msg = f"Please select a BOM for Item {item.item_name}."
frappe.throw(_(msg))
frappe.throw(_("Row {0}: Please select a BOM for Item {1}.").format(item.idx, item.item_name))
def __get_data_before_save(self):
item_dict = {}