Merge pull request #35842 from rohitwaghchaure/fixed-multiple-work-orders-against-sigle-production-order

fix: multiple Work Orders against same production plan
This commit is contained in:
rohitwaghchaure 2023-06-22 22:11:09 +05:30 committed by GitHub
commit f4f8df6cfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View File

@ -99,7 +99,7 @@ frappe.ui.form.on('Production Plan', {
}, __('Create'));
}
if (frm.doc.mr_items && !in_list(['Material Requested', 'Closed'], frm.doc.status)) {
if (frm.doc.mr_items && frm.doc.mr_items.length && !in_list(['Material Requested', 'Closed'], frm.doc.status)) {
frm.add_custom_button(__("Material Request"), ()=> {
frm.trigger("make_material_request");
}, __('Create'));

View File

@ -515,6 +515,9 @@ class ProductionPlan(Document):
self.show_list_created_message("Work Order", wo_list)
self.show_list_created_message("Purchase Order", po_list)
if not wo_list:
frappe.msgprint(_("No Work Orders were created"))
def make_work_order_for_finished_goods(self, wo_list, default_warehouses):
items_data = self.get_production_items()
@ -618,6 +621,9 @@ class ProductionPlan(Document):
def create_work_order(self, item):
from erpnext.manufacturing.doctype.work_order.work_order import OverProductionError
if item.get("qty") <= 0:
return
wo = frappe.new_doc("Work Order")
wo.update(item)
wo.planned_start_date = item.get("planned_start_date") or item.get("schedule_date")

View File

@ -76,6 +76,13 @@ class TestProductionPlan(FrappeTestCase):
"Work Order", fields=["name"], filters={"production_plan": pln.name}, as_list=1
)
pln.make_work_order()
nwork_orders = frappe.get_all(
"Work Order", fields=["name"], filters={"production_plan": pln.name}, as_list=1
)
self.assertTrue(len(work_orders), len(nwork_orders))
self.assertTrue(len(work_orders), len(pln.po_items))
for name in material_requests: