Merge pull request #2653 from neilLasrado/bom-validations
Validations added to Bom Doctype.
diff --git a/erpnext/accounts/page/financial_analytics/financial_analytics.js b/erpnext/accounts/page/financial_analytics/financial_analytics.js
index 631af15..4e50711 100644
--- a/erpnext/accounts/page/financial_analytics/financial_analytics.js
+++ b/erpnext/accounts/page/financial_analytics/financial_analytics.js
@@ -49,7 +49,7 @@
],
setup_columns: function() {
var std_columns = [
- {id: "check", name: __("Plot"), field: "check", width: 30,
+ {id: "_check", name: __("Plot"), field: "_check", width: 30,
formatter: this.check_formatter},
{id: "name", name: __("Account"), field: "name", width: 300,
formatter: this.tree_formatter},
diff --git a/erpnext/buying/page/purchase_analytics/purchase_analytics.js b/erpnext/buying/page/purchase_analytics/purchase_analytics.js
index 5ac7593..33fb9b2 100644
--- a/erpnext/buying/page/purchase_analytics/purchase_analytics.js
+++ b/erpnext/buying/page/purchase_analytics/purchase_analytics.js
@@ -74,7 +74,7 @@
this.tree_grid = this.tree_grids[this.tree_type];
var std_columns = [
- {id: "check", name: __("Plot"), field: "check", width: 30,
+ {id: "_check", name: __("Plot"), field: "_check", width: 30,
formatter: this.check_formatter},
{id: "name", name: this.tree_grid.label, field: "name", width: 300,
formatter: this.tree_formatter},
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 82da90e..1b0cda0 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -15,9 +15,8 @@
class BuyingController(StockController):
def __setup__(self):
if hasattr(self, "items"):
- self.table_print_templates = {
- "items": "templates/print_formats/includes/item_grid.html",
- "taxes": "templates/print_formats/includes/taxes.html",
+ self.print_templates = {
+ "taxes": "templates/print_formats/includes/taxes.html"
}
def get_feed(self):
diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py
index 328894c..89cac69 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -13,9 +13,8 @@
class SellingController(StockController):
def __setup__(self):
if hasattr(self, "items"):
- self.table_print_templates = {
- "items": "templates/print_formats/includes/item_grid.html",
- "taxes": "templates/print_formats/includes/taxes.html",
+ self.print_templates = {
+ "taxes": "templates/print_formats/includes/taxes.html"
}
def get_feed(self):
diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js
index 4f78c41..7dedfac 100644
--- a/erpnext/manufacturing/doctype/bom/bom.js
+++ b/erpnext/manufacturing/doctype/bom/bom.js
@@ -61,6 +61,7 @@
}
cur_frm.add_fetch("item", "description", "description");
+cur_frm.add_fetch("item", "item_name", "item_name");
cur_frm.add_fetch("item", "stock_uom", "uom");
diff --git a/erpnext/manufacturing/doctype/bom/bom.json b/erpnext/manufacturing/doctype/bom/bom.json
index 7dac33c..9d76d2f 100644
--- a/erpnext/manufacturing/doctype/bom/bom.json
+++ b/erpnext/manufacturing/doctype/bom/bom.json
@@ -22,6 +22,33 @@
"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",
"fieldname": "is_active",
@@ -48,11 +75,6 @@
"permlevel": 0
},
{
- "fieldname": "cb0",
- "fieldtype": "Column Break",
- "permlevel": 0
- },
- {
"description": "Manage cost of operations",
"fieldname": "with_operations",
"fieldtype": "Check",
@@ -60,21 +82,6 @@
"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.",
"fieldname": "operations_section",
@@ -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",
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index 1ef1f7e..96f398f 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -54,7 +54,7 @@
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)
@@ -70,7 +70,7 @@
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:
@@ -94,6 +94,7 @@
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'],
@@ -204,9 +205,10 @@
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 """
@@ -316,6 +318,7 @@
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),
@@ -331,7 +334,7 @@
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
@@ -340,6 +343,7 @@
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,
diff --git a/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.json b/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.json
index 58b505d..71b6da5 100644
--- a/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.json
+++ b/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.json
@@ -17,6 +17,21 @@
"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",
"in_list_view": 1,
@@ -29,6 +44,12 @@
"width": "300px"
},
{
+ "fieldname": "section_break_4",
+ "fieldtype": "Section Break",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
"fieldname": "qty",
"fieldtype": "Float",
"in_list_view": 1,
@@ -50,17 +71,22 @@
"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",
"in_list_view": 0,
@@ -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",
diff --git a/erpnext/manufacturing/doctype/bom_item/bom_item.json b/erpnext/manufacturing/doctype/bom_item/bom_item.json
index 872f532..79287eb 100644
--- a/erpnext/manufacturing/doctype/bom_item/bom_item.json
+++ b/erpnext/manufacturing/doctype/bom_item/bom_item.json
@@ -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"
-}
+}
\ No newline at end of file
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index ccbf676..9a74469 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -105,3 +105,4 @@
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
diff --git a/erpnext/patches/v5_0/update_item_name_in_bom.py b/erpnext/patches/v5_0/update_item_name_in_bom.py
new file mode 100644
index 0000000..1e858c5
--- /dev/null
+++ b/erpnext/patches/v5_0/update_item_name_in_bom.py
@@ -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)""")
\ No newline at end of file
diff --git a/erpnext/public/js/stock_analytics.js b/erpnext/public/js/stock_analytics.js
index ef6633b..f8aeba9 100644
--- a/erpnext/public/js/stock_analytics.js
+++ b/erpnext/public/js/stock_analytics.js
@@ -36,7 +36,7 @@
},
setup_columns: function() {
var std_columns = [
- {id: "check", name: __("Plot"), field: "check", width: 30,
+ {id: "_check", name: __("Plot"), field: "_check", width: 30,
formatter: this.check_formatter},
{id: "name", name: __("Item"), field: "name", width: 300,
formatter: this.tree_formatter},
diff --git a/erpnext/support/page/support_analytics/support_analytics.js b/erpnext/support/page/support_analytics/support_analytics.js
index 8e0b10a..4ca15a2 100644
--- a/erpnext/support/page/support_analytics/support_analytics.js
+++ b/erpnext/support/page/support_analytics/support_analytics.js
@@ -37,7 +37,7 @@
setup_columns: function() {
var std_columns = [
- {id: "check", name: __("Plot"), field: "check", width: 30,
+ {id: "_check", name: __("Plot"), field: "_check", width: 30,
formatter: this.check_formatter},
{id: "status", name: __("Status"), field: "status", width: 100},
];