Merge pull request #2488 from neilLasrado/bom-currency-fix

Bom Currency Fix
diff --git a/erpnext/manufacturing/doctype/bom/bom.json b/erpnext/manufacturing/doctype/bom/bom.json
index c236caf..1368e2e 100644
--- a/erpnext/manufacturing/doctype/bom/bom.json
+++ b/erpnext/manufacturing/doctype/bom/bom.json
@@ -129,15 +129,17 @@
   }, 
   {
    "fieldname": "raw_material_cost", 
-   "fieldtype": "Float", 
+   "fieldtype": "Currency", 
    "label": "Total Raw Material Cost", 
+   "options": "Company:company:default_currency", 
    "permlevel": 0, 
    "read_only": 1
   }, 
   {
    "fieldname": "operating_cost", 
-   "fieldtype": "Float", 
+   "fieldtype": "Currency", 
    "label": "Total Operating Cost", 
+   "options": "Company:company:default_currency", 
    "permlevel": 0, 
    "read_only": 1
   }, 
@@ -148,23 +150,26 @@
   }, 
   {
    "fieldname": "total_variable_cost", 
-   "fieldtype": "Float", 
+   "fieldtype": "Currency", 
    "in_list_view": 1, 
    "label": "Total Variable Cost", 
+   "options": "Company:company:default_currency", 
    "permlevel": 0, 
    "read_only": 1
   }, 
   {
    "fieldname": "total_fixed_cost", 
-   "fieldtype": "Float", 
+   "fieldtype": "Currency", 
    "label": "Total Fixed Cost", 
+   "options": "Company:company:default_currency", 
    "permlevel": 0, 
    "read_only": 1
   }, 
   {
    "fieldname": "total_cost", 
-   "fieldtype": "Float", 
+   "fieldtype": "Currency", 
    "label": "Total Cost", 
+   "options": "Company:company:default_currency", 
    "permlevel": 0, 
    "read_only": 1
   }, 
@@ -185,6 +190,14 @@
    "permlevel": 0
   }, 
   {
+   "fieldname": "company", 
+   "fieldtype": "Link", 
+   "label": "Company", 
+   "options": "company", 
+   "permlevel": 0, 
+   "precision": ""
+  }, 
+  {
    "fieldname": "amended_from", 
    "fieldtype": "Link", 
    "ignore_user_permissions": 1, 
@@ -247,7 +260,7 @@
  "is_submittable": 1, 
  "issingle": 0, 
  "istable": 0, 
- "modified": "2014-12-04 12:37:39.710211", 
+ "modified": "2014-12-12 11:13:12.146205", 
  "modified_by": "Administrator", 
  "module": "Manufacturing", 
  "name": "BOM", 
diff --git a/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.json b/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.json
index 6465e6a..58b505d 100644
--- a/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.json
+++ b/erpnext/manufacturing/doctype/bom_explosion_item/bom_explosion_item.json
@@ -1,6 +1,6 @@
 {
  "autoname": "FBD/.######", 
- "creation": "2013-03-07 11:42:57.000000", 
+ "creation": "2013-03-07 11:42:57", 
  "default_print_format": "Standard", 
  "docstatus": 0, 
  "doctype": "DocType", 
@@ -40,21 +40,23 @@
   }, 
   {
    "fieldname": "rate", 
-   "fieldtype": "Float", 
+   "fieldtype": "Currency", 
    "in_list_view": 1, 
    "label": "Rate", 
    "oldfieldname": "standard_rate", 
    "oldfieldtype": "Currency", 
+   "options": "Company:company:default_currency", 
    "permlevel": 0, 
    "read_only": 1
   }, 
   {
    "fieldname": "amount", 
-   "fieldtype": "Float", 
+   "fieldtype": "Currency", 
    "in_list_view": 1, 
    "label": "Amount", 
    "oldfieldname": "amount_as_per_sr", 
    "oldfieldtype": "Currency", 
+   "options": "Company:company:default_currency", 
    "permlevel": 0, 
    "read_only": 1
   }, 
@@ -82,10 +84,11 @@
  ], 
  "idx": 1, 
  "istable": 1, 
- "modified": "2013-12-20 19:22:57.000000", 
+ "modified": "2014-12-12 11:18:01.745641", 
  "modified_by": "Administrator", 
  "module": "Manufacturing", 
  "name": "BOM Explosion Item", 
  "owner": "Administrator", 
+ "permissions": [], 
  "read_only": 0
 }
\ No newline at end of file
diff --git a/erpnext/manufacturing/doctype/bom_item/bom_item.json b/erpnext/manufacturing/doctype/bom_item/bom_item.json
index 0231a70..39ceaa7 100644
--- a/erpnext/manufacturing/doctype/bom_item/bom_item.json
+++ b/erpnext/manufacturing/doctype/bom_item/bom_item.json
@@ -76,9 +76,10 @@
   {
    "description": "See \"Rate Of Materials Based On\" in Costing Section", 
    "fieldname": "rate", 
-   "fieldtype": "Float", 
+   "fieldtype": "Currency", 
    "in_list_view": 1, 
    "label": "Rate", 
+   "options": "Company:company:default_currency", 
    "permlevel": 0, 
    "reqd": 1
   }, 
@@ -101,11 +102,12 @@
   }, 
   {
    "fieldname": "amount", 
-   "fieldtype": "Float", 
+   "fieldtype": "Currency", 
    "in_list_view": 1, 
    "label": "Amount", 
    "oldfieldname": "amount_as_per_mar", 
    "oldfieldtype": "Currency", 
+   "options": "Company:company:default_currency", 
    "permlevel": 0, 
    "print_width": "150px", 
    "read_only": 1, 
@@ -134,7 +136,7 @@
  ], 
  "idx": 1, 
  "istable": 1, 
- "modified": "2014-05-29 15:56:31.859868", 
+ "modified": "2014-12-12 11:15:43.798755", 
  "modified_by": "Administrator", 
  "module": "Manufacturing", 
  "name": "BOM Item", 
diff --git a/erpnext/manufacturing/doctype/bom_operation/bom_operation.json b/erpnext/manufacturing/doctype/bom_operation/bom_operation.json
index 3b1b07b..d4dd958 100644
--- a/erpnext/manufacturing/doctype/bom_operation/bom_operation.json
+++ b/erpnext/manufacturing/doctype/bom_operation/bom_operation.json
@@ -1,89 +1,92 @@
 {
- "creation": "2013-02-22 01:27:49",
- "docstatus": 0,
- "doctype": "DocType",
+ "creation": "2013-02-22 01:27:49", 
+ "docstatus": 0, 
+ "doctype": "DocType", 
  "fields": [
   {
-   "fieldname": "operation_no",
-   "fieldtype": "Data",
-   "in_list_view": 1,
-   "label": "Operation No",
-   "oldfieldname": "operation_no",
-   "oldfieldtype": "Data",
-   "permlevel": 0,
+   "fieldname": "operation_no", 
+   "fieldtype": "Data", 
+   "in_list_view": 1, 
+   "label": "Operation No", 
+   "oldfieldname": "operation_no", 
+   "oldfieldtype": "Data", 
+   "permlevel": 0, 
    "reqd": 1
-  },
+  }, 
   {
-   "fieldname": "opn_description",
-   "fieldtype": "Text",
-   "in_list_view": 1,
-   "label": "Operation Description",
-   "oldfieldname": "opn_description",
-   "oldfieldtype": "Text",
-   "permlevel": 0,
+   "fieldname": "opn_description", 
+   "fieldtype": "Text", 
+   "in_list_view": 1, 
+   "label": "Operation Description", 
+   "oldfieldname": "opn_description", 
+   "oldfieldtype": "Text", 
+   "permlevel": 0, 
    "reqd": 1
-  },
+  }, 
   {
-   "fieldname": "col_break1",
-   "fieldtype": "Column Break",
+   "fieldname": "col_break1", 
+   "fieldtype": "Column Break", 
    "permlevel": 0
-  },
+  }, 
   {
-   "fieldname": "workstation",
-   "fieldtype": "Link",
-   "in_list_view": 1,
-   "label": "Workstation",
-   "oldfieldname": "workstation",
-   "oldfieldtype": "Link",
-   "options": "Workstation",
-   "permlevel": 0,
+   "fieldname": "workstation", 
+   "fieldtype": "Link", 
+   "in_list_view": 1, 
+   "label": "Workstation", 
+   "oldfieldname": "workstation", 
+   "oldfieldtype": "Link", 
+   "options": "Workstation", 
+   "permlevel": 0, 
    "reqd": 0
-  },
+  }, 
   {
-   "fieldname": "hour_rate",
-   "fieldtype": "Float",
-   "in_list_view": 0,
-   "label": "Hour Rate",
-   "oldfieldname": "hour_rate",
-   "oldfieldtype": "Currency",
-   "permlevel": 0,
+   "fieldname": "hour_rate", 
+   "fieldtype": "Currency", 
+   "in_list_view": 0, 
+   "label": "Hour Rate", 
+   "oldfieldname": "hour_rate", 
+   "oldfieldtype": "Currency", 
+   "options": "Company:company:default_currency", 
+   "permlevel": 0, 
    "reqd": 0
-  },
+  }, 
   {
-   "fieldname": "time_in_mins",
-   "fieldtype": "Float",
-   "in_list_view": 0,
-   "label": "Operation Time (mins)",
-   "oldfieldname": "time_in_mins",
-   "oldfieldtype": "Currency",
-   "permlevel": 0,
+   "fieldname": "time_in_mins", 
+   "fieldtype": "Float", 
+   "in_list_view": 0, 
+   "label": "Operation Time (mins)", 
+   "oldfieldname": "time_in_mins", 
+   "oldfieldtype": "Currency", 
+   "permlevel": 0, 
    "reqd": 0
-  },
+  }, 
   {
-   "allow_on_submit": 0,
-   "fieldname": "operating_cost",
-   "fieldtype": "Float",
-   "in_list_view": 1,
-   "label": "Operating Cost",
-   "oldfieldname": "operating_cost",
-   "oldfieldtype": "Currency",
-   "permlevel": 0,
+   "allow_on_submit": 0, 
+   "fieldname": "operating_cost", 
+   "fieldtype": "Currency", 
+   "in_list_view": 1, 
+   "label": "Operating Cost", 
+   "oldfieldname": "operating_cost", 
+   "oldfieldtype": "Currency", 
+   "options": "Company:company:default_currency", 
+   "permlevel": 0, 
    "reqd": 0
-  },
+  }, 
   {
-   "fieldname": "fixed_cycle_cost",
-   "fieldtype": "Float",
-   "in_list_view": 0,
-   "label": "Fixed Cycle Cost",
+   "fieldname": "fixed_cycle_cost", 
+   "fieldtype": "Currency", 
+   "in_list_view": 0, 
+   "label": "Fixed Cycle Cost", 
+   "options": "Company:company:default_currency", 
    "permlevel": 0
   }
- ],
- "idx": 1,
- "istable": 1,
- "modified": "2014-09-15 12:03:47.456370",
- "modified_by": "Administrator",
- "module": "Manufacturing",
- "name": "BOM Operation",
- "owner": "Administrator",
+ ], 
+ "idx": 1, 
+ "istable": 1, 
+ "modified": "2014-12-12 11:16:49.031521", 
+ "modified_by": "Administrator", 
+ "module": "Manufacturing", 
+ "name": "BOM Operation", 
+ "owner": "Administrator", 
  "permissions": []
-}
+}
\ No newline at end of file
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 2558d18..a81527e 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -97,3 +97,4 @@
 execute:frappe.reload_doc('stock', 'doctype', 'item')
 execute:frappe.db.sql("update `tabItem` i set apply_warehouse_wise_reorder_level=1, re_order_level=0, re_order_qty=0 where exists(select name from `tabItem Reorder` where parent=i.name)")
 execute:frappe.rename_doc("DocType", "Support Ticket", "Issue", force=True)
+erpnext.patches.v5_0.set_default_company_in_bom
diff --git a/erpnext/patches/v5_0/set_default_company_in_bom.py b/erpnext/patches/v5_0/set_default_company_in_bom.py
new file mode 100644
index 0000000..e5dc86c
--- /dev/null
+++ b/erpnext/patches/v5_0/set_default_company_in_bom.py
@@ -0,0 +1,8 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+import frappe
+
+def execute():
+	company = frappe.db.get_value("Global Defaults", None, "default_company")
+	frappe.db.sql("""update  `tabBOM` set company = %s""",company)