mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-19 13:09:17 +00:00
feat: track Semi-finished goods (including subcontracted items) against Job Cards (#38341)
* feat: Track Semi-finished goods (including subcontracted items) against Job Cards * feat: option to add raw materials manually against operation
This commit is contained in:
@@ -99,7 +99,7 @@ def get_subcontracting_boms_for_finished_goods(fg_items: str | list) -> dict:
|
||||
else:
|
||||
return subcontracting_boms[0]
|
||||
|
||||
return {}
|
||||
return frappe._dict({})
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
|
||||
@@ -49,6 +49,9 @@
|
||||
"cost_center",
|
||||
"dimension_col_break",
|
||||
"project",
|
||||
"references_section",
|
||||
"job_card",
|
||||
"column_break_nfod",
|
||||
"section_break_34",
|
||||
"purchase_order_item",
|
||||
"page_break"
|
||||
@@ -378,13 +381,29 @@
|
||||
"no_copy": 1,
|
||||
"read_only": 1,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "references_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "References"
|
||||
},
|
||||
{
|
||||
"fieldname": "job_card",
|
||||
"fieldtype": "Link",
|
||||
"label": "Job Card",
|
||||
"options": "Job Card",
|
||||
"read_only": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_nfod",
|
||||
"fieldtype": "Column Break"
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
"index_web_pages_for_search": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2024-03-27 13:10:46.343298",
|
||||
"modified": "2024-03-27 13:12:46.343298",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Subcontracting",
|
||||
"name": "Subcontracting Order Item",
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
from frappe.query_builder.functions import Sum
|
||||
from frappe.utils import cint, flt, get_link_to_form, getdate, nowdate
|
||||
|
||||
import erpnext
|
||||
@@ -155,6 +156,7 @@ class SubcontractingReceipt(SubcontractingController):
|
||||
self.repost_future_sle_and_gle()
|
||||
self.update_status()
|
||||
self.auto_create_purchase_receipt()
|
||||
self.update_job_card()
|
||||
|
||||
def on_update(self):
|
||||
for table_field in ["items", "supplied_items"]:
|
||||
@@ -178,6 +180,7 @@ class SubcontractingReceipt(SubcontractingController):
|
||||
self.repost_future_sle_and_gle()
|
||||
self.update_status()
|
||||
self.delete_auto_created_batches()
|
||||
self.update_job_card()
|
||||
|
||||
@frappe.whitelist()
|
||||
def reset_raw_materials(self):
|
||||
@@ -189,6 +192,23 @@ class SubcontractingReceipt(SubcontractingController):
|
||||
if item.subcontracting_order:
|
||||
check_on_hold_or_closed_status("Subcontracting Order", item.subcontracting_order)
|
||||
|
||||
def update_job_card(self):
|
||||
for row in self.get("items"):
|
||||
if row.job_card:
|
||||
doc = frappe.get_doc("Job Card", row.job_card)
|
||||
doc.set_manufactured_qty()
|
||||
|
||||
def get_manufactured_qty(self, job_card):
|
||||
table = frappe.qb.DocType("Subcontracting Receipt Item")
|
||||
query = (
|
||||
frappe.qb.from_(table)
|
||||
.select(Sum(table.qty))
|
||||
.where((table.job_card == job_card) & (table.docstatus == 1))
|
||||
)
|
||||
|
||||
qty = query.run()[0][0] or 0.0
|
||||
return flt(qty)
|
||||
|
||||
def validate_items_qty(self):
|
||||
for item in self.items:
|
||||
if not (item.qty or item.rejected_qty):
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
"subcontracting_order",
|
||||
"subcontracting_order_item",
|
||||
"subcontracting_receipt_item",
|
||||
"job_card",
|
||||
"column_break_40",
|
||||
"rejected_warehouse",
|
||||
"bom",
|
||||
@@ -577,12 +578,20 @@
|
||||
"fieldname": "add_serial_batch_for_rejected_qty",
|
||||
"fieldtype": "Button",
|
||||
"label": "Add Serial / Batch No (Rejected Qty)"
|
||||
},
|
||||
{
|
||||
"fieldname": "job_card",
|
||||
"fieldtype": "Link",
|
||||
"label": "Job Card",
|
||||
"options": "Job Card",
|
||||
"read_only": 1,
|
||||
"search_index": 1
|
||||
}
|
||||
],
|
||||
"idx": 1,
|
||||
"istable": 1,
|
||||
"links": [],
|
||||
"modified": "2024-03-29 15:42:43.425544",
|
||||
"modified": "2024-03-29 15:43:43.425544",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Subcontracting",
|
||||
"name": "Subcontracting Receipt Item",
|
||||
|
||||
Reference in New Issue
Block a user