Bom operations and item link removed. Cost recalculated on removal of operation or rew material row.
This commit is contained in:
parent
44c0a741d1
commit
c8c67f7807
@ -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,
|
cur_frm.add_custom_button(__("Update Item Description"), cur_frm.cscript.update_item_desc,
|
||||||
"icon-tag", "btn-default");
|
"icon-tag", "btn-default");
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.with_operations(doc);
|
|
||||||
erpnext.bom.set_operation(doc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.update_cost = function() {
|
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", "description", "description");
|
||||||
cur_frm.add_fetch("item", "item_name", "item_name");
|
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");
|
||||||
@ -210,7 +184,6 @@ frappe.ui.form.on("BOM Operation", "operation", function(frm, cdt, cdn) {
|
|||||||
callback: function (data) {
|
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, "opn_description", data.message.opn_description);
|
||||||
frappe.model.set_value(d.doctype, d.name, "workstation", data.message.workstation);
|
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);
|
||||||
|
});
|
||||||
@ -196,8 +196,6 @@ class BOM(Document):
|
|||||||
def clear_operations(self):
|
def clear_operations(self):
|
||||||
if not self.with_operations:
|
if not self.with_operations:
|
||||||
self.set('operations', [])
|
self.set('operations', [])
|
||||||
for d in self.get("items"):
|
|
||||||
d.operation = None
|
|
||||||
|
|
||||||
def validate_main_item(self):
|
def validate_main_item(self):
|
||||||
""" Validate main FG item"""
|
""" Validate main FG item"""
|
||||||
@ -223,14 +221,15 @@ class BOM(Document):
|
|||||||
if flt(m.qty) <= 0:
|
if flt(m.qty) <= 0:
|
||||||
frappe.throw(_("Quantity required for Item {0} in row {1}").format(m.item_code, m.idx))
|
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)
|
self.check_if_item_repeated(m.item_code, check_list)
|
||||||
|
|
||||||
|
|
||||||
def check_if_item_repeated(self, item, op, check_list):
|
def check_if_item_repeated(self, item, check_list):
|
||||||
if [cstr(item), cstr(op)] in check_list:
|
|
||||||
frappe.throw(_("Item {0} has been entered multiple times against same operation").format(item))
|
if [cstr(item)] in check_list:
|
||||||
|
frappe.throw(_("Item {0} has been entered multiple times.").format(item))
|
||||||
else:
|
else:
|
||||||
check_list.append([cstr(item), cstr(op)])
|
check_list.append([cstr(item)])
|
||||||
|
|
||||||
def check_recursion(self):
|
def check_recursion(self):
|
||||||
""" Check whether recursion occurs in any bom"""
|
""" Check whether recursion occurs in any bom"""
|
||||||
|
|||||||
@ -3,16 +3,6 @@
|
|||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
|
||||||
"fieldname": "operation",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"in_list_view": 1,
|
|
||||||
"label": "Operation",
|
|
||||||
"oldfieldname": "operation_no",
|
|
||||||
"oldfieldtype": "Data",
|
|
||||||
"permlevel": 0,
|
|
||||||
"reqd": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "item_code",
|
"fieldname": "item_code",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
@ -63,7 +53,7 @@
|
|||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_width": "250px",
|
"print_width": "250px",
|
||||||
"reqd": 0,
|
"reqd": 0,
|
||||||
"width": "25px"
|
"width": "250px"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "quantity_and_rate",
|
"fieldname": "quantity_and_rate",
|
||||||
@ -143,7 +133,7 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"idx": 1,
|
"idx": 1,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-01-20 13:28:35.152945",
|
"modified": "2015-01-20 13:28:35.152945",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user