bom cleanup
This commit is contained in:
parent
fce76cd5b2
commit
3adaf607f0
@ -17,9 +17,40 @@
|
|||||||
// On REFRESH
|
// On REFRESH
|
||||||
cur_frm.cscript.refresh = function(doc,dt,dn){
|
cur_frm.cscript.refresh = function(doc,dt,dn){
|
||||||
cur_frm.toggle_enable("item", doc.__islocal);
|
cur_frm.toggle_enable("item", doc.__islocal);
|
||||||
|
|
||||||
if (!doc.__islocal && doc.docstatus==0) {
|
if (!doc.__islocal && doc.docstatus==0) {
|
||||||
cur_frm.set_intro("Submit the BOM to use it in production");
|
cur_frm.set_intro("Submit the BOM to use it in production");
|
||||||
} else cur_frm.set_intro("");
|
} else cur_frm.set_intro("");
|
||||||
|
|
||||||
|
cur_frm.cscript.track_operations(doc);
|
||||||
|
set_operation_no(doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.track_operations = function(doc) {
|
||||||
|
cur_frm.fields_dict["bom_materials"].grid.set_column_disp("operation_no", doc.track_operations);
|
||||||
|
cur_frm.fields_dict["bom_materials"].grid.toggle_reqd("operation_no", doc.track_operations)
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_frm.cscript.operation_no = function(doc, cdt, cdn) {
|
||||||
|
var child = locals[cdt][cdn];
|
||||||
|
if(child.parentfield=="bom_operations") set_operation_no(doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
var set_operation_no = function(doc) {
|
||||||
|
var op_table = getchildren('BOM Operation', doc.name, 'bom_operations');
|
||||||
|
var operations = [];
|
||||||
|
|
||||||
|
for (var i=0, j=op_table.length; i<j; i++) {
|
||||||
|
var op = op_table[i].operation_no;
|
||||||
|
if (op && !inList(operations, op)) operations.push(op);
|
||||||
|
}
|
||||||
|
cur_frm.fields_dict["bom_materials"].grid.get_field("operation_no")
|
||||||
|
.df.options = operations.join("\n");
|
||||||
|
refresh_field("bom_materials");
|
||||||
|
}
|
||||||
|
|
||||||
|
cur_frm.fields_dict["bom_operations"].grid.on_row_delete = function(cdt, cdn){
|
||||||
|
set_operation_no(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.item = function(doc, dt, dn) {
|
cur_frm.cscript.item = function(doc, dt, dn) {
|
||||||
@ -28,7 +59,6 @@ cur_frm.cscript.item = function(doc, dt, dn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cur_frm.cscript.workstation = function(doc,dt,dn) {
|
cur_frm.cscript.workstation = function(doc,dt,dn) {
|
||||||
var d = locals[dt][dn];
|
var d = locals[dt][dn];
|
||||||
if (d.workstation) {
|
if (d.workstation) {
|
||||||
@ -167,11 +197,11 @@ cur_frm.fields_dict['bom_materials'].grid.get_field('item_code').get_query = fun
|
|||||||
cur_frm.fields_dict['bom_materials'].grid.get_field('bom_no').get_query = function(doc, cdt, cdn) {
|
cur_frm.fields_dict['bom_materials'].grid.get_field('bom_no').get_query = function(doc, cdt, cdn) {
|
||||||
var d = locals[cdt][cdn];
|
var d = locals[cdt][cdn];
|
||||||
msgprint('SELECT DISTINCT `tabBOM`.`name`, `tabBOM`.`remarks` FROM `tabBOM` \
|
msgprint('SELECT DISTINCT `tabBOM`.`name`, `tabBOM`.`remarks` FROM `tabBOM` \
|
||||||
WHERE `tabBOM`.`item` = "' + d.item_code + '" AND `tabBOM`.`is_active` = "Yes" AND \
|
WHERE `tabBOM`.`item` = "' + d.item_code + '" AND `tabBOM`.`is_active` = 1 AND \
|
||||||
`tabBOM`.docstatus = 1 AND `tabBOM`.`name` like "%s" \
|
`tabBOM`.docstatus = 1 AND `tabBOM`.`name` like "%s" \
|
||||||
ORDER BY `tabBOM`.`name` LIMIT 50');
|
ORDER BY `tabBOM`.`name` LIMIT 50');
|
||||||
return 'SELECT DISTINCT `tabBOM`.`name`, `tabBOM`.`remarks` FROM `tabBOM` \
|
return 'SELECT DISTINCT `tabBOM`.`name`, `tabBOM`.`remarks` FROM `tabBOM` \
|
||||||
WHERE `tabBOM`.`item` = "' + d.item_code + '" AND `tabBOM`.`is_active` = "Yes" AND \
|
WHERE `tabBOM`.`item` = "' + d.item_code + '" AND `tabBOM`.`is_active` = 1 AND \
|
||||||
`tabBOM`.docstatus = 1 AND `tabBOM`.`name` like "%s" \
|
`tabBOM`.docstatus = 1 AND `tabBOM`.`name` like "%s" \
|
||||||
ORDER BY `tabBOM`.`name` LIMIT 50';
|
ORDER BY `tabBOM`.`name` LIMIT 50';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -108,7 +108,7 @@ class DocType:
|
|||||||
|
|
||||||
def get_bom_unitcost(self, bom_no):
|
def get_bom_unitcost(self, bom_no):
|
||||||
bom = sql("""select name, total_cost/quantity as unit_cost from `tabBOM`
|
bom = sql("""select name, total_cost/quantity as unit_cost from `tabBOM`
|
||||||
where is_active = 'Yes' and name = %s""", bom_no, as_dict=1)
|
where is_active = 1 and name = %s""", bom_no, as_dict=1)
|
||||||
return bom and bom[0]['unit_cost'] or 0
|
return bom and bom[0]['unit_cost'] or 0
|
||||||
|
|
||||||
def get_valuation_rate(self, arg):
|
def get_valuation_rate(self, arg):
|
||||||
@ -134,7 +134,7 @@ class DocType:
|
|||||||
update default bom in item master
|
update default bom in item master
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.doc.is_default and self.doc.is_active == 'Yes':
|
if self.doc.is_default and self.doc.is_active:
|
||||||
sql("update `tabBOM` set is_default = 0 where name != %s and item=%s",
|
sql("update `tabBOM` set is_default = 0 where name != %s and item=%s",
|
||||||
(self.doc.name, self.doc.item))
|
(self.doc.name, self.doc.item))
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ class DocType:
|
|||||||
check_list = []
|
check_list = []
|
||||||
for m in getlist(self.doclist, 'bom_materials'):
|
for m in getlist(self.doclist, 'bom_materials'):
|
||||||
# check if operation no not in op table
|
# check if operation no not in op table
|
||||||
if cstr(m.operation_no) not in self.op:
|
if self.doc.track_operations and cstr(m.operation_no) not in self.op:
|
||||||
msgprint("""Operation no: %s against item: %s at row no: %s \
|
msgprint("""Operation no: %s against item: %s at row no: %s \
|
||||||
is not present at Operations table""" %
|
is not present at Operations table""" %
|
||||||
(m.operation_no, m.item_code, m.idx), raise_exception = 1)
|
(m.operation_no, m.item_code, m.idx), raise_exception = 1)
|
||||||
@ -207,7 +207,7 @@ class DocType:
|
|||||||
def validate_bom_no(self, item, bom_no, idx):
|
def validate_bom_no(self, item, bom_no, idx):
|
||||||
"""Validate BOM No of sub-contracted items"""
|
"""Validate BOM No of sub-contracted items"""
|
||||||
bom = sql("""select name from `tabBOM` where name = %s and item = %s
|
bom = sql("""select name from `tabBOM` where name = %s and item = %s
|
||||||
and ifnull(is_active, 'No') = 'Yes' and docstatus < 2 """,
|
and is_active = 1 and docstatus < 2 """,
|
||||||
(bom_no, item), as_dict =1)
|
(bom_no, item), as_dict =1)
|
||||||
if not bom:
|
if not bom:
|
||||||
msgprint("""Incorrect BOM No: %s against item: %s at row no: %s.
|
msgprint("""Incorrect BOM No: %s against item: %s at row no: %s.
|
||||||
@ -374,12 +374,12 @@ class DocType:
|
|||||||
# check if used in any other bom
|
# check if used in any other bom
|
||||||
par = sql("""select t1.parent from `tabBOM Item` t1, `tabBOM` t2
|
par = sql("""select t1.parent from `tabBOM Item` t1, `tabBOM` t2
|
||||||
where t1.parent = t2.name and t1.bom_no = %s and t1.docstatus = 1
|
where t1.parent = t2.name and t1.bom_no = %s and t1.docstatus = 1
|
||||||
and t2.is_active = 'Yes'""", self.doc.name)
|
and t2.is_active = 1""", self.doc.name)
|
||||||
if par:
|
if par:
|
||||||
msgprint("""BOM can not be cancelled, as it is a child item \
|
msgprint("""BOM can not be cancelled, as it is a child item \
|
||||||
in following active BOM %s""" % [d[0] for d in par], raise_exception=1)
|
in following active BOM %s""" % [d[0] for d in par], raise_exception=1)
|
||||||
|
|
||||||
webnotes.conn.set(self.doc, "is_active", "No")
|
webnotes.conn.set(self.doc, "is_active", 0)
|
||||||
webnotes.conn.set(self.doc, "is_default", 0)
|
webnotes.conn.set(self.doc, "is_default", 0)
|
||||||
self.manage_default_bom()
|
self.manage_default_bom()
|
||||||
self.update_cost_and_exploded_items(calculate_cost=False)
|
self.update_cost_and_exploded_items(calculate_cost=False)
|
||||||
@ -391,9 +391,9 @@ class DocType:
|
|||||||
|
|
||||||
|
|
||||||
def validate_inactive_bom(self):
|
def validate_inactive_bom(self):
|
||||||
if self.doc.is_active == 'No':
|
if not self.doc.is_active:
|
||||||
act_pbom = sql("""select distinct t1.parent from `tabBOM Item` t1, `tabBOM` t2
|
act_pbom = sql("""select distinct t1.parent from `tabBOM Item` t1, `tabBOM` t2
|
||||||
where t1.bom_no =%s and t2.name = t1.parent and t2.is_active = 'Yes'
|
where t1.bom_no =%s and t2.name = t1.parent and t2.is_active = 1
|
||||||
and t2.docstatus = 1 and t1.docstatus =1 """, self.doc.name)
|
and t2.docstatus = 1 and t1.docstatus =1 """, self.doc.name)
|
||||||
if act_pbom and act_pbom[0][0]:
|
if act_pbom and act_pbom[0][0]:
|
||||||
msgprint("""Sorry cannot inactivate as BOM: %s is child
|
msgprint("""Sorry cannot inactivate as BOM: %s is child
|
||||||
|
|||||||
@ -2,9 +2,9 @@
|
|||||||
{
|
{
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"creation": "2012-12-12 10:17:41",
|
"creation": "2012-12-14 10:15:15",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"modified": "2012-12-13 11:48:39"
|
"modified": "2012-12-14 13:40:48"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"istable": 0,
|
"istable": 0,
|
||||||
@ -44,14 +44,6 @@
|
|||||||
"name": "BOM",
|
"name": "BOM",
|
||||||
"doctype": "DocType"
|
"doctype": "DocType"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"oldfieldtype": "Column Break",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"width": "50%",
|
|
||||||
"fieldname": "column_break0",
|
|
||||||
"fieldtype": "Column Break",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"description": "Select the item code for which Bill of Material is being created",
|
"description": "Select the item code for which Bill of Material is being created",
|
||||||
"oldfieldtype": "Link",
|
"oldfieldtype": "Link",
|
||||||
@ -67,55 +59,15 @@
|
|||||||
"options": "Item"
|
"options": "Item"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Total quantity of items for which raw materials required and operations done will be defined",
|
|
||||||
"default": "1",
|
|
||||||
"oldfieldtype": "Currency",
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Quantity",
|
"fieldname": "cb0",
|
||||||
"oldfieldname": "quantity",
|
|
||||||
"fieldname": "quantity",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"reqd": 1,
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"label": "Item UOM",
|
|
||||||
"options": "link:UOM",
|
|
||||||
"fieldname": "uom",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"permlevel": 1
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"width": "50%",
|
|
||||||
"fieldname": "column_break1",
|
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"permlevel": 0,
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldtype": "Select",
|
|
||||||
"allow_on_submit": 1,
|
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Is Active",
|
"label": "Track Operations",
|
||||||
"oldfieldname": "is_active",
|
"fieldname": "track_operations",
|
||||||
"default": "Yes",
|
|
||||||
"fieldname": "is_active",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"reqd": 1,
|
|
||||||
"hidden": 0,
|
|
||||||
"options": "\nYes\nNo"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldtype": "Check",
|
|
||||||
"allow_on_submit": 1,
|
|
||||||
"doctype": "DocField",
|
|
||||||
"label": "Is Default",
|
|
||||||
"oldfieldname": "is_default",
|
|
||||||
"fieldname": "is_default",
|
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
@ -123,12 +75,13 @@
|
|||||||
"oldfieldtype": "Section Break",
|
"oldfieldtype": "Section Break",
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Operations",
|
"label": "Operations",
|
||||||
|
"options": "Specify the operations, operating cost and give a unique Operation no to your operations.",
|
||||||
"fieldname": "operations",
|
"fieldname": "operations",
|
||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
|
"depends_on": "track_operations",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Specify the operations, operating cost and give a unique Operation no to your operations.",
|
|
||||||
"oldfieldtype": "Table",
|
"oldfieldtype": "Table",
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "BOM Operations",
|
"label": "BOM Operations",
|
||||||
@ -146,14 +99,6 @@
|
|||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"doctype": "DocField",
|
|
||||||
"label": "Consider Raw Material Cost As Per",
|
|
||||||
"options": "Valuation Rate\nLast Purchase Rate\nStandard Rate",
|
|
||||||
"fieldname": "rm_cost_as_per",
|
|
||||||
"fieldtype": "Select",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"description": "Enter the raw materials required to manufacture the BOM item. Specify the operation no as entered in the previous tab which will be performed on the raw materials entered.",
|
"description": "Enter the raw materials required to manufacture the BOM item. Specify the operation no as entered in the previous tab which will be performed on the raw materials entered.",
|
||||||
"oldfieldtype": "Table",
|
"oldfieldtype": "Table",
|
||||||
@ -173,6 +118,27 @@
|
|||||||
"fieldtype": "Section Break",
|
"fieldtype": "Section Break",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"label": "Consider Raw Material Cost As Per",
|
||||||
|
"options": "Valuation Rate\nLast Purchase Rate",
|
||||||
|
"fieldname": "rm_cost_as_per",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"label": "Total Cost",
|
||||||
|
"fieldname": "total_cost",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"permlevel": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"fieldname": "cb1",
|
||||||
|
"fieldtype": "Column Break",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Raw Material Cost",
|
"label": "Raw Material Cost",
|
||||||
@ -189,16 +155,35 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Total Cost",
|
"label": "More Info",
|
||||||
"fieldname": "total_cost",
|
"fieldname": "more_info_section",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Section Break",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Total quantity of items for which raw materials required and operations done will be defined",
|
||||||
|
"default": "1",
|
||||||
|
"oldfieldtype": "Currency",
|
||||||
|
"doctype": "DocField",
|
||||||
|
"label": "Quantity",
|
||||||
|
"oldfieldname": "quantity",
|
||||||
|
"fieldname": "quantity",
|
||||||
|
"fieldtype": "Currency",
|
||||||
|
"reqd": 1,
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocField",
|
||||||
|
"label": "Item UOM",
|
||||||
|
"options": "link:UOM",
|
||||||
|
"fieldname": "uom",
|
||||||
|
"fieldtype": "Select",
|
||||||
"permlevel": 1
|
"permlevel": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "More Info",
|
"fieldname": "col_break23",
|
||||||
"fieldname": "more_info_section",
|
"fieldtype": "Column Break",
|
||||||
"fieldtype": "Section Break",
|
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -214,18 +199,28 @@
|
|||||||
"in_filter": 1
|
"in_filter": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"oldfieldtype": "Data",
|
"no_copy": 1,
|
||||||
|
"oldfieldtype": "Select",
|
||||||
|
"allow_on_submit": 1,
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Maintained By",
|
"label": "Is Active",
|
||||||
"oldfieldname": "maintained_by",
|
"oldfieldname": "is_active",
|
||||||
"fieldname": "maintained_by",
|
"default": "1",
|
||||||
"fieldtype": "Data",
|
"fieldname": "is_active",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"reqd": 1,
|
||||||
|
"hidden": 0,
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"no_copy": 1,
|
||||||
|
"oldfieldtype": "Check",
|
||||||
|
"allow_on_submit": 1,
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "col_break23",
|
"label": "Is Default",
|
||||||
"fieldtype": "Column Break",
|
"oldfieldname": "is_default",
|
||||||
|
"fieldname": "is_default",
|
||||||
|
"fieldtype": "Check",
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -238,27 +233,6 @@
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"permlevel": 1
|
"permlevel": 1
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"print_hide": 1,
|
|
||||||
"description": "The date at which current entry is corrected in the system.",
|
|
||||||
"no_copy": 1,
|
|
||||||
"depends_on": "eval:doc.amended_from",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"label": "Amendment Date",
|
|
||||||
"fieldname": "amendment_date",
|
|
||||||
"fieldtype": "Date",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"no_copy": 1,
|
|
||||||
"oldfieldtype": "Text",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"label": "Remarks",
|
|
||||||
"oldfieldname": "remarks",
|
|
||||||
"fieldname": "remarks",
|
|
||||||
"fieldtype": "Small Text",
|
|
||||||
"permlevel": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"print_hide": 0,
|
"print_hide": 0,
|
||||||
"depends_on": "eval:!doc.__islocal",
|
"depends_on": "eval:!doc.__islocal",
|
||||||
@ -284,6 +258,17 @@
|
|||||||
"hidden": 0,
|
"hidden": 0,
|
||||||
"options": "BOM Explosion Item"
|
"options": "BOM Explosion Item"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"print_hide": 1,
|
||||||
|
"description": "The date at which current entry is corrected in the system.",
|
||||||
|
"no_copy": 1,
|
||||||
|
"depends_on": "eval:doc.amended_from",
|
||||||
|
"doctype": "DocField",
|
||||||
|
"label": "Amendment Date",
|
||||||
|
"fieldname": "amendment_date",
|
||||||
|
"fieldtype": "Date",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"doctype": "DocPerm",
|
"doctype": "DocPerm",
|
||||||
|
|||||||
@ -17,7 +17,7 @@ wn.doclistviews['BOM'] = wn.views.ListView.extend({
|
|||||||
prepare_data: function(data) {
|
prepare_data: function(data) {
|
||||||
this._super(data);
|
this._super(data);
|
||||||
data.costing_date = wn.datetime.str_to_user(data.costing_date);
|
data.costing_date = wn.datetime.str_to_user(data.costing_date);
|
||||||
data.description = (data.is_active === 'Yes' ? '' : '[Inactive] ') + data.description;
|
data.description = (data.is_active ? '' : '[Inactive] ') + data.description;
|
||||||
},
|
},
|
||||||
|
|
||||||
columns: [
|
columns: [
|
||||||
|
|||||||
@ -2,20 +2,15 @@
|
|||||||
{
|
{
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"creation": "2012-03-27 14:36:02",
|
"creation": "2012-12-14 10:15:16",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"modified": "2012-12-10 18:30:00"
|
"modified": "2012-12-14 13:11:49"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"section_style": "Simple",
|
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"name": "__common__",
|
"name": "__common__",
|
||||||
"colour": "White:FFF",
|
"doctype": "DocType",
|
||||||
"module": "Manufacturing",
|
"module": "Manufacturing"
|
||||||
"show_in_menu": 0,
|
|
||||||
"version": 27,
|
|
||||||
"server_code_error": " ",
|
|
||||||
"doctype": "DocType"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "__common__",
|
"name": "__common__",
|
||||||
@ -37,36 +32,26 @@
|
|||||||
"name": "BOM Item",
|
"name": "BOM Item",
|
||||||
"doctype": "DocType"
|
"doctype": "DocType"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"write": 1,
|
|
||||||
"permlevel": 0,
|
|
||||||
"doctype": "DocPerm"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"permlevel": 1,
|
|
||||||
"doctype": "DocPerm"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"oldfieldtype": "Data",
|
"oldfieldtype": "Data",
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Operation No",
|
"label": "Operation No",
|
||||||
"oldfieldname": "operation_no",
|
"oldfieldname": "operation_no",
|
||||||
"fieldname": "operation_no",
|
"fieldname": "operation_no",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Select",
|
||||||
"reqd": 1,
|
"reqd": 0,
|
||||||
"permlevel": 0
|
"permlevel": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"search_index": 1,
|
"oldfieldtype": "Link",
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Item Code",
|
"label": "Item Code",
|
||||||
"oldfieldname": "item_code",
|
"oldfieldname": "item_code",
|
||||||
"trigger": "Client",
|
"options": "Item",
|
||||||
"fieldname": "item_code",
|
"fieldname": "item_code",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"oldfieldtype": "Link",
|
"search_index": 1,
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
"options": "Item",
|
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"in_filter": 1
|
"in_filter": 1
|
||||||
},
|
},
|
||||||
@ -77,7 +62,6 @@
|
|||||||
"label": "BOM No",
|
"label": "BOM No",
|
||||||
"oldfieldname": "bom_no",
|
"oldfieldname": "bom_no",
|
||||||
"width": "150px",
|
"width": "150px",
|
||||||
"trigger": "Client",
|
|
||||||
"fieldname": "bom_no",
|
"fieldname": "bom_no",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"search_index": 1,
|
"search_index": 1,
|
||||||
@ -90,7 +74,6 @@
|
|||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"label": "Qty",
|
"label": "Qty",
|
||||||
"oldfieldname": "qty",
|
"oldfieldname": "qty",
|
||||||
"trigger": "Client",
|
|
||||||
"fieldname": "qty",
|
"fieldname": "qty",
|
||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"reqd": 1,
|
"reqd": 1,
|
||||||
@ -154,5 +137,14 @@
|
|||||||
"fieldtype": "Float",
|
"fieldtype": "Float",
|
||||||
"hidden": 1,
|
"hidden": 1,
|
||||||
"permlevel": 1
|
"permlevel": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"write": 1,
|
||||||
|
"doctype": "DocPerm",
|
||||||
|
"permlevel": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"doctype": "DocPerm",
|
||||||
|
"permlevel": 1
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -102,8 +102,7 @@ cur_frm.cscript['Update Finished Goods'] = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cur_frm.cscript.make_se = function(doc, process) {
|
cur_frm.cscript.make_se = function(doc, process) {
|
||||||
var se = LocalDB.create('Stock Entry');
|
var se = wn.model.get_new_doc("Stock Entry");
|
||||||
se = locals['Stock Entry'][se];
|
|
||||||
se.purpose = 'Production Order';
|
se.purpose = 'Production Order';
|
||||||
se.process = process;
|
se.process = process;
|
||||||
se.production_order = doc.name;
|
se.production_order = doc.name;
|
||||||
|
|||||||
@ -173,7 +173,7 @@ class DocType:
|
|||||||
(d.item_code, d.idx), raise_exception=1)
|
(d.item_code, d.idx), raise_exception=1)
|
||||||
else:
|
else:
|
||||||
bom = sql("""select name from `tabBOM` where name = %s and item = %s
|
bom = sql("""select name from `tabBOM` where name = %s and item = %s
|
||||||
and docstatus = 1 and ifnull(is_active, 'No') = 'Yes'""",
|
and docstatus = 1 and is_active = 1""",
|
||||||
(d.bom_no, d.item_code), as_dict = 1)
|
(d.bom_no, d.item_code), as_dict = 1)
|
||||||
if not bom:
|
if not bom:
|
||||||
msgprint("""Incorrect BOM No: %s entered for item: %s at row no: %s
|
msgprint("""Incorrect BOM No: %s entered for item: %s at row no: %s
|
||||||
|
|||||||
@ -2,9 +2,9 @@
|
|||||||
{
|
{
|
||||||
"owner": "jai@webnotestech.com",
|
"owner": "jai@webnotestech.com",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"creation": "2012-12-11 15:15:06",
|
"creation": "2012-12-14 10:15:16",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"modified": "2012-12-11 16:13:59"
|
"modified": "2012-12-14 11:37:40"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"read_only": 1,
|
"read_only": 1,
|
||||||
@ -148,15 +148,6 @@
|
|||||||
"fieldtype": "Button",
|
"fieldtype": "Button",
|
||||||
"options": "clear_item_table"
|
"options": "clear_item_table"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"description": "If checked, BOM for sub-assembly items will be considered for getting raw materials. Otherwise, all sub-assembly items will be treated as a raw material.",
|
|
||||||
"default": "1",
|
|
||||||
"doctype": "DocField",
|
|
||||||
"label": "Use Multi-Level BOM",
|
|
||||||
"fieldname": "use_multi_level_bom",
|
|
||||||
"fieldtype": "Check",
|
|
||||||
"reqd": 0
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "section_break3",
|
"fieldname": "section_break3",
|
||||||
@ -183,6 +174,15 @@
|
|||||||
"fieldname": "column_break6",
|
"fieldname": "column_break6",
|
||||||
"fieldtype": "Column Break"
|
"fieldtype": "Column Break"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"description": "If checked, BOM for sub-assembly items will be considered for getting raw materials. Otherwise, all sub-assembly items will be treated as a raw material.",
|
||||||
|
"default": "1",
|
||||||
|
"doctype": "DocField",
|
||||||
|
"label": "Use Multi-Level BOM",
|
||||||
|
"fieldname": "use_multi_level_bom",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"reqd": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"description": "Download a report containing all raw materials with their latest inventory status",
|
"description": "Download a report containing all raw materials with their latest inventory status",
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
|
|||||||
@ -4,12 +4,14 @@ def execute():
|
|||||||
delete_doctypes()
|
delete_doctypes()
|
||||||
rename_module()
|
rename_module()
|
||||||
rebuilt_exploded_bom()
|
rebuilt_exploded_bom()
|
||||||
|
cleanup_bom()
|
||||||
|
|
||||||
def delete_doctypes():
|
def delete_doctypes():
|
||||||
from webnotes.model import delete_doc
|
from webnotes.model import delete_doc
|
||||||
delete_doc("DocType", "Production Control")
|
delete_doc("DocType", "Production Control")
|
||||||
delete_doc("DocType", "BOM Control")
|
delete_doc("DocType", "BOM Control")
|
||||||
|
|
||||||
|
|
||||||
def rename_module():
|
def rename_module():
|
||||||
webnotes.reload_doc("core", "doctype", "role")
|
webnotes.reload_doc("core", "doctype", "role")
|
||||||
webnotes.reload_doc("core", "doctype", "page")
|
webnotes.reload_doc("core", "doctype", "page")
|
||||||
@ -38,3 +40,8 @@ def rebuilt_exploded_bom():
|
|||||||
from webnotes.model.code import get_obj
|
from webnotes.model.code import get_obj
|
||||||
for bom in webnotes.conn.sql("""select name from `tabBOM` where docstatus < 2"""):
|
for bom in webnotes.conn.sql("""select name from `tabBOM` where docstatus < 2"""):
|
||||||
get_obj("BOM", bom[0], with_children=1).on_update()
|
get_obj("BOM", bom[0], with_children=1).on_update()
|
||||||
|
|
||||||
|
def cleanup_bom():
|
||||||
|
webnotes.conn.sql("""UPDATE `tabBOM` SET is_active = if(is_active='Yes', 1, 0),
|
||||||
|
track_operations = 1""")
|
||||||
|
|
||||||
@ -5,7 +5,7 @@ def execute():
|
|||||||
where docstatus = 2""")
|
where docstatus = 2""")
|
||||||
|
|
||||||
for bom in cancelled_boms:
|
for bom in cancelled_boms:
|
||||||
webnotes.conn.sql("""update `tabBOM` set is_default=0, is_active='No'
|
webnotes.conn.sql("""update `tabBOM` set is_default=0, is_active=0
|
||||||
where name=%s""", (bom[0],))
|
where name=%s""", (bom[0],))
|
||||||
|
|
||||||
webnotes.conn.sql("""update `tabItem` set default_bom=null
|
webnotes.conn.sql("""update `tabItem` set default_bom=null
|
||||||
|
|||||||
@ -119,7 +119,7 @@ erpnext.queries.bom = function(opts) {
|
|||||||
return 'SELECT tabBOM.name, tabBOM.item \
|
return 'SELECT tabBOM.name, tabBOM.item \
|
||||||
FROM tabBOM \
|
FROM tabBOM \
|
||||||
WHERE tabBOM.docstatus=1 \
|
WHERE tabBOM.docstatus=1 \
|
||||||
AND tabBOM.is_active="Yes" \
|
AND tabBOM.is_active=1 \
|
||||||
AND tabBOM.%(key)s LIKE "%s" ' + (conditions.length
|
AND tabBOM.%(key)s LIKE "%s" ' + (conditions.length
|
||||||
? (" AND " + conditions.join(" AND "))
|
? (" AND " + conditions.join(" AND "))
|
||||||
: "")
|
: "")
|
||||||
|
|||||||
@ -52,7 +52,7 @@ cur_frm.cscript.show_in_website = function(doc, dt, dn) {
|
|||||||
|
|
||||||
cur_frm.fields_dict['default_bom'].get_query = function(doc) {
|
cur_frm.fields_dict['default_bom'].get_query = function(doc) {
|
||||||
//var d = locals[this.doctype][this.docname];
|
//var d = locals[this.doctype][this.docname];
|
||||||
return 'SELECT DISTINCT `tabBOM`.`name` FROM `tabBOM` WHERE `tabBOM`.`item` = "' + doc.item_code + '" AND `tabBOM`.`is_active` = "No" and `tabBOM`.docstatus != 2 AND `tabBOM`.%(key)s LIKE "%s" ORDER BY `tabBOM`.`name` LIMIT 50'
|
return 'SELECT DISTINCT `tabBOM`.`name` FROM `tabBOM` WHERE `tabBOM`.`item` = "' + doc.item_code + '" AND ifnull(`tabBOM`.`is_active`, 0) = 0 and `tabBOM`.docstatus != 2 AND `tabBOM`.%(key)s LIKE "%s" ORDER BY `tabBOM`.`name` LIMIT 50'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -375,7 +375,11 @@ class DocType(TransactionBase):
|
|||||||
|
|
||||||
def add_bom(self, d):
|
def add_bom(self, d):
|
||||||
#----- fetching default bom from Bill of Materials instead of Item Master --
|
#----- fetching default bom from Bill of Materials instead of Item Master --
|
||||||
bom_det = sql("select t1.item, t2.item_code, t2.qty_consumed_per_unit, t2.moving_avg_rate, t2.value_as_per_mar, t2.stock_uom, t2.name, t2.description from `tabBOM` t1, `tabBOM Item` t2 where t2.parent = t1.name and t1.item = '%s' and ifnull(t1.is_default,0) = 1 and t1.docstatus = 1 and t2.docstatus =1" % d.item_code)
|
bom_det = sql("""select t1.item, t2.item_code, t2.qty_consumed_per_unit,
|
||||||
|
t2.moving_avg_rate, t2.value_as_per_mar, t2.stock_uom, t2.name, t2.description
|
||||||
|
from `tabBOM` t1, `tabBOM Item` t2
|
||||||
|
where t2.parent = t1.name and t1.item = %s and t1.is_default = 1
|
||||||
|
and t1.docstatus = 1 and t2.docstatus =1 and t1.is_active = 1""", d.item_code)
|
||||||
if not bom_det:
|
if not bom_det:
|
||||||
msgprint("No default BOM exists for item: %s" % d.item_code)
|
msgprint("No default BOM exists for item: %s" % d.item_code)
|
||||||
raise Exception
|
raise Exception
|
||||||
|
|||||||
@ -214,7 +214,7 @@ class DocType(TransactionBase):
|
|||||||
def validate_bom_no(self):
|
def validate_bom_no(self):
|
||||||
if self.doc.bom_no:
|
if self.doc.bom_no:
|
||||||
if not webnotes.conn.sql("""select name from tabBOM where name = %s and docstatus = 1
|
if not webnotes.conn.sql("""select name from tabBOM where name = %s and docstatus = 1
|
||||||
and ifnull(is_active, 'No') = 'Yes'""", self.doc.bom_no):
|
and is_active = 1""", self.doc.bom_no):
|
||||||
msgprint("""BOM: %s not found, may be it has been cancelled or inactivated""" %
|
msgprint("""BOM: %s not found, may be it has been cancelled or inactivated""" %
|
||||||
self.doc.bom_no, raise_exception=1)
|
self.doc.bom_no, raise_exception=1)
|
||||||
if not self.doc.fg_completed_qty:
|
if not self.doc.fg_completed_qty:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user