From 2771b7d82865e3316eba99a19eb894fddef2cf83 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Tue, 21 Jul 2015 18:11:43 +0530 Subject: [PATCH] Track Operations removed and Global Switch added to disable capacity planning in manufacturing settings --- .../manufacturing_settings.json | 10 +++++++++- .../production_order/production_order.js | 19 ++++--------------- .../production_order/production_order.json | 14 +++----------- .../production_order/production_order.py | 7 +------ erpnext/patches.txt | 1 - erpnext/patches/v5_1/track_operations.py | 8 -------- .../stock/doctype/stock_entry/stock_entry.py | 4 +--- 7 files changed, 18 insertions(+), 45 deletions(-) delete mode 100644 erpnext/patches/v5_1/track_operations.py diff --git a/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json b/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json index ea9569f9b4..4c0028034b 100644 --- a/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json +++ b/erpnext/manufacturing/doctype/manufacturing_settings/manufacturing_settings.json @@ -15,6 +15,14 @@ "permlevel": 0, "precision": "" }, + { + "description": "Disables creation of time logs against Production Orders.\nOperations shall not be tracked against Production Order", + "fieldname": "disable_capacity_planning", + "fieldtype": "Check", + "label": "Disable Capacity Planning", + "permlevel": 0, + "precision": "" + }, { "description": "Plan time logs outside Workstation Working Hours.", "fieldname": "allow_overtime", @@ -72,7 +80,7 @@ "is_submittable": 0, "issingle": 1, "istable": 0, - "modified": "2015-06-15 05:52:22.986958", + "modified": "2015-07-21 08:51:01.651774", "modified_by": "Administrator", "module": "Manufacturing", "name": "Manufacturing Settings", diff --git a/erpnext/manufacturing/doctype/production_order/production_order.js b/erpnext/manufacturing/doctype/production_order/production_order.js index 17fa202a4d..f8d76fff63 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.js +++ b/erpnext/manufacturing/doctype/production_order/production_order.js @@ -186,27 +186,16 @@ $.extend(cur_frm.cscript, { }, bom_no: function() { - if (this.frm.doc.track_operations) { - return this.frm.call({ - doc: this.frm.doc, - method: "set_production_order_operations" - }); - } + return this.frm.call({ + doc: this.frm.doc, + method: "set_production_order_operations" + }); }, qty: function() { frappe.ui.form.trigger("Production Order", 'bom_no') }, - track_operations: function(doc) { - if (doc.track_operations) { - frappe.ui.form.trigger("Production Order", 'bom_no') - } - else { - doc.operations =[]; - } - }, - show_time_logs: function(doc, cdt, cdn) { var child = locals[cdt][cdn] frappe.route_options = {"operation_id": child.name}; diff --git a/erpnext/manufacturing/doctype/production_order/production_order.json b/erpnext/manufacturing/doctype/production_order/production_order.json index 75aab9963e..e07ac5bf97 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.json +++ b/erpnext/manufacturing/doctype/production_order/production_order.json @@ -73,14 +73,6 @@ "label": "Use Multi-Level BOM", "permlevel": 0 }, - { - "default": "1", - "fieldname": "track_operations", - "fieldtype": "Check", - "label": "Track Operations", - "permlevel": 0, - "precision": "" - }, { "fieldname": "column_break1", "fieldtype": "Column Break", @@ -215,7 +207,7 @@ "read_only": 1 }, { - "depends_on": "track_operations", + "depends_on": "", "fieldname": "operations_section", "fieldtype": "Section Break", "label": "Operations", @@ -234,7 +226,7 @@ "read_only": 1 }, { - "depends_on": "track_operations", + "depends_on": "operations", "fieldname": "section_break_22", "fieldtype": "Section Break", "label": "Operation Cost", @@ -368,7 +360,7 @@ "idx": 1, "in_create": 0, "is_submittable": 1, - "modified": "2015-07-13 05:28:23.259016", + "modified": "2015-07-21 07:45:53.206902", "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 93ce5e16f6..072ad41b5a 100644 --- a/erpnext/manufacturing/doctype/production_order/production_order.py +++ b/erpnext/manufacturing/doctype/production_order/production_order.py @@ -174,17 +174,12 @@ class ProductionOrder(Document): def set_production_order_operations(self): """Fetch operations from BOM and set in 'Production Order'""" - if not self.bom_no: + if not self.bom_no or cint(frappe.db.get_single_value("Manufacturing Settings", "disable_capacity_planning")): return self.set('operations', []) operations = frappe.db.sql("""select operation, description, workstation, idx, hour_rate, time_in_mins, "Pending" as status from `tabBOM Operation` where parent = %s order by idx""", self.bom_no, as_dict=1) - if operations: - self.track_operations=1 - else: - self.track_operations=0 - frappe.msgprint(_("Cannot 'track operations' as selected BOM does not have Operations.")) self.set('operations', operations) self.calculate_time() diff --git a/erpnext/patches.txt b/erpnext/patches.txt index c7355073c4..762912372b 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -173,7 +173,6 @@ erpnext.patches.v5_0.item_variants erpnext.patches.v5_0.update_item_desc_in_invoice erpnext.patches.v5_1.fix_against_account erpnext.patches.v5_1.fix_credit_days_based_on -erpnext.patches.v5_1.track_operations execute:frappe.rename_doc("DocType", "Salary Manager", "Process Payroll", force=True) erpnext.patches.v5_1.rename_roles erpnext.patches.v5_1.default_bom diff --git a/erpnext/patches/v5_1/track_operations.py b/erpnext/patches/v5_1/track_operations.py deleted file mode 100644 index 0a121420e5..0000000000 --- a/erpnext/patches/v5_1/track_operations.py +++ /dev/null @@ -1,8 +0,0 @@ -from __future__ import unicode_literals - -import frappe - -def execute(): - frappe.reload_doctype("Production Order") - frappe.db.sql("""Update `tabProduction Order` as po set track_operations=1 where - exists(select name from `tabProduction Order Operation` as po_operation where po_operation.parent = po.name )""") \ No newline at end of file diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index fb1ec3d17b..cae057123b 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -201,9 +201,7 @@ class StockEntry(StockController): def check_if_operations_completed(self): """Check if Time Logs are completed against before manufacturing to capture operating costs.""" prod_order = frappe.get_doc("Production Order", self.production_order) - if not prod_order.track_operations: - return - + for d in prod_order.get("operations"): total_completed_qty = flt(self.fg_completed_qty) + flt(prod_order.produced_qty) if total_completed_qty > flt(d.completed_qty):