Add option to skip material transfer for production orders
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.js b/erpnext/manufacturing/doctype/production_order/production_order.js
index 6037397..3ce87aa 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.js
+++ b/erpnext/manufacturing/doctype/production_order/production_order.js
@@ -72,15 +72,17 @@
message = title;
// pending qty
- var pending_complete = frm.doc.material_transferred_for_manufacturing - frm.doc.produced_qty;
- if(pending_complete) {
- var title = __('{0} items in progress', [pending_complete]);
- bars.push({
- 'title': title,
- 'width': ((pending_complete / frm.doc.qty * 100) - added_min) + '%',
- 'progress_class': 'progress-bar-warning'
- })
- message = message + '. ' + title;
+ if(!frm.doc.skip_transfer){
+ var pending_complete = frm.doc.material_transferred_for_manufacturing - frm.doc.produced_qty;
+ if(pending_complete) {
+ var title = __('{0} items in progress', [pending_complete]);
+ bars.push({
+ 'title': title,
+ 'width': ((pending_complete / frm.doc.qty * 100) - added_min) + '%',
+ 'progress_class': 'progress-bar-warning'
+ })
+ message = message + '. ' + title;
+ }
}
frm.dashboard.add_progress(__('Status'), bars, message);
}
@@ -122,21 +124,32 @@
frm.add_custom_button(__('Re-open'), cur_frm.cscript['Unstop Production Order'], __("Status"));
}
- if ((flt(doc.material_transferred_for_manufacturing) < flt(doc.qty)) && frm.doc.status != 'Stopped') {
+ if(!frm.doc.skip_transfer){
+ if ((flt(doc.material_transferred_for_manufacturing) < flt(doc.qty)) && frm.doc.status != 'Stopped') {
frm.has_start_btn = true;
var btn = frm.add_custom_button(__('Start'),
cur_frm.cscript['Transfer Raw Materials']);
btn.addClass('btn-primary');
+ }
}
- if ((flt(doc.produced_qty) < flt(doc.material_transferred_for_manufacturing)) && frm.doc.status != 'Stopped') {
- frm.has_finish_btn = true;
- var btn = frm.add_custom_button(__('Finish'),
- cur_frm.cscript['Update Finished Goods']);
+ if(!frm.doc.skip_transfer){
+ if ((flt(doc.produced_qty) < flt(doc.material_transferred_for_manufacturing)) && frm.doc.status != 'Stopped') {
+ frm.has_finish_btn = true;
+ var btn = frm.add_custom_button(__('Finish'),
+ cur_frm.cscript['Update Finished Goods']);
- if(doc.material_transferred_for_manufacturing==doc.qty) {
- // all materials transferred for manufacturing,
- // make this primary
+ if(doc.material_transferred_for_manufacturing==doc.qty) {
+ // all materials transferred for manufacturing,
+ // make this primary
+ btn.addClass('btn-primary');
+ }
+ }
+ } else if(frm.doc.skip_transfer){
+ if ((flt(doc.produced_qty) < flt(doc.qty)) && frm.doc.status != 'Stopped') {
+ frm.has_finish_btn = true;
+ var btn = frm.add_custom_button(__('Finish'),
+ cur_frm.cscript['Update Finished Goods']);
btn.addClass('btn-primary');
}
}
@@ -235,9 +248,15 @@
make_se: function(purpose) {
var me = this;
- var max = (purpose === "Manufacture") ?
- flt(this.frm.doc.material_transferred_for_manufacturing) - flt(this.frm.doc.produced_qty) :
- flt(this.frm.doc.qty) - flt(this.frm.doc.material_transferred_for_manufacturing);
+ if(!this.frm.doc.skip_transfer){
+ var max = (purpose === "Manufacture") ?
+ flt(this.frm.doc.material_transferred_for_manufacturing) - flt(this.frm.doc.produced_qty) :
+ flt(this.frm.doc.qty) - flt(this.frm.doc.material_transferred_for_manufacturing);
+ } else if(this.frm.doc.skip_transfer){
+ var max = (purpose === "Manufacture") ?
+ flt(this.frm.doc.qty) - flt(this.frm.doc.produced_qty) :
+ flt(this.frm.doc.qty) - flt(this.frm.doc.produced_qty);
+ }
frappe.prompt({fieldtype:"Float", label: __("Qty for {0}", [purpose]), fieldname:"qty",
description: __("Max: {0}", [max]), 'default': max },
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.json b/erpnext/manufacturing/doctype/production_order/production_order.json
index 882833f..1507089 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.json
+++ b/erpnext/manufacturing/doctype/production_order/production_order.json
@@ -318,6 +318,36 @@
"search_index": 0,
"set_only_once": 0,
"unique": 0
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "columns": 0,
+ "description": "Check if material transfer entry is not required",
+ "fieldname": "skip_transfer",
+ "fieldtype": "Check",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
+ "in_filter": 0,
+ "in_global_search": 0,
+ "in_list_view": 0,
+ "in_standard_filter": 0,
+ "label": "Skip Material Transfer",
+ "length": 0,
+ "no_copy": 0,
+ "permlevel": 0,
+ "precision": "",
+ "print_hide": 0,
+ "print_hide_if_no_value": 0,
+ "read_only": 0,
+ "remember_last_selected_value": 0,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0
},
{
"allow_on_submit": 0,
diff --git a/erpnext/manufacturing/doctype/production_order/production_order.py b/erpnext/manufacturing/doctype/production_order/production_order.py
index b9b10c1..ff1082d 100644
--- a/erpnext/manufacturing/doctype/production_order/production_order.py
+++ b/erpnext/manufacturing/doctype/production_order/production_order.py
@@ -535,7 +535,7 @@
stock_entry.from_warehouse = production_order.wip_warehouse
stock_entry.to_warehouse = production_order.fg_warehouse
additional_costs = get_additional_costs(production_order, fg_qty=stock_entry.fg_completed_qty)
- stock_entry.project = frappe.db.get_value("Stock Entry",{"production_order": production_order_id,"purpose": "Material Transfer for Manufacture"}, "project")
+ stock_entry.project = production_order.project
stock_entry.set("additional_costs", additional_costs)
stock_entry.get_items()