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

View File

@ -42,7 +42,7 @@ class DocType:
def get_item_det(self, item_code):
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
from `tabItem` where item_code = %s""", item_code, as_dict = 1)
@ -50,27 +50,13 @@ class DocType:
def get_item_detail(self, item_code):
""" Get stock uom and description for finished good item"""
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
return { 'uom' : webnotes.conn.get_value("Item", item_code, "stock_uom")}
def get_workstation_details(self,workstation):
""" Fetch hour rate from workstation master"""
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 ''}
return {'hour_rate': webnotes.conn.get_value("Workstation", workstation, "hour_rate")}
def validate_rm_item(self, item):
""" Validate raw material items"""
if item[0]['name'] == self.doc.item:
msgprint("Item_code: %s in materials tab cannot be same as FG Item",
item[0]['name'], raise_exception=1)
@ -130,7 +116,6 @@ class DocType:
as per valuation method (MAR/FIFO)
as on costing date
"""
dt = self.doc.costing_date or nowdate()
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'])

View File

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