Merge pull request #2605 from neilLasrado/bom-costs

Bom operations and item link removed.
This commit is contained in:
Nabin Hait 2015-02-03 18:31:56 +05:30
commit 1f9c6fdcf3
4 changed files with 16 additions and 55 deletions

View File

@ -13,9 +13,6 @@ cur_frm.cscript.refresh = function(doc,dt,dn){
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.update_item_desc = function() {
}
})
}
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 @@ frappe.ui.form.on("BOM Operation", "operation", function(frm, cdt, cdn) {
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", "workstation", function(frm, cdt, cdn) {
}
})
});
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);
});

View File

@ -196,8 +196,6 @@ class BOM(Document):
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 @@ class BOM(Document):
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"""

View File

@ -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",

View File

@ -3,16 +3,6 @@
"docstatus": 0,
"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",
@ -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",