diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.js b/erpnext/manufacturing/doctype/production_plan/production_plan.js index 1a64bc5e24..b723387a09 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.js +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.js @@ -56,23 +56,35 @@ frappe.ui.form.on('Production Plan', { refresh: function(frm) { if (frm.doc.docstatus === 1) { frm.trigger("show_progress"); + + if (frm.doc.status !== "Completed") { + if (frm.doc.po_items && frm.doc.status !== "Closed") { + frm.add_custom_button(__("Work Order"), ()=> { + frm.trigger("make_work_order"); + }, __('Create')); + } + + if (frm.doc.mr_items && !in_list(['Material Requested', 'Closed'], frm.doc.status)) { + frm.add_custom_button(__("Material Request"), ()=> { + frm.trigger("make_material_request"); + }, __('Create')); + } + + if (frm.doc.status === "Closed") { + frm.add_custom_button(__("Re-open"), function() { + frm.events.close_open_production_plan(frm, false); + }, __("Status")); + } else { + frm.add_custom_button(__("Close"), function() { + frm.events.close_open_production_plan(frm, true); + }, __("Status")); + } + } } - if (frm.doc.docstatus === 1 && frm.doc.po_items - && frm.doc.status != 'Completed') { - frm.add_custom_button(__("Work Order"), ()=> { - frm.trigger("make_work_order"); - }, __('Create')); + if (frm.doc.status !== "Closed") { + frm.page.set_inner_btn_group_as_primary(__('Create')); } - - if (frm.doc.docstatus === 1 && frm.doc.mr_items - && !in_list(['Material Requested', 'Completed'], frm.doc.status)) { - frm.add_custom_button(__("Material Request"), ()=> { - frm.trigger("make_material_request"); - }, __('Create')); - } - - frm.page.set_inner_btn_group_as_primary(__('Create')); frm.trigger("material_requirement"); const projected_qty_formula = ` @@ -121,6 +133,18 @@ frappe.ui.form.on('Production Plan', { set_field_options("projected_qty_formula", projected_qty_formula); }, + close_open_production_plan: (frm, close=false) => { + frappe.call({ + method: "set_status", + freeze: true, + doc: frm.doc, + args: {close : close}, + callback: function() { + frm.reload_doc(); + } + }); + }, + make_work_order: function(frm) { frappe.call({ method: "make_work_order", diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.json b/erpnext/manufacturing/doctype/production_plan/production_plan.json index 90e8b22ed9..850d5aeff8 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.json +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.json @@ -275,7 +275,7 @@ "fieldtype": "Select", "label": "Status", "no_copy": 1, - "options": "\nDraft\nSubmitted\nNot Started\nIn Process\nCompleted\nStopped\nCancelled\nMaterial Requested", + "options": "\nDraft\nSubmitted\nNot Started\nIn Process\nCompleted\nClosed\nCancelled\nMaterial Requested", "print_hide": 1, "read_only": 1 }, @@ -304,9 +304,10 @@ } ], "icon": "fa fa-calendar", + "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], - "modified": "2020-02-03 00:25:25.934202", + "modified": "2020-10-26 13:00:54.335319", "modified_by": "Administrator", "module": "Manufacturing", "name": "Production Plan", diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan.py b/erpnext/manufacturing/doctype/production_plan/production_plan.py index feac9c8fa2..a314a15c23 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan.py +++ b/erpnext/manufacturing/doctype/production_plan/production_plan.py @@ -219,13 +219,17 @@ class ProductionPlan(Document): filters = {'docstatus': 0, 'production_plan': ("=", self.name)}): frappe.delete_doc('Work Order', d.name) - def set_status(self): + def set_status(self, close=None): self.status = { 0: 'Draft', 1: 'Submitted', 2: 'Cancelled' }.get(self.docstatus) + if close: + self.db_set('status', 'Closed') + return + if self.total_produced_qty > 0: self.status = "In Process" if self.total_produced_qty == self.total_planned_qty: @@ -235,6 +239,9 @@ class ProductionPlan(Document): self.update_ordered_status() self.update_requested_status() + if close is not None: + self.db_set('status', self.status) + def update_ordered_status(self): update_status = False for d in self.po_items: diff --git a/erpnext/manufacturing/doctype/production_plan/production_plan_list.js b/erpnext/manufacturing/doctype/production_plan/production_plan_list.js index d377ef0af7..165b66ff5d 100644 --- a/erpnext/manufacturing/doctype/production_plan/production_plan_list.js +++ b/erpnext/manufacturing/doctype/production_plan/production_plan_list.js @@ -1,6 +1,6 @@ frappe.listview_settings['Production Plan'] = { add_fields: ["status"], - filters: [["status", "!=", "Stopped"]], + filters: [["status", "!=", "Closed"]], get_indicator: function(doc) { if(doc.status==="Submitted") { return [__("Not Started"), "orange", "status,=,Submitted"]; @@ -10,7 +10,8 @@ frappe.listview_settings['Production Plan'] = { "In Process": "orange", "Completed": "green", "Material Requested": "darkgrey", - "Cancelled": "darkgrey" + "Cancelled": "darkgrey", + "Closed": "grey" }[doc.status], "status,=," + doc.status]; } } diff --git a/erpnext/manufacturing/doctype/production_plan_material_request_warehouse/production_plan_material_request_warehouse.json b/erpnext/manufacturing/doctype/production_plan_material_request_warehouse/production_plan_material_request_warehouse.json index 53e33c0265..e72f48943c 100644 --- a/erpnext/manufacturing/doctype/production_plan_material_request_warehouse/production_plan_material_request_warehouse.json +++ b/erpnext/manufacturing/doctype/production_plan_material_request_warehouse/production_plan_material_request_warehouse.json @@ -11,30 +11,20 @@ { "fieldname": "warehouse", "fieldtype": "Link", + "in_list_view": 1, "label": "Warehouse", "options": "Warehouse" } ], + "index_web_pages_for_search": 1, + "istable": 1, "links": [], - "modified": "2020-02-02 10:37:16.650836", + "modified": "2020-10-26 12:55:00.778201", "modified_by": "Administrator", "module": "Manufacturing", "name": "Production Plan Material Request Warehouse", "owner": "Administrator", - "permissions": [ - { - "create": 1, - "delete": 1, - "email": 1, - "export": 1, - "print": 1, - "read": 1, - "report": 1, - "role": "System Manager", - "share": 1, - "write": 1 - } - ], + "permissions": [], "quick_entry": 1, "sort_field": "modified", "sort_order": "DESC",