From 06072c1e51e658490448b6da51ddc3a39f379b50 Mon Sep 17 00:00:00 2001
From: Rushabh Mehta
Date: Tue, 17 Feb 2015 11:50:45 +0530
Subject: [PATCH] [refactor] Material Transfer for Manufacture
---
.../production_order/production_order.js | 6 +-
.../production_order/production_order.py | 8 +-
erpnext/patches.txt | 1 +
...pdate_material_transfer_for_manufacture.py | 5 +
.../stock/doctype/stock_entry/stock_entry.js | 13 +-
.../doctype/stock_entry/stock_entry.json | 1160 ++++++++---------
.../stock/doctype/stock_entry/stock_entry.py | 21 +-
.../templates/form_grid/stock_entry_grid.html | 17 +-
8 files changed, 623 insertions(+), 608 deletions(-)
create mode 100644 erpnext/patches/v5_0/update_material_transfer_for_manufacture.py
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.js b/erpnext/manufacturing/doctype/production_order/production_order.js
index f7ebaa95d9f..2eeef0801e1 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.js
+++ b/erpnext/manufacturing/doctype/production_order/production_order.js
@@ -7,7 +7,7 @@ $.extend(cur_frm.cscript, {
cfn_set_fields(doc, dt, dn);
this.frm.add_fetch("sales_order", "delivery_date", "expected_delivery_date");
-
+
if(doc.__islocal) {
cur_frm.set_value({
"actual_start_date": "",
@@ -70,7 +70,7 @@ $.extend(cur_frm.cscript, {
method: "set_production_order_operations"
});
},
-
+
planned_start_date: function() {
return this.frm.call({
doc: this.frm.doc,
@@ -144,7 +144,7 @@ cur_frm.cscript['Unstop Production Order'] = function() {
}
cur_frm.cscript['Transfer Raw Materials'] = function() {
- cur_frm.cscript.make_se('Material Transfer');
+ cur_frm.cscript.make_se('Material Transfer for Manufacture');
}
cur_frm.cscript['Update Finished Goods'] = function() {
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py
index 67b53f633b1..7375cf229ee 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.py
+++ b/erpnext/manufacturing/doctype/production_order/production_order.py
@@ -210,7 +210,7 @@ class ProductionOrder(Document):
d.status = "Completed"
else:
frappe.throw(_("Completed Qty can not be greater than 'Qty to Manufacture'"))
-
+
def set_actual_dates(self):
if self.get("operations"):
actual_date = frappe.db.sql("""select min(actual_start_time) as start_date, max(actual_end_time) as end_date from `tabProduction Order Operation`
@@ -220,11 +220,11 @@ class ProductionOrder(Document):
else:
self.actual_start_date = None
self.actual_end_date = None
-
+
def validate_delivery_date(self):
if self.planned_start_date and self.expected_delivery_date and getdate(self.expected_delivery_date) < getdate(self.planned_start_date):
frappe.throw(_("Expected Delivery Date cannot be greater than Planned Start Date"))
-
+
if self.planned_end_date and self.expected_delivery_date and getdate(self.expected_delivery_date) < getdate(self.planned_end_date):
frappe.msgprint(_("Production might not be able to finish by the Expected Delivery Date."))
@@ -254,7 +254,7 @@ def make_stock_entry(production_order_id, purpose, qty=None):
stock_entry.use_multi_level_bom = production_order.use_multi_level_bom
stock_entry.fg_completed_qty = qty or (flt(production_order.qty) - flt(production_order.produced_qty))
- if purpose=="Material Transfer":
+ if purpose=="Material Transfer for Manufacture":
stock_entry.to_warehouse = production_order.wip_warehouse
else:
stock_entry.from_warehouse = production_order.wip_warehouse
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 147525e2cbf..d1955f2e578 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -111,3 +111,4 @@ erpnext.patches.v5_0.update_item_name_in_bom
execute:frappe.reload_doc('crm', 'doctype', 'lead')
execute:frappe.reload_doc('crm', 'doctype', 'opportunity')
erpnext.patches.v5_0.rename_customer_issue
+erpnext.patches.v5_0.update_material_transfer_for_manufacture
diff --git a/erpnext/patches/v5_0/update_material_transfer_for_manufacture.py b/erpnext/patches/v5_0/update_material_transfer_for_manufacture.py
new file mode 100644
index 00000000000..d862ad3d753
--- /dev/null
+++ b/erpnext/patches/v5_0/update_material_transfer_for_manufacture.py
@@ -0,0 +1,5 @@
+import frappe
+
+def execute():
+ frappe.db.sql("""update `tabStock Entry` set purpose='Material Transfer for Manufacture'
+ where ifnull(production_order, '')!='' and purpose='Material Transfer'""")
diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.js b/erpnext/stock/doctype/stock_entry/stock_entry.js
index cc7169bf85c..a77aa748ea6 100644
--- a/erpnext/stock/doctype/stock_entry/stock_entry.js
+++ b/erpnext/stock/doctype/stock_entry/stock_entry.js
@@ -122,7 +122,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
clean_up: function() {
// Clear Production Order record from locals, because it is updated via Stock Entry
if(this.frm.doc.production_order &&
- this.frm.doc.purpose == "Manufacture") {
+ in_list(["Manufacture", "Material Transfer for Manufacture"], this.frm.doc.purpose)) {
frappe.model.remove_from_locals("Production Order",
this.frm.doc.production_order);
}
@@ -164,7 +164,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
},
toggle_enable_bom: function() {
- this.frm.toggle_enable("bom_no", this.frm.doc.purpose!="Manufacture");
+ this.frm.toggle_enable("bom_no", !in_list(["Manufacture", "Material Transfer for Manufacture"], this.frm.doc.purpose));
},
get_doctype_docname: function() {
@@ -233,8 +233,10 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
if(!row.t_warehouse) row.t_warehouse = this.frm.doc.to_warehouse;
},
- source_mandatory: ["Material Issue", "Material Transfer", "Purchase Return", "Subcontract"],
- target_mandatory: ["Material Receipt", "Material Transfer", "Sales Return", "Subcontract"],
+ source_mandatory: ["Material Issue", "Material Transfer", "Purchase Return", "Subcontract",
+ "Material Transfer for Manufacture"],
+ target_mandatory: ["Material Receipt", "Material Transfer", "Sales Return", "Subcontract",
+ "Material Transfer for Manufacture"],
from_warehouse: function(doc) {
var me = this;
@@ -251,6 +253,7 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
},
set_warehouse_if_missing: function(fieldname, value, condition) {
+ var changed = false;
for (var i=0, l=(this.frm.doc.items || []).length; i{%= doc.description %}
{% } %}
{% include "templates/form_grid/includes/visible_cols.html" %}
- {% if(doc.s_warehouse) { %}
- {%= doc.s_warehouse || "" %}{% } %}
-
+ {% if(doc.s_warehouse) { %}
+
+ {%= doc.s_warehouse || "" %}
+ {% } %}
+
{% if(doc.t_warehouse) { %}
{%= doc.t_warehouse || "" %}{% } %}
+ {% if(doc.s_warehouse && doc.actual_qty < doc.qty) { %}
+
+ Not in Stock
+
+ {% } %}