fixes in production, porjects, packing slip
diff --git a/erpnext/patches/jan_mar_2012/sync_ref_db.py b/erpnext/patches/jan_mar_2012/sync_ref_db.py
index a86bb3f..efdacf2 100644
--- a/erpnext/patches/jan_mar_2012/sync_ref_db.py
+++ b/erpnext/patches/jan_mar_2012/sync_ref_db.py
@@ -20,7 +20,7 @@
 			'Invest 80 Declaration Detail', 'IT Checklist', 'Chapter VI A Detail', 'Declaration Detail',
 			'Personalize', 'Salary Slip Control Panel',
 			],
-		'Page'		:	['File Browser'],
+		'Page'		:	['File Browser', 'Bill of Materials'],
 		'DocType Mapper': ['Production Forecast-Production Planning Tool', 'Production Forecast-Production Plan', 'Sales Order-Production Plan']
 	}
 
diff --git a/erpnext/production/page/bill_of_materials/__init__.py b/erpnext/production/page/bill_of_materials/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/erpnext/production/page/bill_of_materials/__init__.py
+++ /dev/null
diff --git a/erpnext/production/page/bill_of_materials/bill_of_materials.html b/erpnext/production/page/bill_of_materials/bill_of_materials.html
deleted file mode 100644
index 55b4e70..0000000
--- a/erpnext/production/page/bill_of_materials/bill_of_materials.html
+++ /dev/null
@@ -1,44 +0,0 @@
-<div class="layout_wrapper">
-<div id="bom_header">&nbsp;</div>
-<!--
-<div style="color: #444444;" mce_style="color: #444444;">
-<table style="width: 100%;" border="0">
-<tbody>
-<tr>
-<td class="standard_title" style="width: 70%;">Bill of Materials</td>
-<td style="width: 30%; text-align: right; vertical-align: top;"><span class="link_type" style="vertical-align:top" mce_style="vertical-align:top"> <img style="cursor:pointer" mce_style="cursor:pointer" onclick="nav_obj.show_last_open()" src="images/ui/close_btn.gif" mce_src="images/ui/close_btn.gif" alt="" /> </span></td>
-</tr>
-</tbody>
-</table>
-</div>
---> <!--  table.coa_toolbar td {  	vertical-align: middle;  }  --> <!--
-<div style="margin-top: 16px; padding: 4px; background-color: #EEE; border: 1px solid #AAA;" mce_style="margin-top: 16px; padding: 4px; background-color: #EEE; border: 1px solid #AAA;">
-<table class="coa_toolbar" border="0" cellspacing="2px">
-<tbody>
-<tr>
-<td>Item Group:</td>
-<td style="padding-right: 8px;" mce_style="padding-right: 8px;"><select id="bom_item_group"></select></td>
-<td>Enter Item Code:</td>
-<td style="padding-right: 8px;" mce_style="padding-right: 8px;"><select id="bom_item_code"></select></td>
-<td>Enter BOM No:</td>
-<td style="padding-right: 8px;" mce_style="padding-right: 8px;"><select id="bom_bom_no"></select></td>
-<td>
-<div id="bom_refresh"></div>
-</td>
-<td>
-<div id="bom_calculate_cost"></div>
-</td>
-</tr>
-</tbody>
-</table>
-</div>
---> <!--
-<div style="margin: 0px 16px 16px; overflow: auto; padding-top: 4px; height: 300px;">-->
-<div style="overflow: auto; margin-top: 8px; padding-top: 4px; height: 300px;">
-<div style="width: 900px;">
-<div id="bom_head_op" style="display: none;"></div>
-<div id="bom_head_it" style="display: none; border-bottom: 2px solid #444;"></div>
-<div id="bom_tree"></div>
-</div>
-</div>
-</div>
\ No newline at end of file
diff --git a/erpnext/production/page/bill_of_materials/bill_of_materials.js b/erpnext/production/page/bill_of_materials/bill_of_materials.js
deleted file mode 100644
index 7fcd6aa..0000000
--- a/erpnext/production/page/bill_of_materials/bill_of_materials.js
+++ /dev/null
@@ -1,524 +0,0 @@
-// ERPNext - web based ERP (http://erpnext.com)
-// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
-// 
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-// 
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-pscript['onload_Bill of Materials'] = function() {
-	wn.require('lib/js/legacy/widgets/tree.js');
-	
-	// header and toolbar
-	var h = new PageHeader('bom_header','Bill of Materials','BOM gives the breakdown of cost for product');
-	
-	var dv = $a(h.toolbar_area,'div','',{margin:'4px 0px'});
-	
-	var tbl = make_table(dv, 1,3,'480px',[],{padding:'4px', width:'160px'});
-	
-	var sel = $a($td(tbl,0,0),'select','',{width:'160px'});
-	sel.id = 'bom_item_group';
-	
-	var sel = $a($td(tbl,0,1),'select','',{width:'160px'});
-	sel.id = 'bom_item_code'; sel.innerHTML = 'Select Item Code...'; sel.disabled = 1;
-	
-	var sel = $a($td(tbl,0,2),'select','',{width:'160px'});
-	sel.id = 'bom_bom_no'; sel.innerHTML = 'Select Bom No...'; sel.disabled = 1;
-	
-	h.add_button('Calculate Cost', function(){ pscript.bom_calculate_cost(pscript.bom_no); },1,'ui-icon-calculator');
-	h.add_button('Refresh', function(){ pscript.bom_refresh(); },0,'ui-icon-refresh');
-        h.add_button('Collapse All', function(){pscript.collapse_all();},0,'');
-	
-  // select for Item Group
-    //$i('bom_item_group').style.width = '180px';
-   // $i('bom_item_code').style.width = '110px';
-   // $i('bom_bom_no').style.width = '150px';
-    $i('bom_tree').innerHTML = 'Please Select Item Group';
-    add_sel_options($i('bom_item_group'), ['Loading ...    ']);
-
-    $c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_item_group'}, function(r,rt) {
-      pscript.item_group = r.message.split('~~~');
-      empty_select($i('bom_item_group'));
-//      add_sel_options($i('bom_item_group'), add_lists([' '], pscript.item_group), ' ');
-      add_sel_options($i('bom_item_group'), add_lists(['Select Item Group...'], pscript.item_group), 'Select Item Group...');
-      $i('bom_item_group').onchange = function() {
-		
-         //$i('bom_item_code').innerHTML = '';
-        // $i('bom_bom_no').innerHTML = '';
-         $i('bom_head_op').innerHTML = '';
-         $i('bom_head_it').innerHTML = '';
-         $i('bom_tree').innerHTML = 'Please Select Item Code';
-         pscript.bom_select_item_code(sel_val(this)); 
-      }
-    });	
-}
-
-pscript.bom_select_item_code = function(item_group) {
-
-  //select for Item Code	
-
-    add_sel_options($i('bom_item_code'), ['Loading ... ']);
-
-    $c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_item_code', 'arg':item_group}, function(r,rt) {
-      pscript.item_code = r.message.split('~~~');
-      empty_select($i('bom_item_code'));
-      add_sel_options($i('bom_item_code'), add_lists(['Select Item Code...'], pscript.item_code), 'Select Item Code...');
-	  if(sel_val($i('bom_item_code')) == 'Select Item Group...'){
-		$i('bom_item_code').disabled = 1;
-		$i('bom_bom_no').disabled = 1;
-	  }
-	  else{ $i('bom_item_code').disabled = 0; }
-	  
-      $i('bom_item_code').onchange = function() {
-        // $i('bom_bom_no').innerHTML = '';
-         $i('bom_head_op').innerHTML = '';
-         $i('bom_head_it').innerHTML = '';
-         $i('bom_tree').innerHTML = 'Please Select BOM NO.'; 
-         pscript.bom_select_bom_no(sel_val(this));
-      }
-    });	
-  
-}
-
-pscript.bom_select_bom_no = function(item_code) {
-
-  //select for BOM NO
-    
-    add_sel_options($i('bom_bom_no'), ['Loading ...     ']);
-	
-    $c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_bom_no', 'arg':item_code}, function(r,rt) {
-      var bom_list = r.message.split('~~~');
-      empty_select($i('bom_bom_no'));
-	  empty_select($i('bom_bom_no'));
-      add_sel_options($i('bom_bom_no'), add_lists(['Select Bom No...'], bom_list), 'Select Bom No...');
-	  if(sel_val($i('bom_item_code')) == 'Select Item Code...'){
-		$i('bom_bom_no').disabled = 1;
-	  }
-	  else{
-		$i('bom_bom_no').disabled = 0;
-	  }
-	  
-      $i('bom_bom_no').onchange = function() { 
-         $i('bom_head_op').innerHTML = '';
-         $i('bom_head_it').innerHTML = '';
-         $i('bom_tree').innerHTML = 'Loading...';
-         pscript.show_bom(); }
-    });	
-}
-
-// Refresh Function
-pscript.bom_refresh = function() {
-  $i('bom_head_op').innerHTML = '';
-  $i('bom_head_it').innerHTML = '';
-  $i('bom_tree').innerHTML = 'Refreshing....';
-  pscript.show_bom();
-}
-
-//Calculate Cost Function
-pscript.bom_calculate_cost = function() {
-  $i('bom_head_op').innerHTML = '';
-  $i('bom_head_it').innerHTML = '';
-  $i('bom_tree').innerHTML = ' Calculating Cost...';
-  $c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'calculate_cost', 'arg':pscript.bom_no}, function(r,rt) {
-      var calculated = r.message;
-      if (calculated == 'calculated') {pscript.show_bom();}
-      else  {$i('bom_tree').innerHTML = "Not available";}
-  });	
-}
-
-pscript.collapse_all = function(){
-  pscript.bom_tree.collapseall()
-}
-
-pscript.show_bom = function () {
-  pscript.item_code = $i('bom_item_code').value;
-  pscript.bom_no = $i('bom_bom_no').value;
- // $i('bom_refresh').innerHTML = '';
-  //$i('bom_refresh').innerHTML = "<input type='button' value='Refresh' onClick='javascript:pscript.bom_refresh()' />";
-  //$i('bom_calculate_cost').innerHTML = "<input type='button' value='Calculate Cost' onClick='javascript:pscript.bom_calculate_cost(pscript.bom_no)' />";
-  if (pscript.item_code == "") {
-    alert("Please Enter Item Code");
-    return;
-  }
-  if (pscript.bom_no == "") {
-    alert("Please Enter BOM No");
-    return;
-  }
-  $ds('bom_head_op');
-  $ds('bom_head_it');
-  $ds('bom_tree');
-  pscript.bom_onexp = function(node) {
-    //alert("Server Call")
-    if(!node.expanded_once) {
-      $ds(node.loading_div);
-      if (!node.is_item){
-        // We will get List Of Items and BOM for particular Operation
-        data = "{'op_no':'" + node.text[1] +"','bom_no':'" + node.text[3] +"'}";
-        $c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_item_bom', 'arg':data}, 
-        function(r,rt) {
-          $dh(node.loading_div);
-          var nl = r.message;
-          for(var i=0; i<nl.length; i++) {
-            if (nl[i][8] == 1) {
-              pscript.bom_tree.addNode(node,$i('bom_head_op'), nl[i], 'images/icons/box.png', null, null);
-            }
-            else {
-              pscript.bom_tree.addNode(node,$i('bom_head_op'), nl[i], 'images/icons/package.png', null, pscript.bom_onexp);
-            }
-         }
-        });
-      } else {
-        //alert("bom_no:%s"%node.text[2])
-        //We will get List Of Operations for particular Item and BOM
-        $c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_operations', 'arg':node.text[3]},
-          function(r,rt) {
-            $dh(node.loading_div);
-            var nl = r.message;
-            for(var i=0; i<nl.length; i++) {
-              pscript.bom_tree.addNode(node, $i('bom_head_op'), nl[i], 'images/icons/folder.png', null, pscript.bom_onexp);
-            }
-          }
-        );
-      }
-    }
-  }
-  // First this function will execute and we will get list of operations
-  $c('runserverobj', args={'doctype':'BOM Control', 'docname':'BOM Control', 'method':'get_operations', 'arg':pscript.bom_no}, function(r,rt) {
-    var nl = r.message;
-    
-    $i('bom_tree').innerHTML = '';
-    var t = new Tree($i('bom_tree'),$i('bom_head_op'),$i('bom_head_it'));
-
-    pscript.bom_tree = t;
-    pscript.bom_curnode = null;
-
-    for(var i=0; i<nl.length; i++) {
-      t.addNode(null, $i('bom_head_op'), nl[i], 'images/icons/folder.png', null, pscript.bom_onexp);
-    }
-  });    
-}
-
-
-//
-// Tree
-//
-
-function Tree(parent,head_op,head_it) {
-  this.container = parent;
-  this.heading = head_op;
-  this.nodes = {};
-  this.all_nodes = [];
-  
-  var me = this;
-  
-  this.body = $a(parent, 'div');
-  this.hopbody = $a(head_op, 'div');
-  this.hitbody = $a(head_it, 'div');
-
-  // columns
-  this.col_details = [
-     ['340px','Opn No', 'Opn Descr','Item Code', 'Description',1,2]
-    ,['150px','BOM' , 'BOM', 3]
-    ,['80px', 'Workstn', 'Qty', 4]
-    ,['45px', 'Hr Rate','Stock UOM',5]
-    ,['45px', 'Time','Scrap',6]
-    ,['50px', 'Mat Cost','Rate',7]
-    ,['45px', 'Op Cost','',8]
-    ,['50px', 'Tot Cost','',9]
-    ,['25px', 'Refresh']
-  ]
-  
-  // Operation  header
-  this.hopbody_tab = $a(this.hopbody, 'table');
-  $y(this.hopbody_tab, {borderCollapse:'collapse', tableLayout:'fixed'})
-  
-  var r0 = this.hopbody_tab.insertRow(0);
-  for(var i=0; i<this.col_details.length; i++) {
-    var c = r0.insertCell(i);
-    c.style.width = this.col_details[i][0];
-    c.style.padding = '2px';
-    c.style.border = '1px solid #DDD';
-   if (i > 0 && this.col_details[i][1] != 'Refresh') c.innerHTML = this.col_details[i][1];
-  }
-  this.hopbody_label = $a(r0.cells[0], 'div');
-  var hopbody_nodetab = $a(this.hopbody_label, 'table');
-  $y(hopbody_nodetab, {borderCollapse:'collapse', tableLayout:'fixed'})
-  
-  var r0 = hopbody_nodetab.insertRow(0);
-  var c = r0.insertCell(0); c.style.width = '16px';  
-  var c = r0.insertCell(1); c.style.width = '20px'; c.innerHTML = "<img src='images/icons/wrench.png' />";
-  var c = r0.insertCell(2); c.style.width = '80px'; c.innerHTML = this.col_details[0][1];
-  l=340-116;
-  var c = r0.insertCell(3); c.style.width = l+'px'; c.innerHTML = this.col_details[0][2];
-  
-  // Item Header
-  this.hitbody_tab = $a(this.hitbody, 'table');
-  $y(this.hitbody_tab, {borderCollapse:'collapse', tableLayout:'fixed'})
-  
-  var r0 = this.hitbody_tab.insertRow(0);
-  for(var i=0; i<this.col_details.length; i++) {
-    var c = r0.insertCell(i);
-    c.style.width = this.col_details[i][0];
-    c.style.padding = '2px';
-    c.style.border = '1px solid #DDD';
-	if (i > 0 && this.col_details[i][1] != 'Refresh') c.innerHTML = this.col_details[i][2];
-  }
-  this.hitbody_label = $a(r0.cells[0], 'div');
-  var hitbody_nodetab = $a(this.hitbody_label, 'table');
-  $y(hitbody_nodetab, {borderCollapse:'collapse', tableLayout:'fixed'})
-  
-  var r0 = hitbody_nodetab.insertRow(0);
-  var c = r0.insertCell(0); c.style.width = '16px'; 
-  var c = r0.insertCell(1); c.style.width = '20px'; c.innerHTML = "<img src='images/icons/package.png' />";
-  var c = r0.insertCell(2); c.style.width = '100px'; c.innerHTML = this.col_details[0][3];
-  l=350-136;
-  var c = r0.insertCell(3); c.style.width = l+'px'; c.innerHTML = this.col_details[0][4];
-  
-  this.addNode = function(parent, head_op, label, imagesrc, onclick, onexpand) {
-    var t = new TreeNode(me, parent, head_op, label, imagesrc, onclick, onexpand);
-   	if(!parent) {
-      me.nodes[label]=t; // add to roots
-    } else {
-      parent.nodes[label] = t; // add to the node
-    }
-    
-    this.all_nodes.push(t);
-		
-    // note: this will only be for groups
-    if(onexpand)t.create_expimage();
-    t.expanded_once = false;
-
-    return t;
-    
-  }
-  
-  this.deleteNode = function(node) {
-    node.container.remove(node);
-
-  }
-  var me = this;
-
-  this.collapseall = function() {
-    //alert("collapseall")
-    for(n in me.nodes) {
-      if (me.nodes[n].expimage){
-        l = me.nodes[n].get_list_of_child_nodes()  
-        for (var i=0; i < l.length; i++ )  l[i].collapse(l[i]);
-      }
-    }
-  }
-}
-
-function TreeNode(tree, parent, head_op, label, imagesrc, onclick, onexpand) {
-  
-  var me = this;
-  this.parent = parent;
-  this.head = head_op;
-  this.nodes = {};
-  this.onclick = onclick;
-  this.onexpand = onexpand;
-  this.text = label;
-
-  if(!parent) {
-    var container = tree.body; 
-  }
-  else {
-    var container = parent.body;
-  }
-  var h_container = tree.hopbody;
-  
-  var t = $a(container, "div");
-  var ht = $a(h_container, "div");
-
-  t.style.display = "none";
-  ht.style.display = "none";
- 
-  this.node_area = $a(t, "div");
-  this.node_area.style.cursor = 'pointer';
-    
-  this.loading_div = $a(container, "div");
-  this.loading_div.innerHTML = 'Loading...';
-  $dh(this.loading_div);
-
-  // main table
-  this.tab = $a(this.node_area, 'table');
-  $y(this.tab, {borderCollapse:'collapse', tableLayout:'fixed'})
-  
-  var r0 = this.tab.insertRow(0);
-  for(var i=0; i<tree.col_details.length; i++) {
-    var c = r0.insertCell(i);
-    c.style.width = tree.col_details[i][0];
-    c.style.padding = '2px';
-    c.style.border = '1px solid #DDD';
-  }
-  
-  this.label = $a(r0.cells[0], 'div');
-  
-  var m=0;
-  var tn = this;
-   
-  while(tn.parent){m+=16;tn=tn.parent;}
-  this.label.style.marginLeft = m+'px';
-  this.loading_div.style.marginLeft = m+40+'px';
-  var l = 350 - m;
-  this.body = $a(t, 'div'); // children will come here
-
-  // make the node
-  var nodetab = $a(this.label, 'table');
-  $y(nodetab, {borderCollapse:'collapse', tableLayout:'fixed'})
-  
-  var r0 = nodetab.insertRow(0);
-  var c = r0.insertCell(0); c.style.width = '16px';  
-  var c = r0.insertCell(1); c.style.width = '20px';
-  var c = r0.insertCell(2); c.style.width = '100px';
-  l=l-136;
-  
-  var c = r0.insertCell(3); c.style.width = l+'px';
-  // BOM - is it item or operation
-  this.is_item = 1;
-  if(label[0] == 'operation') {
-    this.is_item = 0;
-    imagesrc = 'images/icons/wrench.png';
-  }
-  
-  if(!imagesrc) imagesrc = "images/icons/folder.png";
-  this.usrimg = $a(nodetab.rows[0].cells[1], 'img');
-  this.usrimg.src = imagesrc;
-
-
-  //this.node_area.onmouseover = function() {this.style.backgroundColor = '#DEF';  }
-  //this.node_area.onmouseout = function() { this.style.backgroundColor = '#FFF';  }
-
-  this.create_expimage = function() {
-    if(!me.expimage) {
-      me.expimage = $a(nodetab.rows[0].cells[0], 'img');
-      me.expimage.style.marginTop = "3px";
-      me.expimage.src = "images/icons/plus.gif";
-      me.expimage.onclick = me.toggle;
-      me.expimage.node = me;
-    }
-  }
-  
-  this.get_list_of_child_nodes = function() {
-    var main_l = [];
-    for (n in me.nodes){
-      if(!me.expimage){}
-      else{
-        var l = [];
-        if (me.nodes[n].get_list_of_child_nodes()) l = me.nodes[n].get_list_of_child_nodes();
-        for(var i=0 ; i < l.length; i ++){
-          main_l.push(l[i]);
-        }
-        alert(1);
-        main_l.push(me.nodes[n]);
-        alert(2);
-      }
-    }
-    return main_l
-  }
-
- this.select = function() {
-    me.show_selected();
-    if(this.onclick)this.onclick(this);
-  }
-  this.show_selected = function() {
-    if(pscript.bom_curnode)pscript.bom_curnode.deselect();
-    me.tab.style.backgroundColor = '#DEF';
-    if(me.is_item == 1) tree.hitbody_tab.style.backgroundColor = '#DEF';
-    if(me.is_item == 0) tree.hopbody_tab.style.backgroundColor = '#DEF';
-    me.tab.style.fontWeight = 'bold';
-    pscript.bom_curnode = me;
-    $ds(me.refresh);
-  }
-
-  this.deselect = function() {
-    me.tab.style.fontWeight = 'normal';
-    pscript.bom_curnode=null;
-    me.tab.style.backgroundColor = '#FFF';
-    tree.hopbody_tab.style.backgroundColor = '#FFF';
-    tree.hitbody_tab.style.backgroundColor = '#FFF';
-    $dh(me.refresh);
-  }
-   
-
-  var expanded = 1;
-  this.toggle = function(node) {
-    //alert("toggle")
-    if(!me.expimage)return;
-    if(me.expanded)me.collapse(this.node);
-    else me.expand(this.node);
-  }
-  this.collapse = function(node) {
-    //alert("collapse")
-    if(!node.expimage)return;
-    node.body.style.display = 'none';
-    if(node.expimage.src)node.expimage.src = "images/icons/plus.gif";
-    node.expanded = 0;
-  }
-  this.expand = function(node) {
-    //alert("expand")
-    if(!node.expimage)return;
-    if(node.onexpand)node.onexpand(node);
-    node.body.style.display = 'block';
-    if(node.expimage.src)node.expimage.src = "images/icons/minus.gif";
-    node.expanded = 1;
-    node.expanded_once = 1;
-  }
-
-  // BOM - Set values
-  for(var i=0;i<tree.col_details.length; i++) {
-    if ( i == 0) {
-      if(this.is_item == 1) {
-        var c = $a( nodetab.rows[0].cells[2], 'span', 'link_type');
-        c.item_code = label[tree.col_details[i][5]]
-        c.onclick = function() { loaddoc("Item", this.item_code); }
-      }
-      if(this.is_item == 0) var c = nodetab.rows[0].cells[2];
-      var d = nodetab.rows[0].cells[3];
-      c.innerHTML = label[tree.col_details[i][5]];
-      d.innerHTML = label[tree.col_details[i][6]].substring(0,15) + '...';
-    }
-    if(i==1) {
-      var c = $a(this.tab.rows[0].cells[i], 'div', 'link_type', {overflow:'hidden', width:'100%'});
-      c.bom_no = label[tree.col_details[i][3]]
-      c.onclick = function() { loaddoc("BOM", this.bom_no); }
-      c.innerHTML = label[tree.col_details[i][3]];
-    }
-    if(this.is_item == 1 && i > 1 && i < 6) {
-      var c = this.tab.rows[0].cells[i];
-      c.innerHTML = label[tree.col_details[i][3]];
-    }
-    if(this.is_item == 0 && i > 1 && tree.col_details[i][1] != 'Refresh') {
-      var c = this.tab.rows[0].cells[i];
-      c.innerHTML = label[tree.col_details[i][3]];
-    }
-    if(tree.col_details[i][1] == 'Refresh') {
-      this.refresh = $a(this.tab.rows[0].cells[i], 'span', 'link_type');  
-      this.refresh.onclick = function() {
-        me.node = me
-        if(me.node.expanded_once){
-          me.node.body.innerHTML = '';
-          me.node.expanded_once = 0
-          me.expanded = 0
-          me.toggle();
-        }
-        else {me.toggle()}
-      }
-      this.refresh.innerHTML = "<img src='images/icons/page_refresh.gif' />"
-      $dh(this.refresh);
-    }
-  }
-
-  this.tab.onclick= function(e) { me.select(); }
-  this.tab.ondblclick = function(e) { me.select(); if(me.ondblclick)me.ondblclick(me); }
-  t.style.display = "block";
-  ht.style.display = "block";
-}
\ No newline at end of file
diff --git a/erpnext/production/page/bill_of_materials/bill_of_materials.txt b/erpnext/production/page/bill_of_materials/bill_of_materials.txt
deleted file mode 100644
index b66f706..0000000
--- a/erpnext/production/page/bill_of_materials/bill_of_materials.txt
+++ /dev/null
@@ -1,58 +0,0 @@
-# Page, Bill of Materials
-[
-
-	# These values are common in all dictionaries
-	{
-		'creation': '2010-10-12 15:19:31',
-		'docstatus': 0,
-		'modified': '2010-12-23 12:58:19',
-		'modified_by': 'Administrator',
-		'owner': 'Administrator'
-	},
-
-	# These values are common for all Page
-	{
-		'doctype': 'Page',
-		'module': 'Production',
-		'name': '__common__',
-		'page_name': 'Bill of Materials',
-		'show_in_menu': 1,
-		'standard': 'Yes'
-	},
-
-	# These values are common for all Page Role
-	{
-		'doctype': 'Page Role',
-		'name': '__common__',
-		'parent': 'Bill of Materials',
-		'parentfield': 'roles',
-		'parenttype': 'Page'
-	},
-
-	# Page, Bill of Materials
-	{
-		'doctype': 'Page',
-		'name': 'Bill of Materials'
-	},
-
-	# Page Role
-	{
-		'doctype': 'Page Role',
-		'idx': 1,
-		'role': 'Administrator'
-	},
-
-	# Page Role
-	{
-		'doctype': 'Page Role',
-		'idx': 2,
-		'role': 'Production User'
-	},
-
-	# Page Role
-	{
-		'doctype': 'Page Role',
-		'idx': 3,
-		'role': 'Production Manager'
-	}
-]
\ No newline at end of file
diff --git a/erpnext/production/page/production_home/production_home.html b/erpnext/production/page/production_home/production_home.html
index 77d8019..6cb2182 100644
--- a/erpnext/production/page/production_home/production_home.html
+++ b/erpnext/production/page/production_home/production_home.html
@@ -34,21 +34,6 @@
 					</div>
 				</div>
 			</div>
-			<div class="section">
-				<div class="section-head">Tools</div>
-				<div class="section-body">
-					<div class="section-item">
-						<a class="section-link" 
-							title = "browse bill of materials in a tree"
-							href="#!Bill of Materials">BOM Browser</a>
-					</div>
-					<div class="section-item">
-						<a class="section-link" 
-							title = "Update delivery dates in all Sales Orders"
-							href="#!Form/Update Delivery Date/Update Delivery Date">Update Delivery Dates</a>
-					</div>
-				</div>
-			</div>
 		</div>
 	</div>
 	<div style="clear: both;"></div>
diff --git a/erpnext/projects/page/projects/projects.js b/erpnext/projects/page/projects/projects.js
index cda9ec5..59b039a 100644
--- a/erpnext/projects/page/projects/projects.js
+++ b/erpnext/projects/page/projects/projects.js
@@ -74,7 +74,7 @@
 	var w = this.make_filter(label,idx);
 	var i = $a(w, 'input');
 
-	var user_fmt = wn.control_panel.date_format;
+	var user_fmt = wn.boot.sysdefaults.date_format;
 	if(!this.user_fmt)this.user_fmt = 'dd-mm-yy';
 
 	$(i).datepicker({
diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py
index 27c34a1..0527045 100644
--- a/erpnext/startup/event_handlers.py
+++ b/erpnext/startup/event_handlers.py
@@ -83,10 +83,6 @@
 			
 		bootinfo['user_background'] = webnotes.conn.get_value("Profile", webnotes.session['user'], 'background_image') or ''
 
-		import conf
-		bootinfo['sync_with_gateway'] = hasattr(conf, 'sync_with_gateway') and \
-				cint(conf.sync_with_gateway) or 0
-
 
 def get_letter_heads():
 	"""load letter heads with startup"""
@@ -117,4 +113,4 @@
 			# throw execption
 			webnotes.msgprint("Authentication Failed", raise_exception=1)
 
-	return login_manager
\ No newline at end of file
+	return login_manager
diff --git a/erpnext/startup/js/toolbar.js b/erpnext/startup/js/toolbar.js
index eb3bff8..891d60f 100644
--- a/erpnext/startup/js/toolbar.js
+++ b/erpnext/startup/js/toolbar.js
@@ -43,11 +43,6 @@
 	$('#toolbar-help').append('<li><a href="http://www.providesupport.com?messenger=iwebnotes" target="_blank">\
 		Live Chat (Office Hours)</a></li>')
 
-	// billing
-	if(pscript.is_erpnext_saas && is_system_manager) {
-		$('#toolbar-user').append('<li><a href="#billing">Billing</a></li>')
-	}
-
 	$.extend(wn.container.wntoolbar, {
 		set_new_comments: function(new_comments) {
 			var navbar_nc = $('.navbar-new-comments');
diff --git a/erpnext/startup/startup.js b/erpnext/startup/startup.js
index 456b1cf..442e7be 100644
--- a/erpnext/startup/startup.js
+++ b/erpnext/startup/startup.js
@@ -38,9 +38,12 @@
 	'Dashboard': 'dashboard'
 }
 
+// wn.modules is used in breadcrumbs for getting module home page
+wn.provide('wn.modules');
+$.extend(wn.modules, erpnext.modules);
+wn.modules['Core'] = 'Setup';
+
 erpnext.startup.set_globals = function() {
-	wn.control_panel.sync_with_gateway = wn.boot.sync_with_gateway
-	pscript.is_erpnext_saas = cint(wn.control_panel.sync_with_gateway)
 	if(inList(user_roles,'System Manager')) is_system_manager = 1;
 }
 
diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.js b/erpnext/stock/doctype/packing_slip/packing_slip.js
index 559f027..aea22ff 100644
--- a/erpnext/stock/doctype/packing_slip/packing_slip.js
+++ b/erpnext/stock/doctype/packing_slip/packing_slip.js
@@ -20,9 +20,12 @@
 
 
 cur_frm.fields_dict['item_details'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
-	return 'SELECT name, description FROM `tabItem` WHERE name IN ( \
+	console.log(doc.delivery_note);
+	var query = 'SELECT name, description FROM `tabItem` WHERE name IN ( \
 		SELECT item_code FROM `tabDelivery Note Item` dnd \
-		WHERE parent="'	+ doc.delivery_note + '" AND qty > packed_qty) AND %(key)s LIKE "%s" LIMIT 50';
+		WHERE parent="'	+ doc.delivery_note + '" AND IFNULL(qty, 0) > IFNULL(packed_qty, 0)) AND %(key)s LIKE "%s" LIMIT 50';
+	console.log(query);
+	return query;
 }
 
 
diff --git a/js/all-app.js b/js/all-app.js
index fe0efa9..4a7cdfe 100644
--- a/js/all-app.js
+++ b/js/all-app.js
@@ -486,7 +486,7 @@
  *	lib/js/legacy/utils/datatype.js
  */
 wn.utils.full_name=function(fn,ln){return fn+(ln?' ':'')+(ln?ln:'')}
-function fmt_money(v){if(v==null||v=='')return'0.00';v=(v+'').replace(/,/g,'');v=parseFloat(v);if(isNaN(v)){return'';}else{var cp=wn.control_panel;var val=2;if(cp.currency_format=='Millions')val=3;v=v.toFixed(2);var delimiter=",";amount=v+'';var a=amount.split('.',2)
+function fmt_money(v){if(v==null||v=='')return'0.00';v=(v+'').replace(/,/g,'');v=parseFloat(v);if(isNaN(v)){return'';}else{var val=2;if(wn.boot.sysdefaults.currency_format=='Millions')val=3;v=v.toFixed(2);var delimiter=",";amount=v+'';var a=amount.split('.',2)
 var d=a[1];var i=parseInt(a[0]);if(isNaN(i)){return'';}
 var minus='';if(v<0){minus='-';}
 i=Math.abs(i);var n=new String(i);var a=[];if(n.length>3)
@@ -1388,7 +1388,7 @@
  *	lib/js/wn/views/breadcrumbs.js
  */
 wn.provide('wn.views');wn.views.breadcrumbs=function(parent,module,doctype,name){$(parent).empty();var $bspan=$(repl('<span class="breadcrumbs">\
-  <a href="#%(home_page)s">Home</a></span>',{home_page:wn.boot.home_page}));if(module){$bspan.append(repl(' / <a href="#!%(module_page)s">%(module)s Home</a>',{module:module,module_page:erpnext.modules[module]}))}
+  <a href="#%(home_page)s">Home</a></span>',{home_page:wn.boot.home_page}));if(module&&wn.modules[module]){$bspan.append(repl(' / <a href="#!%(module_page)s">%(module)s Home</a>',{module:module,module_page:wn.modules[module]}))}
 if(doctype&&(locals.DocType[doctype]&&!locals.DocType[doctype].issingle)){$bspan.append(repl(' / <a href="#!List/%(doctype)s">%(doctype)s</a>',{doctype:doctype}))}
 if(name){$bspan.append(' / '+name.bold())}
 $bspan.appendTo(parent);}
@@ -2165,7 +2165,7 @@
  *	erpnext/startup/startup.js
  */
 var current_module;var is_system_manager=0;wn.provide('erpnext.startup');erpnext.modules={'Selling':'selling-home','Accounts':'accounts-home','Stock':'stock-home','Buying':'buying-home','Support':'support-home','Projects':'projects-home','Production':'production-home','Website':'website-home','HR':'hr-home','Setup':'Setup','Activity':'activity','To Do':'todo','Calendar':'calendar','Messages':'messages','Knowledge Base':'questions','Dashboard':'dashboard'}
-erpnext.startup.set_globals=function(){wn.control_panel.sync_with_gateway=wn.boot.sync_with_gateway
+wn.provide('wn.modules');$.extend(wn.modules,erpnext.modules);wn.modules['Core']='Setup';erpnext.startup.set_globals=function(){wn.control_panel.sync_with_gateway=wn.boot.sync_with_gateway
 pscript.is_erpnext_saas=cint(wn.control_panel.sync_with_gateway)
 if(inList(user_roles,'System Manager'))is_system_manager=1;}
 erpnext.startup.start=function(){$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);}
diff --git a/js/all-web.js b/js/all-web.js
index 1363d15..9991b87 100644
--- a/js/all-web.js
+++ b/js/all-web.js
@@ -373,7 +373,7 @@
  *	lib/js/legacy/utils/datatype.js
  */
 wn.utils.full_name=function(fn,ln){return fn+(ln?' ':'')+(ln?ln:'')}
-function fmt_money(v){if(v==null||v=='')return'0.00';v=(v+'').replace(/,/g,'');v=parseFloat(v);if(isNaN(v)){return'';}else{var cp=wn.control_panel;var val=2;if(cp.currency_format=='Millions')val=3;v=v.toFixed(2);var delimiter=",";amount=v+'';var a=amount.split('.',2)
+function fmt_money(v){if(v==null||v=='')return'0.00';v=(v+'').replace(/,/g,'');v=parseFloat(v);if(isNaN(v)){return'';}else{var val=2;if(wn.boot.sysdefaults.currency_format=='Millions')val=3;v=v.toFixed(2);var delimiter=",";amount=v+'';var a=amount.split('.',2)
 var d=a[1];var i=parseInt(a[0]);if(isNaN(i)){return'';}
 var minus='';if(v<0){minus='-';}
 i=Math.abs(i);var n=new String(i);var a=[];if(n.length>3)
@@ -864,7 +864,7 @@
  *	erpnext/startup/startup.js
  */
 var current_module;var is_system_manager=0;wn.provide('erpnext.startup');erpnext.modules={'Selling':'selling-home','Accounts':'accounts-home','Stock':'stock-home','Buying':'buying-home','Support':'support-home','Projects':'projects-home','Production':'production-home','Website':'website-home','HR':'hr-home','Setup':'Setup','Activity':'activity','To Do':'todo','Calendar':'calendar','Messages':'messages','Knowledge Base':'questions','Dashboard':'dashboard'}
-erpnext.startup.set_globals=function(){wn.control_panel.sync_with_gateway=wn.boot.sync_with_gateway
+wn.provide('wn.modules');$.extend(wn.modules,erpnext.modules);wn.modules['Core']='Setup';erpnext.startup.set_globals=function(){wn.control_panel.sync_with_gateway=wn.boot.sync_with_gateway
 pscript.is_erpnext_saas=cint(wn.control_panel.sync_with_gateway)
 if(inList(user_roles,'System Manager'))is_system_manager=1;}
 erpnext.startup.start=function(){$('#startup_div').html('Starting up...').toggle(true);erpnext.startup.set_globals();if(wn.boot.user_background){erpnext.set_user_background(wn.boot.user_background);}