mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-13 02:01:21 +00:00
Merge pull request #2613 from neilLasrado/bom-item-name
item name added to BOM
This commit is contained in:
@@ -61,6 +61,7 @@ cur_frm.cscript.operations_remove = function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.add_fetch("item", "description", "description");
|
cur_frm.add_fetch("item", "description", "description");
|
||||||
|
cur_frm.add_fetch("item", "item_name", "item_name");
|
||||||
cur_frm.add_fetch("item", "stock_uom", "uom");
|
cur_frm.add_fetch("item", "stock_uom", "uom");
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,33 @@
|
|||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"search_index": 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,
|
"allow_on_submit": 1,
|
||||||
"default": "1",
|
"default": "1",
|
||||||
@@ -47,11 +74,6 @@
|
|||||||
"oldfieldtype": "Check",
|
"oldfieldtype": "Check",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "cb0",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"description": "Manage cost of operations",
|
"description": "Manage cost of operations",
|
||||||
"fieldname": "with_operations",
|
"fieldname": "with_operations",
|
||||||
@@ -59,21 +81,6 @@
|
|||||||
"label": "With Operations",
|
"label": "With Operations",
|
||||||
"permlevel": 0
|
"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",
|
"depends_on": "with_operations",
|
||||||
"description": "Specify the operations, operating cost and give a unique Operation no to your operations.",
|
"description": "Specify the operations, operating cost and give a unique Operation no to your operations.",
|
||||||
@@ -245,7 +252,7 @@
|
|||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
"modified": "2015-01-07 11:11:07.047695",
|
"modified": "2015-01-20 11:54:43.042697",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "BOM",
|
"name": "BOM",
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class BOM(Document):
|
|||||||
self.manage_default_bom()
|
self.manage_default_bom()
|
||||||
|
|
||||||
def get_item_det(self, item_code):
|
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,
|
docstatus, description, is_sub_contracted_item, stock_uom, default_bom,
|
||||||
last_purchase_rate
|
last_purchase_rate
|
||||||
from `tabItem` where name=%s""", item_code, as_dict = 1)
|
from `tabItem` where name=%s""", item_code, as_dict = 1)
|
||||||
@@ -69,7 +69,7 @@ class BOM(Document):
|
|||||||
|
|
||||||
def set_bom_material_details(self):
|
def set_bom_material_details(self):
|
||||||
for item in self.get("items"):
|
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})
|
"qty": item.qty})
|
||||||
|
|
||||||
for r in ret:
|
for r in ret:
|
||||||
@@ -93,6 +93,7 @@ class BOM(Document):
|
|||||||
|
|
||||||
rate = self.get_rm_rate(args)
|
rate = self.get_rm_rate(args)
|
||||||
ret_item = {
|
ret_item = {
|
||||||
|
'item_name' : item and args['item_name'] or '',
|
||||||
'description' : item and args['description'] or '',
|
'description' : item and args['description'] or '',
|
||||||
'stock_uom' : item and args['stock_uom'] or '',
|
'stock_uom' : item and args['stock_uom'] or '',
|
||||||
'bom_no' : args['bom_no'],
|
'bom_no' : args['bom_no'],
|
||||||
@@ -203,9 +204,10 @@ class BOM(Document):
|
|||||||
if not item:
|
if not item:
|
||||||
frappe.throw(_("Item {0} does not exist in the system or has expired").format(self.item))
|
frappe.throw(_("Item {0} does not exist in the system or has expired").format(self.item))
|
||||||
else:
|
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.description = ret[0]
|
||||||
self.uom = ret[1]
|
self.uom = ret[1]
|
||||||
|
self.item_name= ret[2]
|
||||||
|
|
||||||
def validate_materials(self):
|
def validate_materials(self):
|
||||||
""" Validate raw material entries """
|
""" Validate raw material entries """
|
||||||
@@ -313,6 +315,7 @@ class BOM(Document):
|
|||||||
else:
|
else:
|
||||||
self.add_to_cur_exploded_items(frappe._dict({
|
self.add_to_cur_exploded_items(frappe._dict({
|
||||||
'item_code' : d.item_code,
|
'item_code' : d.item_code,
|
||||||
|
'item_name' : d.item_name,
|
||||||
'description' : d.description,
|
'description' : d.description,
|
||||||
'stock_uom' : d.stock_uom,
|
'stock_uom' : d.stock_uom,
|
||||||
'qty' : flt(d.qty),
|
'qty' : flt(d.qty),
|
||||||
@@ -328,7 +331,7 @@ class BOM(Document):
|
|||||||
def get_child_exploded_items(self, bom_no, qty):
|
def get_child_exploded_items(self, bom_no, qty):
|
||||||
""" Add all items from Flat BOM of child BOM"""
|
""" 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
|
# 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,
|
bom_item.stock_uom, bom_item.qty, bom_item.rate,
|
||||||
ifnull(bom_item.qty, 0 ) / ifnull(bom.quantity, 1) as qty_consumed_per_unit
|
ifnull(bom_item.qty, 0 ) / ifnull(bom.quantity, 1) as qty_consumed_per_unit
|
||||||
from `tabBOM Explosion Item` bom_item, tabBOM bom
|
from `tabBOM Explosion Item` bom_item, tabBOM bom
|
||||||
@@ -337,6 +340,7 @@ class BOM(Document):
|
|||||||
for d in child_fb_items:
|
for d in child_fb_items:
|
||||||
self.add_to_cur_exploded_items(frappe._dict({
|
self.add_to_cur_exploded_items(frappe._dict({
|
||||||
'item_code' : d['item_code'],
|
'item_code' : d['item_code'],
|
||||||
|
'item_name' : d['item_name'],
|
||||||
'description' : d['description'],
|
'description' : d['description'],
|
||||||
'stock_uom' : d['stock_uom'],
|
'stock_uom' : d['stock_uom'],
|
||||||
'qty' : d['qty_consumed_per_unit']*qty,
|
'qty' : d['qty_consumed_per_unit']*qty,
|
||||||
|
|||||||
@@ -16,6 +16,21 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1
|
"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",
|
"fieldname": "description",
|
||||||
"fieldtype": "Text",
|
"fieldtype": "Text",
|
||||||
@@ -28,6 +43,12 @@
|
|||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
"width": "300px"
|
"width": "300px"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "section_break_4",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "qty",
|
"fieldname": "qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
@@ -50,16 +71,21 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "amount",
|
"fieldname": "qty_consumed_per_unit",
|
||||||
"fieldtype": "Currency",
|
"fieldtype": "Float",
|
||||||
|
"hidden": 0,
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Amount",
|
"label": "Qty Consumed Per Unit",
|
||||||
"oldfieldname": "amount_as_per_sr",
|
"no_copy": 0,
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"options": "Company:company:default_currency",
|
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "column_break_8",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "stock_uom",
|
"fieldname": "stock_uom",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
@@ -72,19 +98,20 @@
|
|||||||
"read_only": 1
|
"read_only": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "qty_consumed_per_unit",
|
"fieldname": "amount",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Currency",
|
||||||
"hidden": 0,
|
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Qty Consumed Per Unit",
|
"label": "Amount",
|
||||||
"no_copy": 0,
|
"oldfieldname": "amount_as_per_sr",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"options": "Company:company:default_currency",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"read_only": 1
|
"read_only": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2014-12-12 11:18:01.745641",
|
"modified": "2015-01-20 13:28:52.258152",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "BOM Explosion Item",
|
"name": "BOM Explosion Item",
|
||||||
|
|||||||
@@ -26,11 +26,19 @@
|
|||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"search_index": 1
|
"search_index": 1
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "item_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"label": "Item Name",
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": ""
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "bom_no",
|
"fieldname": "bom_no",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"in_filter": 1,
|
"in_filter": 1,
|
||||||
"in_list_view": 1,
|
"in_list_view": 0,
|
||||||
"label": "BOM No",
|
"label": "BOM No",
|
||||||
"oldfieldname": "bom_no",
|
"oldfieldname": "bom_no",
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
@@ -55,7 +63,7 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_width": "250px",
|
"print_width": "250px",
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"width": "250px"
|
"width": "25px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "quantity_and_rate",
|
"fieldname": "quantity_and_rate",
|
||||||
@@ -136,7 +144,7 @@
|
|||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2014-12-12 11:15:43.798755",
|
"modified": "2015-01-20 13:28:35.152945",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
"name": "BOM Item",
|
"name": "BOM Item",
|
||||||
|
|||||||
@@ -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.remove_shopping_cart_app
|
||||||
erpnext.patches.v5_0.update_companywise_payment_account
|
erpnext.patches.v5_0.update_companywise_payment_account
|
||||||
erpnext.patches.v5_0.remove_birthday_events
|
erpnext.patches.v5_0.remove_birthday_events
|
||||||
|
erpnext.patches.v5_0.update_item_name_in_bom
|
||||||
|
|||||||
12
erpnext/patches/v5_0/update_item_name_in_bom.py
Normal file
12
erpnext/patches/v5_0/update_item_name_in_bom.py
Normal 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` as bom set bom.item_name = \
|
||||||
|
( select item.item_name from `tabItem` as item where item.name = bom.item)""")
|
||||||
|
frappe.db.sql("""update `tabBOM Item` as bomItem set bomItem.item_name = ( select item.item_name \
|
||||||
|
from `tabItem` as item where item.name = bomItem.item_code)""")
|
||||||
|
frappe.db.sql("""update `tabBOM Explosion Item` as explosionItem set explosionItem.item_name = \
|
||||||
|
( select item.item_name from `tabItem` as item where item.name = explosionItem.item_code)""")
|
||||||
Reference in New Issue
Block a user