item name added to BOM

This commit is contained in:
Neil Trini Lasrado 2015-01-20 17:39:46 +05:30
parent d2b762d760
commit 41acbff959
7 changed files with 215 additions and 155 deletions

View File

@ -61,6 +61,7 @@ cur_frm.cscript.operations_remove = function(){
}
cur_frm.add_fetch("item", "description", "description");
cur_frm.add_fetch("item", "item_name", "item_name");
cur_frm.add_fetch("item", "stock_uom", "uom");

View File

@ -21,6 +21,33 @@
"reqd": 1,
"search_index": 1
},
{
"fieldname": "item_name",
"fieldtype": "Data",
"label": "Item Name",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "rm_cost_as_per",
"fieldtype": "Select",
"label": "Rate Of Materials Based On",
"options": "Valuation Rate\nLast Purchase Rate\nPrice List",
"permlevel": 0
},
{
"depends_on": "eval:doc.rm_cost_as_per===\"Price List\"",
"fieldname": "buying_price_list",
"fieldtype": "Link",
"label": "Price List",
"options": "Price List",
"permlevel": 0
},
{
"fieldname": "cb0",
"fieldtype": "Column Break",
"permlevel": 0
},
{
"allow_on_submit": 1,
"default": "1",
@ -47,11 +74,6 @@
"oldfieldtype": "Check",
"permlevel": 0
},
{
"fieldname": "cb0",
"fieldtype": "Column Break",
"permlevel": 0
},
{
"description": "Manage cost of operations",
"fieldname": "with_operations",
@ -59,21 +81,6 @@
"label": "With Operations",
"permlevel": 0
},
{
"fieldname": "rm_cost_as_per",
"fieldtype": "Select",
"label": "Rate Of Materials Based On",
"options": "Valuation Rate\nLast Purchase Rate\nPrice List",
"permlevel": 0
},
{
"depends_on": "eval:doc.rm_cost_as_per===\"Price List\"",
"fieldname": "buying_price_list",
"fieldtype": "Link",
"label": "Price List",
"options": "Price List",
"permlevel": 0
},
{
"depends_on": "with_operations",
"description": "Specify the operations, operating cost and give a unique Operation no to your operations.",
@ -245,7 +252,7 @@
"is_submittable": 1,
"issingle": 0,
"istable": 0,
"modified": "2015-01-07 11:11:07.047695",
"modified": "2015-01-20 11:54:43.042697",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "BOM",

View File

@ -53,7 +53,7 @@ class BOM(Document):
self.manage_default_bom()
def get_item_det(self, item_code):
item = frappe.db.sql("""select name, is_asset_item, is_purchase_item,
item = frappe.db.sql("""select name, item_name, is_asset_item, is_purchase_item,
docstatus, description, is_sub_contracted_item, stock_uom, default_bom,
last_purchase_rate
from `tabItem` where name=%s""", item_code, as_dict = 1)
@ -69,7 +69,7 @@ class BOM(Document):
def set_bom_material_details(self):
for item in self.get("items"):
ret = self.get_bom_material_detail({"item_code": item.item_code, "bom_no": item.bom_no,
ret = self.get_bom_material_detail({"item_code": item.item_code, "item_name": item.item_name, "bom_no": item.bom_no,
"qty": item.qty})
for r in ret:
@ -93,6 +93,7 @@ class BOM(Document):
rate = self.get_rm_rate(args)
ret_item = {
'item_name' : item and args['item_name'] or '',
'description' : item and args['description'] or '',
'stock_uom' : item and args['stock_uom'] or '',
'bom_no' : args['bom_no'],
@ -203,9 +204,10 @@ class BOM(Document):
if not item:
frappe.throw(_("Item {0} does not exist in the system or has expired").format(self.item))
else:
ret = frappe.db.get_value("Item", self.item, ["description", "stock_uom"])
ret = frappe.db.get_value("Item", self.item, ["description", "stock_uom", "item_name"])
self.description = ret[0]
self.uom = ret[1]
self.item_name= ret[2]
def validate_materials(self):
""" Validate raw material entries """
@ -313,6 +315,7 @@ class BOM(Document):
else:
self.add_to_cur_exploded_items(frappe._dict({
'item_code' : d.item_code,
'item_name' : d.item_name,
'description' : d.description,
'stock_uom' : d.stock_uom,
'qty' : flt(d.qty),
@ -328,7 +331,7 @@ class BOM(Document):
def get_child_exploded_items(self, bom_no, qty):
""" Add all items from Flat BOM of child BOM"""
# Did not use qty_consumed_per_unit in the query, as it leads to rounding loss
child_fb_items = frappe.db.sql("""select bom_item.item_code, bom_item.description,
child_fb_items = frappe.db.sql("""select bom_item.item_code, bom_item.item_name, bom_item.description,
bom_item.stock_uom, bom_item.qty, bom_item.rate,
ifnull(bom_item.qty, 0 ) / ifnull(bom.quantity, 1) as qty_consumed_per_unit
from `tabBOM Explosion Item` bom_item, tabBOM bom
@ -337,6 +340,7 @@ class BOM(Document):
for d in child_fb_items:
self.add_to_cur_exploded_items(frappe._dict({
'item_code' : d['item_code'],
'item_name' : d['item_name'],
'description' : d['description'],
'stock_uom' : d['stock_uom'],
'qty' : d['qty_consumed_per_unit']*qty,

View File

@ -16,6 +16,21 @@
"permlevel": 0,
"read_only": 1
},
{
"fieldname": "item_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Item Name",
"permlevel": 0,
"precision": "",
"read_only": 1
},
{
"fieldname": "column_break_2",
"fieldtype": "Column Break",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "description",
"fieldtype": "Text",
@ -28,6 +43,12 @@
"read_only": 1,
"width": "300px"
},
{
"fieldname": "section_break_4",
"fieldtype": "Section Break",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "qty",
"fieldtype": "Float",
@ -50,16 +71,21 @@
"read_only": 1
},
{
"fieldname": "amount",
"fieldtype": "Currency",
"fieldname": "qty_consumed_per_unit",
"fieldtype": "Float",
"hidden": 0,
"in_list_view": 1,
"label": "Amount",
"oldfieldname": "amount_as_per_sr",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"label": "Qty Consumed Per Unit",
"no_copy": 0,
"permlevel": 0,
"read_only": 1
},
{
"fieldname": "column_break_8",
"fieldtype": "Column Break",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "stock_uom",
"fieldtype": "Link",
@ -72,19 +98,20 @@
"read_only": 1
},
{
"fieldname": "qty_consumed_per_unit",
"fieldtype": "Float",
"hidden": 0,
"fieldname": "amount",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Qty Consumed Per Unit",
"no_copy": 0,
"label": "Amount",
"oldfieldname": "amount_as_per_sr",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"permlevel": 0,
"read_only": 1
}
],
"idx": 1,
"istable": 1,
"modified": "2014-12-12 11:18:01.745641",
"modified": "2015-01-20 13:28:52.258152",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "BOM Explosion Item",

View File

@ -1,147 +1,155 @@
{
"creation": "2013-02-22 01:27:49",
"docstatus": 0,
"doctype": "DocType",
"creation": "2013-02-22 01:27:49",
"docstatus": 0,
"doctype": "DocType",
"fields": [
{
"fieldname": "operation",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Operation",
"oldfieldname": "operation_no",
"oldfieldtype": "Data",
"permlevel": 0,
"fieldname": "operation",
"fieldtype": "Select",
"in_list_view": 1,
"label": "Operation",
"oldfieldname": "operation_no",
"oldfieldtype": "Data",
"permlevel": 0,
"reqd": 0
},
},
{
"fieldname": "item_code",
"fieldtype": "Link",
"in_filter": 1,
"in_list_view": 1,
"label": "Item Code",
"oldfieldname": "item_code",
"oldfieldtype": "Link",
"options": "Item",
"permlevel": 0,
"reqd": 1,
"fieldname": "item_code",
"fieldtype": "Link",
"in_filter": 1,
"in_list_view": 1,
"label": "Item Code",
"oldfieldname": "item_code",
"oldfieldtype": "Link",
"options": "Item",
"permlevel": 0,
"reqd": 1,
"search_index": 1
},
},
{
"fieldname": "bom_no",
"fieldtype": "Link",
"in_filter": 1,
"in_list_view": 1,
"label": "BOM No",
"oldfieldname": "bom_no",
"oldfieldtype": "Link",
"options": "BOM",
"permlevel": 0,
"print_width": "150px",
"reqd": 0,
"search_index": 1,
"fieldname": "item_name",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Item Name",
"permlevel": 0,
"precision": ""
},
{
"fieldname": "bom_no",
"fieldtype": "Link",
"in_filter": 1,
"in_list_view": 0,
"label": "BOM No",
"oldfieldname": "bom_no",
"oldfieldtype": "Link",
"options": "BOM",
"permlevel": 0,
"print_width": "150px",
"reqd": 0,
"search_index": 1,
"width": "150px"
},
},
{
"fieldname": "col_break1",
"fieldtype": "Column Break",
"fieldname": "col_break1",
"fieldtype": "Column Break",
"permlevel": 0
},
},
{
"fieldname": "description",
"fieldtype": "Text",
"label": "Item Description",
"oldfieldname": "description",
"oldfieldtype": "Text",
"permlevel": 0,
"print_width": "250px",
"reqd": 0,
"width": "250px"
},
"fieldname": "description",
"fieldtype": "Text",
"label": "Item Description",
"oldfieldname": "description",
"oldfieldtype": "Text",
"permlevel": 0,
"print_width": "250px",
"reqd": 0,
"width": "25px"
},
{
"fieldname": "quantity_and_rate",
"fieldtype": "Section Break",
"label": "Quantity and Rate",
"fieldname": "quantity_and_rate",
"fieldtype": "Section Break",
"label": "Quantity and Rate",
"permlevel": 0
},
},
{
"fieldname": "qty",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Qty",
"oldfieldname": "qty",
"oldfieldtype": "Currency",
"permlevel": 0,
"fieldname": "qty",
"fieldtype": "Float",
"in_list_view": 1,
"label": "Qty",
"oldfieldname": "qty",
"oldfieldtype": "Currency",
"permlevel": 0,
"reqd": 1
},
},
{
"description": "See \"Rate Of Materials Based On\" in Costing Section",
"fieldname": "rate",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Rate",
"options": "Company:company:default_currency",
"permlevel": 0,
"description": "See \"Rate Of Materials Based On\" in Costing Section",
"fieldname": "rate",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Rate",
"options": "Company:company:default_currency",
"permlevel": 0,
"reqd": 1
},
},
{
"fieldname": "col_break2",
"fieldtype": "Column Break",
"fieldname": "col_break2",
"fieldtype": "Column Break",
"permlevel": 0
},
},
{
"fieldname": "stock_uom",
"fieldtype": "Link",
"in_list_view": 0,
"label": "Stock UOM",
"oldfieldname": "stock_uom",
"oldfieldtype": "Data",
"options": "UOM",
"permlevel": 0,
"read_only": 1,
"fieldname": "stock_uom",
"fieldtype": "Link",
"in_list_view": 0,
"label": "Stock UOM",
"oldfieldname": "stock_uom",
"oldfieldtype": "Data",
"options": "UOM",
"permlevel": 0,
"read_only": 1,
"reqd": 1
},
},
{
"fieldname": "amount",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Amount",
"oldfieldname": "amount_as_per_mar",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"permlevel": 0,
"print_width": "150px",
"read_only": 1,
"fieldname": "amount",
"fieldtype": "Currency",
"in_list_view": 1,
"label": "Amount",
"oldfieldname": "amount_as_per_mar",
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"permlevel": 0,
"print_width": "150px",
"read_only": 1,
"width": "150px"
},
},
{
"fieldname": "scrap",
"fieldtype": "Float",
"label": "Scrap %",
"oldfieldname": "scrap",
"oldfieldtype": "Currency",
"permlevel": 0,
"fieldname": "scrap",
"fieldtype": "Float",
"label": "Scrap %",
"oldfieldname": "scrap",
"oldfieldtype": "Currency",
"permlevel": 0,
"print_hide": 1
},
},
{
"fieldname": "qty_consumed_per_unit",
"fieldtype": "Float",
"hidden": 1,
"label": "Qty Consumed Per Unit",
"oldfieldname": "qty_consumed_per_unit",
"oldfieldtype": "Float",
"permlevel": 0,
"print_hide": 1,
"fieldname": "qty_consumed_per_unit",
"fieldtype": "Float",
"hidden": 1,
"label": "Qty Consumed Per Unit",
"oldfieldname": "qty_consumed_per_unit",
"oldfieldtype": "Float",
"permlevel": 0,
"print_hide": 1,
"read_only": 1
}
],
"idx": 1,
"istable": 1,
"modified": "2014-12-12 11:15:43.798755",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "BOM Item",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
],
"idx": 1,
"istable": 1,
"modified": "2015-01-20 13:28:35.152945",
"modified_by": "Administrator",
"module": "Manufacturing",
"name": "BOM Item",
"owner": "Administrator",
"permissions": [],
"sort_field": "modified",
"sort_order": "DESC"
}
}

View File

@ -105,3 +105,4 @@ erpnext.patches.v5_0.recalculate_total_amount_in_jv
erpnext.patches.v5_0.remove_shopping_cart_app
erpnext.patches.v5_0.update_companywise_payment_account
erpnext.patches.v5_0.remove_birthday_events
erpnext.patches.v5_0.update_item_name_in_bom

View File

@ -0,0 +1,12 @@
# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
import frappe
def execute():
frappe.db.sql("""update `tabBOM` set `tabBOM`.item_name = ( select `tabItem`.item_name \
from `tabItem` where `tabItem`.name = `tabBOM`.item)""")
frappe.db.sql("""update `tabBOM Item` set item_name = ( select item_name \
from tabItem where `tabItem`.name = `tabBOM Item`.item_code)""")
frappe.db.sql("""update `tabBOM Explosion Item` set `tabBOM Explosion Item`.item_name = \
( select `tabItem`.item_name from `tabItem` where `tabItem`.name = `tabBOM Explosion Item`.item_code)""")