From 8d5d5cc0a714ccb5b314108c207ab627b19db5c3 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Wed, 1 Apr 2015 17:31:12 +0530 Subject: [PATCH 1/8] Planned Start Date made mandatory in production order server side check added to not plan operations if planned_start_date is None Production Order on submit - unwanted error messsages problem fixed. --- .../doctype/production_order/production_order.json | 7 ++++--- .../doctype/production_order/production_order.py | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.json b/erpnext/manufacturing/doctype/production_order/production_order.json index 59473ad1e9..4463cd0bc8 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.json +++ b/erpnext/manufacturing/doctype/production_order/production_order.json @@ -172,7 +172,8 @@ "fieldtype": "Datetime", "label": "Planned Start Date", "permlevel": 0, - "precision": "" + "precision": "", + "reqd": 1 }, { "fieldname": "planned_end_date", @@ -354,8 +355,8 @@ "icon": "icon-cogs", "idx": 1, "in_create": 0, - "is_submittable": 1, - "modified": "2015-03-10 17:02:28.401930", + "is_submittable": 1, + "modified": "2015-04-01 07:32:38.426624", "modified_by": "Administrator", "module": "Manufacturing", "name": "Production Order", diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index 6818ba9990..c8c3f6505e 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -201,7 +201,7 @@ class ProductionOrder(Document): Planned Start Date. Time logs will be created and remain in Draft mode and must be submitted before manufacturing entry can be made.""" - if not self.operations: + if not self.operations and not self.planned_start_date: return time_logs = [] @@ -248,6 +248,7 @@ class ProductionOrder(Document): self.planned_end_date = self.operations[-1].planned_end_time if time_logs: + frappe.local.message_log = [] frappe.msgprint(_("Time Logs created:") + "\n" + "\n".join(time_logs)) def set_operation_start_end_time(self, i, d): From 5ab7d930b6c3f0167c387d2179d366f54dc5716c Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Wed, 1 Apr 2015 17:59:01 +0530 Subject: [PATCH 2/8] make time log button in Production order operations fixed show time logs button made available for compleated operations --- .../doctype/production_order/production_order.js | 5 +++-- .../production_order_operation.json | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.js b/erpnext/manufacturing/doctype/production_order/production_order.js index 36cb1aecdd..471b46b4bf 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.js +++ b/erpnext/manufacturing/doctype/production_order/production_order.js @@ -204,12 +204,13 @@ $.extend(cur_frm.cscript, { method:"erpnext.manufacturing.doctype.production_order.production_order.make_time_log", args: { "name": doc.name, - "operation": child.idx + ". " + child.operation, + "operation": child.operation, "from_time": child.planned_start_time, "to_time": child.planned_end_time, "project": doc.project, "workstation": child.workstation, - "qty": flt(doc.qty) - flt(child.completed_qty) + "qty": flt(doc.qty) - flt(child.completed_qty), + "operation_id": child.name }, callback: function(r) { var doclist = frappe.model.sync(r.message); diff --git a/erpnext/manufacturing/doctype/production_order_operation/production_order_operation.json b/erpnext/manufacturing/doctype/production_order_operation/production_order_operation.json index faa7687f1d..40ecec5d3d 100644 --- a/erpnext/manufacturing/doctype/production_order_operation/production_order_operation.json +++ b/erpnext/manufacturing/doctype/production_order_operation/production_order_operation.json @@ -126,7 +126,7 @@ }, { "allow_on_submit": 1, - "depends_on": "eval:(doc.docstatus==1 && doc.status!=\"Completed\")", + "depends_on": "eval:(doc.docstatus==1)", "fieldname": "show_time_logs", "fieldtype": "Button", "label": "Show Time Logs", @@ -277,6 +277,7 @@ "read_only": 1 }, { + "allow_on_submit": 1, "depends_on": "eval:(doc.docstatus==1 && doc.status!=\"Completed\")", "fieldname": "make_time_log", "fieldtype": "Button", @@ -292,7 +293,7 @@ "is_submittable": 0, "issingle": 0, "istable": 1, - "modified": "2015-03-24 07:02:54.203235", + "modified": "2015-04-01 08:23:58.556092", "modified_by": "Administrator", "module": "Manufacturing", "name": "Production Order Operation", From cd1816cc5a4ceab62823c7a29d96b9a94a1e96f2 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Mon, 6 Apr 2015 12:41:44 +0530 Subject: [PATCH 3/8] removed unnecesssary functions. Production related feilds made mandatory in TIme Log --- erpnext/projects/doctype/time_log/time_log.js | 43 +------------------ .../projects/doctype/time_log/time_log.json | 8 ++-- erpnext/projects/doctype/time_log/time_log.py | 14 ------ .../stock/doctype/stock_entry/stock_entry.py | 2 +- 4 files changed, 6 insertions(+), 61 deletions(-) diff --git a/erpnext/projects/doctype/time_log/time_log.js b/erpnext/projects/doctype/time_log/time_log.js index 91971f3b2d..a49b1f1c04 100644 --- a/erpnext/projects/doctype/time_log/time_log.js +++ b/erpnext/projects/doctype/time_log/time_log.js @@ -41,45 +41,4 @@ frappe.ui.form.on("Time Log", "to_time", function(frm) { if(frm._setting_hours) return; frm.set_value("hours", moment(cur_frm.doc.to_time).diff(moment(cur_frm.doc.from_time), "hours")); -}); - -cur_frm.set_query("production_order", function(doc) { - return { - "filters": { - "docstatus": 1 - } - }; -}); - -cur_frm.add_fetch('task','project','project'); - -$.extend(cur_frm.cscript, { - production_order: function(doc) { - if (doc.production_order){ - var operations = []; - frappe.model.with_doc("Production Order", doc.production_order, function(pro) { - doc = frappe.get_doc("Production Order",pro); - $.each(doc.operations , function(i, row){ - operations[i] = row.operation; - }); - frappe.meta.get_docfield("Time Log", "operation", me.frm.doc.name).options = "\n" + operations.join("\n"); - refresh_field("operation"); - }) - } - }, - - operation: function(doc) { - return frappe.call({ - method: "erpnext.projects.doctype.time_log.time_log.get_workstation", - args: { - "production_order": doc.production_order, - "operation": doc.operation - }, - callback: function(r) { - if(!r.exc) { - cur_frm.set_value("workstation", r.message) - } - } - }); - } -}); +}); \ No newline at end of file diff --git a/erpnext/projects/doctype/time_log/time_log.json b/erpnext/projects/doctype/time_log/time_log.json index 6ef576f7f7..20b5c0c296 100644 --- a/erpnext/projects/doctype/time_log/time_log.json +++ b/erpnext/projects/doctype/time_log/time_log.json @@ -117,7 +117,7 @@ "options": "Production Order", "permlevel": 0, "precision": "", - "read_only": 0 + "read_only": 1 }, { "depends_on": "", @@ -127,7 +127,7 @@ "options": "Operation", "permlevel": 0, "precision": "", - "read_only": 0 + "read_only": 1 }, { "depends_on": "", @@ -155,7 +155,7 @@ "options": "Workstation", "permlevel": 0, "precision": "", - "read_only": 0 + "read_only": 1 }, { "depends_on": "", @@ -242,7 +242,7 @@ "icon": "icon-time", "idx": 1, "is_submittable": 1, - "modified": "2015-03-24 08:10:31.412670", + "modified": "2015-04-06 02:47:16.187046", "modified_by": "Administrator", "module": "Projects", "name": "Time Log", diff --git a/erpnext/projects/doctype/time_log/time_log.py b/erpnext/projects/doctype/time_log/time_log.py index a499c8f788..c385c0935b 100644 --- a/erpnext/projects/doctype/time_log/time_log.py +++ b/erpnext/projects/doctype/time_log/time_log.py @@ -206,20 +206,6 @@ class TimeLog(Document): self.operation = None self.quantity = None -@frappe.whitelist() -def get_workstation(production_order, operation): - """Returns workstation name from Production Order against an associated Operation. - - :param production_order string - :param operation string - """ - if operation: - idx, operation = operation.split('. ',1) - - workstation = frappe.db.sql("""select workstation from `tabProduction Order Operation` where idx=%s and - parent=%s and operation = %s""", (idx, production_order, operation)) - return workstation[0][0] if workstation else "" - @frappe.whitelist() def get_events(start, end, filters=None): """Returns events for Gantt / Calendar view rendering. diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index bd2d945ca8..b9dbc9aa08 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -474,7 +474,7 @@ class StockEntry(StockController): pro_doc = frappe.get_doc("Production Order", self.production_order) _validate_production_order(pro_doc) pro_doc.run_method("update_status") - if self.purpose == "Manufacture": + if self.purpose in ["Manufacture", "Material Transfer for Manufacture"]: pro_doc.run_method("update_production_order_qty") self.update_planned_qty(pro_doc) From d3d94d1efe7b64f33a15a4c0d3d6074966becb32 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Mon, 6 Apr 2015 12:53:37 +0530 Subject: [PATCH 4/8] fix- Material Transferred for Manufacturing not Updating in Production Order Error --- erpnext/stock/doctype/stock_entry/stock_entry.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index b9dbc9aa08..3df4f94ee2 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -474,9 +474,8 @@ class StockEntry(StockController): pro_doc = frappe.get_doc("Production Order", self.production_order) _validate_production_order(pro_doc) pro_doc.run_method("update_status") - if self.purpose in ["Manufacture", "Material Transfer for Manufacture"]: - pro_doc.run_method("update_production_order_qty") - self.update_planned_qty(pro_doc) + pro_doc.run_method("update_production_order_qty") + self.update_planned_qty(pro_doc) def update_planned_qty(self, pro_doc): from erpnext.stock.utils import update_bin From c43ac20115fe377164592cbc44c0dd77f0dc2313 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Wed, 8 Apr 2015 13:48:07 +0530 Subject: [PATCH 5/8] Fixes in logic for production order scheduling --- .../manufacturing/doctype/production_order/production_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index c8c3f6505e..7b70815635 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -201,7 +201,7 @@ class ProductionOrder(Document): Planned Start Date. Time logs will be created and remain in Draft mode and must be submitted before manufacturing entry can be made.""" - if not self.operations and not self.planned_start_date: + if not (self.operations and self.planned_start_date): return time_logs = [] From 1371afce2ec37db6acb976c1de06eb91d0e6ce8a Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Mon, 13 Apr 2015 12:15:52 +0530 Subject: [PATCH 6/8] added default date to planned start date in Prod Order & made planned end date read-only --- .../doctype/production_order/production_order.json | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.json b/erpnext/manufacturing/doctype/production_order/production_order.json index 4463cd0bc8..07cc5c64b1 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.json +++ b/erpnext/manufacturing/doctype/production_order/production_order.json @@ -167,7 +167,7 @@ "read_only": 0 }, { - "default": "", + "default": "now", "fieldname": "planned_start_date", "fieldtype": "Datetime", "label": "Planned Start Date", @@ -179,8 +179,10 @@ "fieldname": "planned_end_date", "fieldtype": "Datetime", "label": "Planned End Date", + "no_copy": 1, "permlevel": 0, - "precision": "" + "precision": "", + "read_only": 1 }, { "fieldname": "column_break_13", @@ -356,7 +358,7 @@ "idx": 1, "in_create": 0, "is_submittable": 1, - "modified": "2015-04-01 07:32:38.426624", + "modified": "2015-04-13 02:44:17.319988", "modified_by": "Administrator", "module": "Manufacturing", "name": "Production Order", From cf96cc26a0ec3fae611203b4bf482a94c5e5af60 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Mon, 13 Apr 2015 13:04:18 +0530 Subject: [PATCH 7/8] Fixes for test cases --- erpnext/stock/doctype/stock_entry/stock_entry.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index 3df4f94ee2..0196c31bf1 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -475,7 +475,8 @@ class StockEntry(StockController): _validate_production_order(pro_doc) pro_doc.run_method("update_status") pro_doc.run_method("update_production_order_qty") - self.update_planned_qty(pro_doc) + if self.purpose == "Manufacture": + self.update_planned_qty(pro_doc) def update_planned_qty(self, pro_doc): from erpnext.stock.utils import update_bin From 18dc151fc781be4bc6bb7fc55df1ce72143c98ee Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Tue, 14 Apr 2015 13:06:07 +0530 Subject: [PATCH 8/8] Fixes in make_time_log function in Production Order --- .../manufacturing/doctype/production_order/production_order.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py index 7b70815635..fa27e9533d 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -201,7 +201,7 @@ class ProductionOrder(Document): Planned Start Date. Time logs will be created and remain in Draft mode and must be submitted before manufacturing entry can be made.""" - if not (self.operations and self.planned_start_date): + if not self.operations: return time_logs = []