Merge pull request #2605 from neilLasrado/bom-costs
Bom operations and item link removed.
diff --git a/erpnext/manufacturing/doctype/bom/bom.js b/erpnext/manufacturing/doctype/bom/bom.js
index 7dedfac..a5d500f 100644
--- a/erpnext/manufacturing/doctype/bom/bom.js
+++ b/erpnext/manufacturing/doctype/bom/bom.js
@@ -13,9 +13,6 @@
cur_frm.add_custom_button(__("Update Item Description"), cur_frm.cscript.update_item_desc,
"icon-tag", "btn-default");
}
-
- cur_frm.cscript.with_operations(doc);
- erpnext.bom.set_operation(doc);
}
cur_frm.cscript.update_cost = function() {
@@ -37,29 +34,6 @@
}
})
}
-
-cur_frm.cscript.with_operations = function(doc) {
- cur_frm.fields_dict["items"].grid.set_column_disp("operation", doc.with_operations);
- cur_frm.fields_dict["items"].grid.toggle_reqd("operation", doc.with_operations);
-}
-
-erpnext.bom.set_operation = function(doc) {
- var op_table = doc["operations"] || [];
- var operations = [];
-
- for (var i=0, j=op_table.length; i<j; i++) {
- operations[i] = (i+1);
- }
-
- frappe.meta.get_docfield("BOM Item", "operation", cur_frm.docname).options = operations.join("\n");
-
- refresh_field("items");
-}
-
-cur_frm.cscript.operations_remove = function(){
- erpnext.bom.set_operation(doc);
-}
-
cur_frm.add_fetch("item", "description", "description");
cur_frm.add_fetch("item", "item_name", "item_name");
cur_frm.add_fetch("item", "stock_uom", "uom");
@@ -210,7 +184,6 @@
callback: function (data) {
frappe.model.set_value(d.doctype, d.name, "opn_description", data.message.opn_description);
frappe.model.set_value(d.doctype, d.name, "workstation", data.message.workstation);
- erpnext.bom.set_operation(frm.doc);
}
})
});
@@ -231,3 +204,13 @@
}
})
});
+
+frappe.ui.form.on("BOM Operation", "operations_remove", function(frm) {
+ erpnext.bom.calculate_op_cost(frm.doc);
+ erpnext.bom.calculate_total(frm.doc);
+});
+
+frappe.ui.form.on("BOM Item", "items_remove", function(frm) {
+ erpnext.bom.calculate_rm_cost(frm.doc);
+ erpnext.bom.calculate_total(frm.doc);
+});
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index 96f398f..f77628a 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -196,8 +196,6 @@
def clear_operations(self):
if not self.with_operations:
self.set('operations', [])
- for d in self.get("items"):
- d.operation = None
def validate_main_item(self):
""" Validate main FG item"""
@@ -216,21 +214,14 @@
frappe.throw(_("Raw Materials cannot be blank."))
check_list = []
for m in self.get('items'):
-
if m.bom_no:
validate_bom_no(m.item_code, m.bom_no)
-
if flt(m.qty) <= 0:
frappe.throw(_("Quantity required for Item {0} in row {1}").format(m.item_code, m.idx))
-
- self.check_if_item_repeated(m.item_code, m.operation, check_list)
-
-
- def check_if_item_repeated(self, item, op, check_list):
- if [cstr(item), cstr(op)] in check_list:
- frappe.throw(_("Item {0} has been entered multiple times against same operation").format(item))
- else:
- check_list.append([cstr(item), cstr(op)])
+ check_list.append(cstr(m.item_code))
+ unique_chk_list = set(check_list)
+ if len(unique_chk_list) != len(check_list):
+ frappe.throw(_("Same item has been entered multiple times."))
def check_recursion(self):
""" Check whether recursion occurs in any bom"""
diff --git a/erpnext/manufacturing/doctype/bom/test_records.json b/erpnext/manufacturing/doctype/bom/test_records.json
index c37cef0..6f10b21 100644
--- a/erpnext/manufacturing/doctype/bom/test_records.json
+++ b/erpnext/manufacturing/doctype/bom/test_records.json
@@ -67,7 +67,6 @@
],
"items": [
{
- "operation": 1,
"amount": 5000.0,
"doctype": "BOM Item",
"item_code": "_Test Item",
@@ -77,7 +76,6 @@
"stock_uom": "_Test UOM"
},
{
- "operation": 1,
"amount": 2000.0,
"bom_no": "BOM/_Test Item Home Desktop Manufactured/001",
"doctype": "BOM Item",
@@ -108,7 +106,6 @@
],
"items": [
{
- "operation": 1,
"amount": 5000.0,
"doctype": "BOM Item",
"item_code": "_Test Item",
diff --git a/erpnext/manufacturing/doctype/bom_item/bom_item.json b/erpnext/manufacturing/doctype/bom_item/bom_item.json
index 79287eb..6786ead 100644
--- a/erpnext/manufacturing/doctype/bom_item/bom_item.json
+++ b/erpnext/manufacturing/doctype/bom_item/bom_item.json
@@ -4,16 +4,6 @@
"doctype": "DocType",
"fields": [
{
- "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,
@@ -63,7 +53,7 @@
"permlevel": 0,
"print_width": "250px",
"reqd": 0,
- "width": "25px"
+ "width": "250px"
},
{
"fieldname": "quantity_and_rate",
@@ -143,7 +133,7 @@
}
],
"idx": 1,
- "istable": 1,
+ "istable": 1,
"modified": "2015-01-20 13:28:35.152945",
"modified_by": "Administrator",
"module": "Manufacturing",