mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 08:24:47 +00:00
[fix] production order transfer raw material to fetch all necessary data
This commit is contained in:
@@ -144,11 +144,18 @@ erpnext.stock.StockEntry = erpnext.stock.StockController.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
production_order: function() {
|
production_order: function() {
|
||||||
|
var me = this;
|
||||||
this.toggle_enable_bom();
|
this.toggle_enable_bom();
|
||||||
|
|
||||||
return this.frm.call({
|
return this.frm.call({
|
||||||
method: "get_production_order_details",
|
method: "get_production_order_details",
|
||||||
args: {production_order: this.frm.doc.production_order}
|
args: {production_order: this.frm.doc.production_order},
|
||||||
|
callback: function(r) {
|
||||||
|
if (!r.exc) {
|
||||||
|
if (me.frm.doc.purpose == "Material Transfer" && !me.frm.doc.to_warehouse)
|
||||||
|
me.frm.set_value("to_warehouse", r.message["wip_warehouse"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -472,11 +472,12 @@ class DocType(StockController):
|
|||||||
if self.doc.purpose=="Material Receipt":
|
if self.doc.purpose=="Material Receipt":
|
||||||
self.doc.from_warehouse = ""
|
self.doc.from_warehouse = ""
|
||||||
|
|
||||||
item = webnotes.conn.sql("""select item, description, uom from `tabBOM`
|
item = webnotes.conn.sql("""select name, item_name, description, uom
|
||||||
where name=%s""", (self.doc.bom_no,), as_dict=1)
|
from `tabItem` where name=%s""", (self.doc.bom_no), as_dict=1)
|
||||||
self.add_to_stock_entry_detail({
|
self.add_to_stock_entry_detail({
|
||||||
item[0]["item"] : {
|
item[0]["item"] : {
|
||||||
"qty": self.doc.fg_completed_qty,
|
"qty": self.doc.fg_completed_qty,
|
||||||
|
"item_name": item[0].item_name,
|
||||||
"description": item[0]["description"],
|
"description": item[0]["description"],
|
||||||
"stock_uom": item[0]["uom"],
|
"stock_uom": item[0]["uom"],
|
||||||
"from_warehouse": ""
|
"from_warehouse": ""
|
||||||
@@ -485,7 +486,6 @@ class DocType(StockController):
|
|||||||
|
|
||||||
self.get_stock_and_rate()
|
self.get_stock_and_rate()
|
||||||
|
|
||||||
|
|
||||||
def get_bom_raw_materials(self, qty):
|
def get_bom_raw_materials(self, qty):
|
||||||
"""
|
"""
|
||||||
get all items from flat bom except
|
get all items from flat bom except
|
||||||
@@ -503,9 +503,12 @@ class DocType(StockController):
|
|||||||
else:
|
else:
|
||||||
item_dict[item.item_code] = {
|
item_dict[item.item_code] = {
|
||||||
"qty": flt(item.qty),
|
"qty": flt(item.qty),
|
||||||
|
"item_name": item.item_name,
|
||||||
"description": item.description,
|
"description": item.description,
|
||||||
"stock_uom": item.stock_uom,
|
"stock_uom": item.stock_uom,
|
||||||
"from_warehouse": item.default_warehouse
|
"from_warehouse": item.default_warehouse,
|
||||||
|
"expense_account": item.purchase_account,
|
||||||
|
"cost_center": item.cost_center
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.doc.use_multi_level_bom:
|
if self.doc.use_multi_level_bom:
|
||||||
@@ -515,7 +518,10 @@ class DocType(StockController):
|
|||||||
ifnull(sum(fb.qty_consumed_per_unit),0)*%s as qty,
|
ifnull(sum(fb.qty_consumed_per_unit),0)*%s as qty,
|
||||||
fb.description,
|
fb.description,
|
||||||
fb.stock_uom,
|
fb.stock_uom,
|
||||||
it.default_warehouse
|
it.item_name,
|
||||||
|
it.default_warehouse,
|
||||||
|
it.purchase_account,
|
||||||
|
it.cost_center
|
||||||
from
|
from
|
||||||
`tabBOM Explosion Item` fb,`tabItem` it
|
`tabBOM Explosion Item` fb,`tabItem` it
|
||||||
where
|
where
|
||||||
@@ -532,10 +538,13 @@ class DocType(StockController):
|
|||||||
# get only BOM items
|
# get only BOM items
|
||||||
fl_bom_sa_items = sql("""select
|
fl_bom_sa_items = sql("""select
|
||||||
`tabItem`.item_code,
|
`tabItem`.item_code,
|
||||||
|
`tabItem`.item_name,
|
||||||
ifnull(sum(`tabBOM Item`.qty_consumed_per_unit), 0) *%s as qty,
|
ifnull(sum(`tabBOM Item`.qty_consumed_per_unit), 0) *%s as qty,
|
||||||
`tabItem`.description,
|
`tabItem`.description,
|
||||||
`tabItem`.stock_uom,
|
`tabItem`.stock_uom,
|
||||||
`tabItem`.default_warehouse
|
`tabItem`.default_warehouse,
|
||||||
|
`tabItem`.purchase_account,
|
||||||
|
`tabItem`.cost_center
|
||||||
from
|
from
|
||||||
`tabBOM Item`, `tabItem`
|
`tabBOM Item`, `tabItem`
|
||||||
where
|
where
|
||||||
@@ -599,16 +608,21 @@ class DocType(StockController):
|
|||||||
return issued_item_qty
|
return issued_item_qty
|
||||||
|
|
||||||
def add_to_stock_entry_detail(self, item_dict, bom_no=None):
|
def add_to_stock_entry_detail(self, item_dict, bom_no=None):
|
||||||
|
idx = 1
|
||||||
for d in item_dict:
|
for d in item_dict:
|
||||||
se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail',
|
se_child = addchild(self.doc, 'mtn_details', 'Stock Entry Detail',
|
||||||
self.doclist)
|
self.doclist)
|
||||||
|
se_child.idx = idx
|
||||||
se_child.s_warehouse = item_dict[d].get("from_warehouse", self.doc.from_warehouse)
|
se_child.s_warehouse = item_dict[d].get("from_warehouse", self.doc.from_warehouse)
|
||||||
se_child.t_warehouse = item_dict[d].get("to_warehouse", self.doc.to_warehouse)
|
se_child.t_warehouse = item_dict[d].get("to_warehouse", self.doc.to_warehouse)
|
||||||
se_child.item_code = cstr(d)
|
se_child.item_code = cstr(d)
|
||||||
|
se_child.item_name = item_dict[d]["item_name"]
|
||||||
se_child.description = item_dict[d]["description"]
|
se_child.description = item_dict[d]["description"]
|
||||||
se_child.uom = item_dict[d]["stock_uom"]
|
se_child.uom = item_dict[d]["stock_uom"]
|
||||||
se_child.stock_uom = item_dict[d]["stock_uom"]
|
se_child.stock_uom = item_dict[d]["stock_uom"]
|
||||||
se_child.qty = flt(item_dict[d]["qty"])
|
se_child.qty = flt(item_dict[d]["qty"])
|
||||||
|
se_child.expense_account = item_dict[d]["expense_account"]
|
||||||
|
se_child.cost_center = item_dict[d]["cost_center"]
|
||||||
|
|
||||||
# in stock uom
|
# in stock uom
|
||||||
se_child.transfer_qty = flt(item_dict[d]["qty"])
|
se_child.transfer_qty = flt(item_dict[d]["qty"])
|
||||||
@@ -617,6 +631,9 @@ class DocType(StockController):
|
|||||||
# to be assigned for finished item
|
# to be assigned for finished item
|
||||||
se_child.bom_no = bom_no
|
se_child.bom_no = bom_no
|
||||||
|
|
||||||
|
# increment idx by 1
|
||||||
|
idx += 1
|
||||||
|
|
||||||
def get_cust_values(self):
|
def get_cust_values(self):
|
||||||
"""fetches customer details"""
|
"""fetches customer details"""
|
||||||
if self.doc.delivery_note_no:
|
if self.doc.delivery_note_no:
|
||||||
@@ -682,8 +699,8 @@ class DocType(StockController):
|
|||||||
@webnotes.whitelist()
|
@webnotes.whitelist()
|
||||||
def get_production_order_details(production_order):
|
def get_production_order_details(production_order):
|
||||||
result = webnotes.conn.sql("""select bom_no,
|
result = webnotes.conn.sql("""select bom_no,
|
||||||
ifnull(qty, 0) - ifnull(produced_qty, 0) as fg_completed_qty, use_multi_level_bom
|
ifnull(qty, 0) - ifnull(produced_qty, 0) as fg_completed_qty, use_multi_level_bom,
|
||||||
from `tabProduction Order` where name = %s""", production_order, as_dict=1)
|
wip_warehouse from `tabProduction Order` where name = %s""", production_order, as_dict=1)
|
||||||
return result and result[0] or {}
|
return result and result[0] or {}
|
||||||
|
|
||||||
def query_sales_return_doc(doctype, txt, searchfield, start, page_len, filters):
|
def query_sales_return_doc(doctype, txt, searchfield, start, page_len, filters):
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"creation": "2013-03-29 18:22:12",
|
"creation": "2013-03-29 18:22:12",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-10-15 14:58:09",
|
"modified": "2013-10-23 13:46:52",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@@ -65,6 +65,12 @@
|
|||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"search_index": 1
|
"search_index": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "item_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Item Name"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "description",
|
"fieldname": "description",
|
||||||
|
|||||||
Reference in New Issue
Block a user