mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-29 18:04:46 +00:00
Merge pull request #2605 from neilLasrado/bom-costs
Bom operations and item link removed.
This commit is contained in:
@@ -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"""
|
||||||
@@ -216,21 +214,14 @@ class BOM(Document):
|
|||||||
frappe.throw(_("Raw Materials cannot be blank."))
|
frappe.throw(_("Raw Materials cannot be blank."))
|
||||||
check_list = []
|
check_list = []
|
||||||
for m in self.get('items'):
|
for m in self.get('items'):
|
||||||
|
|
||||||
if m.bom_no:
|
if m.bom_no:
|
||||||
validate_bom_no(m.item_code, m.bom_no)
|
validate_bom_no(m.item_code, m.bom_no)
|
||||||
|
|
||||||
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))
|
||||||
|
check_list.append(cstr(m.item_code))
|
||||||
self.check_if_item_repeated(m.item_code, m.operation, check_list)
|
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_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)])
|
|
||||||
|
|
||||||
def check_recursion(self):
|
def check_recursion(self):
|
||||||
""" Check whether recursion occurs in any bom"""
|
""" Check whether recursion occurs in any bom"""
|
||||||
|
|||||||
@@ -67,7 +67,6 @@
|
|||||||
],
|
],
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"operation": 1,
|
|
||||||
"amount": 5000.0,
|
"amount": 5000.0,
|
||||||
"doctype": "BOM Item",
|
"doctype": "BOM Item",
|
||||||
"item_code": "_Test Item",
|
"item_code": "_Test Item",
|
||||||
@@ -77,7 +76,6 @@
|
|||||||
"stock_uom": "_Test UOM"
|
"stock_uom": "_Test UOM"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"operation": 1,
|
|
||||||
"amount": 2000.0,
|
"amount": 2000.0,
|
||||||
"bom_no": "BOM/_Test Item Home Desktop Manufactured/001",
|
"bom_no": "BOM/_Test Item Home Desktop Manufactured/001",
|
||||||
"doctype": "BOM Item",
|
"doctype": "BOM Item",
|
||||||
@@ -108,7 +106,6 @@
|
|||||||
],
|
],
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"operation": 1,
|
|
||||||
"amount": 5000.0,
|
"amount": 5000.0,
|
||||||
"doctype": "BOM Item",
|
"doctype": "BOM Item",
|
||||||
"item_code": "_Test Item",
|
"item_code": "_Test Item",
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
Reference in New Issue
Block a user