bom code cleanup

This commit is contained in:
Nabin Hait 2012-12-13 11:47:41 +05:30
parent 4301dadaab
commit 7e20d938d4
3 changed files with 31 additions and 50 deletions

View File

@ -19,7 +19,7 @@ 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("");
} }
cur_frm.cscript.item = function(doc, dt, dn) { cur_frm.cscript.item = function(doc, dt, dn) {
@ -164,8 +164,12 @@ cur_frm.fields_dict['bom_materials'].grid.get_field('item_code').get_query = fun
ORDER BY `tabItem`.`name` LIMIT 50'; ORDER BY `tabItem`.`name` LIMIT 50';
} }
cur_frm.fields_dict['bom_materials'].grid.get_field('bom_no').get_query = function(doc) { cur_frm.fields_dict['bom_materials'].grid.get_field('bom_no').get_query = function(doc, cdt, cdn) {
var d = locals[this.doctype][this.docname]; var d = locals[cdt][cdn];
msgprint('SELECT DISTINCT `tabBOM`.`name`, `tabBOM`.`remarks` FROM `tabBOM` \
WHERE `tabBOM`.`item` = "' + d.item_code + '" AND `tabBOM`.`is_active` = "Yes" AND \
`tabBOM`.docstatus = 1 AND `tabBOM`.`name` like "%s" \
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` = "Yes" AND \
`tabBOM`.docstatus = 1 AND `tabBOM`.`name` like "%s" \ `tabBOM`.docstatus = 1 AND `tabBOM`.`name` like "%s" \

View File

@ -42,7 +42,7 @@ class DocType:
def get_item_det(self, item_code): def get_item_det(self, item_code):
item = sql("""select name, is_asset_item, is_purchase_item, docstatus, item = sql("""select name, is_asset_item, is_purchase_item, docstatus,
is_sub_contracted_item, description, stock_uom, default_bom, is_sub_contracted_item, stock_uom, default_bom,
last_purchase_rate, standard_rate, is_manufactured_item last_purchase_rate, standard_rate, is_manufactured_item
from `tabItem` where item_code = %s""", item_code, as_dict = 1) from `tabItem` where item_code = %s""", item_code, as_dict = 1)
@ -50,27 +50,13 @@ class DocType:
def get_item_detail(self, item_code): def get_item_detail(self, item_code):
""" Get stock uom and description for finished good item""" return { 'uom' : webnotes.conn.get_value("Item", item_code, "stock_uom")}
item = self.get_item_det(item_code)
ret={
'description' : item and item[0]['description'] or '',
'uom' : item and item[0]['stock_uom'] or ''
}
return ret
def get_workstation_details(self,workstation): def get_workstation_details(self,workstation):
""" Fetch hour rate from workstation master""" return {'hour_rate': webnotes.conn.get_value("Workstation", workstation, "hour_rate")}
ws = sql("select hour_rate from `tabWorkstation` where name = %s",
workstation , as_dict = 1)
return {'hour_rate' : ws and flt(ws[0]['hour_rate']) or ''}
def validate_rm_item(self, item): def validate_rm_item(self, item):
""" Validate raw material items"""
if item[0]['name'] == self.doc.item: if item[0]['name'] == self.doc.item:
msgprint("Item_code: %s in materials tab cannot be same as FG Item", msgprint("Item_code: %s in materials tab cannot be same as FG Item",
item[0]['name'], raise_exception=1) item[0]['name'], raise_exception=1)
@ -130,7 +116,6 @@ class DocType:
as per valuation method (MAR/FIFO) as per valuation method (MAR/FIFO)
as on costing date as on costing date
""" """
dt = self.doc.costing_date or nowdate() dt = self.doc.costing_date or nowdate()
time = self.doc.costing_date == nowdate() and now().split()[1] or '23:59' time = self.doc.costing_date == nowdate() and now().split()[1] or '23:59'
warehouse = sql("select warehouse from `tabBin` where item_code = %s", arg['item_code']) warehouse = sql("select warehouse from `tabBin` where item_code = %s", arg['item_code'])

View File

@ -2,9 +2,9 @@
{ {
"owner": "Administrator", "owner": "Administrator",
"docstatus": 0, "docstatus": 0,
"creation": "2012-12-10 19:03:43", "creation": "2012-12-12 10:17:41",
"modified_by": "Administrator", "modified_by": "Administrator",
"modified": "2012-12-11 15:13:42" "modified": "2012-12-13 11:43:11"
}, },
{ {
"istable": 0, "istable": 0,
@ -68,6 +68,7 @@
}, },
{ {
"description": "Total quantity of items for which raw materials required and operations done will be defined", "description": "Total quantity of items for which raw materials required and operations done will be defined",
"default": "1",
"oldfieldtype": "Currency", "oldfieldtype": "Currency",
"doctype": "DocField", "doctype": "DocField",
"label": "Quantity", "label": "Quantity",
@ -77,6 +78,14 @@
"reqd": 1, "reqd": 1,
"permlevel": 0 "permlevel": 0
}, },
{
"doctype": "DocField",
"label": "Item UOM",
"options": "link:UOM",
"fieldname": "uom",
"fieldtype": "Select",
"permlevel": 1
},
{ {
"doctype": "DocField", "doctype": "DocField",
"width": "50%", "width": "50%",
@ -85,13 +94,14 @@
"permlevel": 0 "permlevel": 0
}, },
{ {
"permlevel": 0,
"no_copy": 1, "no_copy": 1,
"oldfieldtype": "Select", "oldfieldtype": "Select",
"allow_on_submit": 1, "allow_on_submit": 1,
"doctype": "DocField", "doctype": "DocField",
"label": "Is Active", "label": "Is Active",
"oldfieldname": "is_active", "oldfieldname": "is_active",
"permlevel": 0, "default": "Yes",
"fieldname": "is_active", "fieldname": "is_active",
"fieldtype": "Select", "fieldtype": "Select",
"reqd": 1, "reqd": 1,
@ -203,30 +213,6 @@
"permlevel": 0, "permlevel": 0,
"in_filter": 1 "in_filter": 1
}, },
{
"doctype": "DocField",
"label": "Item UOM",
"options": "link:UOM",
"fieldname": "uom",
"fieldtype": "Select",
"permlevel": 1
},
{
"oldfieldtype": "Text",
"doctype": "DocField",
"label": "Item Description",
"oldfieldname": "description",
"width": "300px",
"fieldname": "description",
"fieldtype": "Small Text",
"permlevel": 0
},
{
"doctype": "DocField",
"fieldname": "col_break23",
"fieldtype": "Column Break",
"permlevel": 0
},
{ {
"oldfieldtype": "Data", "oldfieldtype": "Data",
"doctype": "DocField", "doctype": "DocField",
@ -236,6 +222,12 @@
"fieldtype": "Data", "fieldtype": "Data",
"permlevel": 0 "permlevel": 0
}, },
{
"doctype": "DocField",
"fieldname": "col_break23",
"fieldtype": "Column Break",
"permlevel": 0
},
{ {
"print_hide": 1, "print_hide": 1,
"no_copy": 1, "no_copy": 1,
@ -270,7 +262,7 @@
{ {
"print_hide": 0, "print_hide": 0,
"doctype": "DocField", "doctype": "DocField",
"label": "Exploded BOM Items", "label": "BOM Explosion Items",
"options": "Simple", "options": "Simple",
"fieldname": "section_break0", "fieldname": "section_break0",
"fieldtype": "Section Break", "fieldtype": "Section Break",
@ -283,7 +275,7 @@
"no_copy": 1, "no_copy": 1,
"oldfieldtype": "Table", "oldfieldtype": "Table",
"doctype": "DocField", "doctype": "DocField",
"label": "Exploded BOM Items", "label": "BOM Explosion Item",
"oldfieldname": "flat_bom_details", "oldfieldname": "flat_bom_details",
"default": "No Toolbar", "default": "No Toolbar",
"fieldname": "flat_bom_details", "fieldname": "flat_bom_details",