Skip to content

Commit

Permalink
fix: make BOM required in SCR Item
Browse files Browse the repository at this point in the history
(cherry picked from commit 760c26e)
  • Loading branch information
s-aga-r authored and mergify[bot] committed Nov 5, 2022
1 parent bd7435c commit 3f79a05
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions erpnext/controllers/subcontracting_controller.py
Expand Up @@ -89,6 +89,9 @@ def validate_items(self):
if bom.item != item.item_code:
msg = f"Please select an valid BOM for Item {item.item_name}."
frappe.throw(_(msg))
else:
msg = f"Please select a BOM for Item {item.item_name}."
frappe.throw(_(msg))

def __get_data_before_save(self):
item_dict = {}
Expand Down
Expand Up @@ -57,6 +57,7 @@ def update_status_updater_args(self):

def before_validate(self):
super(SubcontractingReceipt, self).before_validate()
self.set_items_bom()
self.set_items_cost_center()
self.set_items_expense_account()

Expand Down Expand Up @@ -193,6 +194,24 @@ def validate_available_qty_for_consumption(self):
).format(item.idx)
)

def set_items_bom(self):
if self.is_return:
for item in self.items:
if not item.bom:
item.bom = frappe.db.get_value(
"Subcontracting Receipt Item",
{"name": item.subcontracting_receipt_item, "parent": self.return_against},
"bom",
)
else:
for item in self.items:
if not item.bom:
item.bom = frappe.db.get_value(
"Subcontracting Order Item",
{"name": item.subcontracting_order_item, "parent": item.subcontracting_order},
"bom",
)

def set_items_cost_center(self):
if self.company:
cost_center = frappe.get_cached_value("Company", self.company, "cost_center")
Expand Down

0 comments on commit 3f79a05

Please sign in to comment.