[refactor] Material Transfer for Manufacture
This commit is contained in:
parent
46e03eadca
commit
06072c1e51
@ -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() {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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'""")
|
@ -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<l; i++) {
|
||||
var row = this.frm.doc.items[i];
|
||||
if (!row[fieldname]) {
|
||||
@ -259,8 +262,10 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
||||
}
|
||||
|
||||
frappe.model.set_value(row.doctype, row.name, fieldname, value, "Link");
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
refresh_field("items");
|
||||
},
|
||||
|
||||
items_on_form_rendered: function(doc, grid_row) {
|
||||
|
@ -46,7 +46,7 @@
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "purpose",
|
||||
"oldfieldtype": "Select",
|
||||
"options": "Material Issue\nMaterial Receipt\nMaterial Transfer\nManufacture\nRepack\nSubcontract\nSales Return\nPurchase Return",
|
||||
"options": "Material Issue\nMaterial Receipt\nMaterial Transfer\nMaterial Transfer for Manufacture\nManufacture\nRepack\nSubcontract\nSales Return\nPurchase Return",
|
||||
"permlevel": 0,
|
||||
"print_hide": 0,
|
||||
"read_only": 0,
|
||||
@ -54,6 +54,34 @@
|
||||
"reqd": 1,
|
||||
"search_index": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"depends_on": "eval:in_list([\"Material Transfer for Manufacture\", \"Manufacture\"], doc.purpose)",
|
||||
"fieldname": "production_order",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"in_filter": 1,
|
||||
"label": "Production Order",
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "production_order",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Production Order",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:!inList([\"Sales Return\", \"Purchase Return\"], doc.purpose)",
|
||||
"fieldname": "bom_no",
|
||||
"fieldtype": "Link",
|
||||
"label": "BOM No",
|
||||
"options": "BOM",
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"depends_on": "eval:doc.purpose==\"Sales Return\"",
|
||||
@ -245,34 +273,6 @@
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"depends_on": "eval:inList([\"Material Transfer\", \"Manufacture\"], doc.purpose)",
|
||||
"fieldname": "production_order",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"in_filter": 1,
|
||||
"label": "Production Order",
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "production_order",
|
||||
"oldfieldtype": "Link",
|
||||
"options": "Production Order",
|
||||
"permlevel": 0,
|
||||
"print_hide": 1,
|
||||
"read_only": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 1
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:!inList([\"Sales Return\", \"Purchase Return\"], doc.purpose)",
|
||||
"fieldname": "bom_no",
|
||||
"fieldtype": "Link",
|
||||
"label": "BOM No",
|
||||
"options": "BOM",
|
||||
"permlevel": 0,
|
||||
"read_only": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"depends_on": "eval:!inList([\"Sales Return\", \"Purchase Return\"], doc.purpose)",
|
||||
@ -596,7 +596,7 @@
|
||||
"is_submittable": 1,
|
||||
"issingle": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2015-02-05 05:11:46.986620",
|
||||
"modified": "2015-02-17 00:49:04.294855",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Stock Entry",
|
||||
|
@ -82,7 +82,7 @@ class StockEntry(StockController):
|
||||
self.meta.get_label("posting_date"))
|
||||
|
||||
def validate_purpose(self):
|
||||
valid_purposes = ["Material Issue", "Material Receipt", "Material Transfer",
|
||||
valid_purposes = ["Material Issue", "Material Receipt", "Material Transfer", "Material Transfer for Manufacture",
|
||||
"Manufacture", "Repack", "Subcontract", "Sales Return", "Purchase Return"]
|
||||
if self.purpose not in valid_purposes:
|
||||
frappe.throw(_("Purpose must be one of {0}").format(comma_or(valid_purposes)))
|
||||
@ -112,7 +112,7 @@ class StockEntry(StockController):
|
||||
if not item.transfer_qty:
|
||||
item.transfer_qty = item.qty * item.conversion_factor
|
||||
|
||||
if (self.purpose in ("Material Transfer", "Sales Return", "Purchase Return")
|
||||
if (self.purpose in ("Material Transfer", "Sales Return", "Purchase Return", "Material Transfer for Manufacture")
|
||||
and not item.serial_no
|
||||
and item.item_code in serialized_items):
|
||||
frappe.throw(_("Row #{0}: Please specify Serial No for Item {1}").format(item.idx, item.item_code),
|
||||
@ -121,8 +121,8 @@ class StockEntry(StockController):
|
||||
def validate_warehouse(self, pro_obj):
|
||||
"""perform various (sometimes conditional) validations on 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"]
|
||||
|
||||
validate_for_manufacture_repack = any([d.bom_no for d in self.get("items")])
|
||||
|
||||
@ -169,13 +169,14 @@ class StockEntry(StockController):
|
||||
frappe.throw(_("Source and target warehouse cannot be same for row {0}").format(d.idx))
|
||||
|
||||
def validate_production_order(self):
|
||||
if self.purpose == "Manufacture":
|
||||
if self.purpose in ("Manufacture", "Material Transfer for Manufacture"):
|
||||
# check if production order is entered
|
||||
if not self.production_order:
|
||||
frappe.throw(_("Production order number is mandatory for stock entry purpose manufacture"))
|
||||
# check for double entry
|
||||
self.check_if_operations_completed()
|
||||
self.check_duplicate_entry_for_production_order()
|
||||
if self.purpose=="Manufacture":
|
||||
self.check_if_operations_completed()
|
||||
self.check_duplicate_entry_for_production_order()
|
||||
elif self.purpose != "Material Transfer":
|
||||
self.production_order = None
|
||||
|
||||
@ -503,8 +504,8 @@ class StockEntry(StockController):
|
||||
|
||||
if self.bom_no:
|
||||
if self.purpose in ["Material Issue", "Material Transfer", "Manufacture", "Repack",
|
||||
"Subcontract"]:
|
||||
if self.production_order and self.purpose == "Material Transfer":
|
||||
"Subcontract", "Material Transfer for Manufacture"]:
|
||||
if self.production_order and self.purpose == "Material Transfer for Manufacture":
|
||||
item_dict = self.get_pending_raw_materials(pro_obj)
|
||||
if self.to_warehouse and pro_obj:
|
||||
for item in item_dict.values():
|
||||
@ -601,7 +602,7 @@ class StockEntry(StockController):
|
||||
result = frappe.db.sql("""select t1.item_code, sum(t1.qty)
|
||||
from `tabStock Entry Detail` t1, `tabStock Entry` t2
|
||||
where t1.parent = t2.name and t2.production_order = %s and t2.docstatus = 1
|
||||
and t2.purpose = 'Material Transfer'
|
||||
and t2.purpose = 'Material Transfer for Manufacture'
|
||||
group by t1.item_code""", self.production_order)
|
||||
for t in result:
|
||||
issued_item_qty[t[0]] = flt(t[1])
|
||||
|
@ -18,15 +18,18 @@
|
||||
<p>{%= doc.description %}</p>{% } %}
|
||||
{% include "templates/form_grid/includes/visible_cols.html" %}
|
||||
<div>
|
||||
{% if(doc.s_warehouse) { %}<span class="label
|
||||
{%= (doc.actual_qty >= doc.qty) ? "label-success"
|
||||
: "label-danger" %}"
|
||||
title="{%= (doc.actual_qty >= doc.qty) ? __("In Stock")
|
||||
: __("Not In Stock") %}">
|
||||
{%= doc.s_warehouse || "" %}</span>{% } %}
|
||||
<i class="icon-long-arrow-right"></i>
|
||||
{% if(doc.s_warehouse) { %}
|
||||
<span class="label label-primary">
|
||||
{%= doc.s_warehouse || "" %}</span>
|
||||
{% } %}
|
||||
<i class="octicon octicon-arrow-small-right"></i>
|
||||
{% if(doc.t_warehouse) { %}<span class="label label-primary">
|
||||
{%= doc.t_warehouse || "" %}</span>{% } %}
|
||||
{% if(doc.s_warehouse && doc.actual_qty < doc.qty) { %}
|
||||
<span class="text-danger small" style="margin-left: 15px;">
|
||||
<span class="octicon octicon-stop" style="font-size: 12px;"></span> Not in Stock
|
||||
</span>
|
||||
{% } %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user