Merge pull request #7756 from mlisb0n/master

[Translation] Revised and updated all translations to meet european portuguese business/accounting terminology
diff --git a/erpnext/__init__.py b/erpnext/__init__.py
index 706a8e5..cd1d288 100644
--- a/erpnext/__init__.py
+++ b/erpnext/__init__.py
@@ -2,7 +2,7 @@
 from __future__ import unicode_literals
 import frappe
 
-__version__ = '7.2.19'
+__version__ = '7.2.23'
 
 def get_default_company(user=None):
 	'''Get default company for user'''
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.js b/erpnext/accounts/doctype/journal_entry/journal_entry.js
index c98e77f..add3e54 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.js
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.js
@@ -38,7 +38,7 @@
 	},
 	
 	posting_date: function(frm) {
-		if(!frm.doc.multi_currency) return;
+		if(!frm.doc.multi_currency || !frm.doc.posting_date) return;
 		
 		$.each(frm.doc.accounts || [], function(i, row) {
 			erpnext.journal_entry.set_exchange_rate(frm, row.doctype, row.name);
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index 5cf2d92..0f9b5d3 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -832,7 +832,7 @@
 
 # Added posting_date as one of the parameters of get_exchange_rate
 @frappe.whitelist()
-def get_exchange_rate(posting_date, account, account_currency=None, company=None,
+def get_exchange_rate(posting_date, account=None, account_currency=None, company=None,
 		reference_type=None, reference_name=None, debit=None, credit=None, exchange_rate=None):
 	from erpnext.setup.utils import get_exchange_rate
 	account_details = frappe.db.get_value("Account", account,
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js
index d3dbd31..1bbe200 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.js
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js
@@ -79,8 +79,13 @@
 		frm.events.show_general_ledger(frm);
 	},
 
+	company: function(frm) {
+		frm.events.hide_unhide_fields(frm);
+		frm.events.set_dynamic_labels(frm);
+	},
+
 	hide_unhide_fields: function(frm) {
-		var company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency;
+		var company_currency = frm.doc.company? frappe.get_doc(":Company", frm.doc.company).default_currency: "";
 
 		frm.toggle_display("source_exchange_rate",
 			(frm.doc.paid_amount && frm.doc.paid_from_account_currency != company_currency));
@@ -118,7 +123,7 @@
 	},
 
 	set_dynamic_labels: function(frm) {
-		var company_currency = frappe.get_doc(":Company", frm.doc.company).default_currency;
+		var company_currency = frm.doc.company? frappe.get_doc(":Company", frm.doc.company).default_currency: "";
 
 		frm.set_currency_labels(["base_paid_amount", "base_received_amount", "base_total_allocated_amount",
 			"difference_amount"], company_currency);
@@ -131,6 +136,10 @@
 
 		frm.set_currency_labels(["total_allocated_amount", "unallocated_amount"], party_account_currency);
 
+		var currency_field = (frm.doc.payment_type=="Receive") ? "paid_from_account_currency" : "paid_to_account_currency"
+		frm.set_df_property("total_allocated_amount", "options", currency_field);
+		frm.set_df_property("unallocated_amount", "options", currency_field);
+
 		frm.set_currency_labels(["total_amount", "outstanding_amount", "allocated_amount"],
 			party_account_currency, "references");
 
@@ -741,4 +750,4 @@
 	deductions_remove: function(frm) {
 		frm.events.set_difference_amount(frm);
 	}
-})
\ No newline at end of file
+})
diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py
index c65a845..e807055 100644
--- a/erpnext/accounts/party.py
+++ b/erpnext/accounts/party.py
@@ -7,7 +7,7 @@
 import datetime
 from frappe import _, msgprint, scrub
 from frappe.defaults import get_user_permissions
-from frappe.utils import add_days, getdate, formatdate, get_first_day, date_diff, add_years
+from frappe.utils import add_days, getdate, formatdate, get_first_day, date_diff, add_years, get_timestamp
 from erpnext.utilities.doctype.address.address import get_address_display
 from erpnext.utilities.doctype.contact.contact import get_contact_details
 from erpnext.exceptions import PartyFrozen, InvalidCurrency, PartyDisabled, InvalidAccountCurrency
@@ -351,8 +351,17 @@
 def get_timeline_data(doctype, name):
 	'''returns timeline data for the past one year'''
 	from frappe.desk.form.load import get_communication_data
+
+	out = {}
 	data = get_communication_data(doctype, name,
-		fields = 'unix_timestamp(date(creation)), count(name)',
+		fields = 'date(creation), count(name)',
 		after = add_years(None, -1).strftime('%Y-%m-%d'),
 		group_by='group by date(creation)', as_dict=False)
-	return dict(data)
\ No newline at end of file
+
+	timeline_items = dict(data)
+
+	for date, count in timeline_items.iteritems():
+		timestamp = get_timestamp(date)
+		out.update({ timestamp: count })
+
+	return out
\ No newline at end of file
diff --git a/erpnext/accounts/report/balance_sheet/balance_sheet.py b/erpnext/accounts/report/balance_sheet/balance_sheet.py
index 5ff8e3e..7e57dce 100644
--- a/erpnext/accounts/report/balance_sheet/balance_sheet.py
+++ b/erpnext/accounts/report/balance_sheet/balance_sheet.py
@@ -8,7 +8,7 @@
 from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data)
 
 def execute(filters=None):
-	period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity)
+	period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, filters.company)
 
 	asset = get_data(filters.company, "Asset", "Debit", period_list, only_current_fiscal_year=False)
 	liability = get_data(filters.company, "Liability", "Credit", period_list, only_current_fiscal_year=False)
diff --git a/erpnext/accounts/report/cash_flow/cash_flow.py b/erpnext/accounts/report/cash_flow/cash_flow.py
index 182878a..d4d2252 100644
--- a/erpnext/accounts/report/cash_flow/cash_flow.py
+++ b/erpnext/accounts/report/cash_flow/cash_flow.py
@@ -10,7 +10,7 @@
 
 
 def execute(filters=None):
-	period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity)
+	period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, filters.company)
 
 	operation_accounts = {
 		"section_name": "Operations",
diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py
index bc4a220..6955037 100644
--- a/erpnext/accounts/report/financial_statements.py
+++ b/erpnext/accounts/report/financial_statements.py
@@ -8,7 +8,7 @@
 from frappe.utils import (flt, getdate, get_first_day, get_last_day, date_diff,
 	add_months, add_days, formatdate, cint)
 
-def get_period_list(from_fiscal_year, to_fiscal_year, periodicity):
+def get_period_list(from_fiscal_year, to_fiscal_year, periodicity, company):
 	"""Get a list of dict {"from_date": from_date, "to_date": to_date, "key": key, "label": label}
 		Periodicity can be (Yearly, Quarterly, Monthly)"""
 
@@ -50,7 +50,7 @@
 			# if a fiscal year ends before a 12 month period
 			period.to_date = year_end_date
 
-		period.to_date_fiscal_year = get_date_fiscal_year(period.to_date)
+		period.to_date_fiscal_year = get_date_fiscal_year(period.to_date, company)
 
 		period_list.append(period)
 
@@ -142,15 +142,16 @@
 				if entry.posting_date <= period.to_date:
 					if (accumulated_values or entry.posting_date >= period.from_date) and \
 						(entry.fiscal_year == period.to_date_fiscal_year or not ignore_accumulated_values_for_fy):
+						frappe.errprint([entry.fiscal_year, period.to_date_fiscal_year])
 						d[period.key] = d.get(period.key, 0.0) + flt(entry.debit) - flt(entry.credit)
 
 			if entry.posting_date < period_list[0].year_start_date:
 				d["opening_balance"] = d.get("opening_balance", 0.0) + flt(entry.debit) - flt(entry.credit)
 				
-def get_date_fiscal_year(date):
+def get_date_fiscal_year(date, company):
 	from erpnext.accounts.utils import get_fiscal_year
 	
-	return get_fiscal_year(date)[0]
+	return get_fiscal_year(date, company=company)[0]
 
 def accumulate_values_into_parents(accounts, accounts_by_name, period_list, accumulated_values):
 	"""accumulate children's values in parent accounts"""
diff --git a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py
index 747eb43..e12fa06 100644
--- a/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py
+++ b/erpnext/accounts/report/profit_and_loss_statement/profit_and_loss_statement.py
@@ -8,7 +8,7 @@
 from erpnext.accounts.report.financial_statements import (get_period_list, get_columns, get_data)
 
 def execute(filters=None):
-	period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity)
+	period_list = get_period_list(filters.from_fiscal_year, filters.to_fiscal_year, filters.periodicity, filters.company)
 	
 	income = get_data(filters.company, "Income", "Credit", period_list, filters = filters,
 		accumulated_values=filters.accumulated_values, ignore_closing_entries=True, ignore_accumulated_values_for_fy= True)
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index c4ba9e7..1d1b4e2 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -178,6 +178,9 @@
 			for item in self.get("items"):
 				item.rm_supp_cost = 0.0
 
+		if self.is_subcontracted == "No" and self.get("supplied_items"):
+			self.set('supplied_items', [])
+
 	def update_raw_materials_supplied(self, item, raw_material_table):
 		bom_items = self.get_items_from_bom(item.item_code, item.bom)
 		raw_materials_cost = 0
diff --git a/erpnext/hr/doctype/salary_slip/salary_slip.py b/erpnext/hr/doctype/salary_slip/salary_slip.py
index eeec6e8..daa86a8 100644
--- a/erpnext/hr/doctype/salary_slip/salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/salary_slip.py
@@ -156,11 +156,10 @@
 			cond = """and payroll_frequency = '%(payroll_frequency)s'""" % {"payroll_frequency": self.payroll_frequency}
 
 		st_name = frappe.db.sql("""select parent from `tabSalary Structure Employee`
-			where employee=%s
+			where employee=%s and (from_date <= %s or from_date <= %s)
+			and (to_date is null or to_date >= %s or to_date >= %s)
 			and parent in (select name from `tabSalary Structure`
-				where is_active = 'Yes'
-				and (from_date <= %s or from_date <= %s)
-				and (to_date is null or to_date >= %s or to_date >= %s) %s)
+				where is_active = 'Yes'%s)
 			"""% ('%s', '%s', '%s','%s','%s', cond),(self.employee, self.start_date, joining_date, self.end_date, relieving_date))
 
 		if st_name:
diff --git a/erpnext/hr/doctype/salary_slip/test_salary_slip.py b/erpnext/hr/doctype/salary_slip/test_salary_slip.py
index 54faa64..1a47347 100644
--- a/erpnext/hr/doctype/salary_slip/test_salary_slip.py
+++ b/erpnext/hr/doctype/salary_slip/test_salary_slip.py
@@ -7,7 +7,7 @@
 import erpnext
 import calendar
 from erpnext.accounts.utils import get_fiscal_year
-from frappe.utils import getdate, nowdate, add_days
+from frappe.utils import getdate, nowdate, add_days, add_months
 from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip
 from erpnext.hr.doctype.process_payroll.test_process_payroll import get_salary_component_account
 from erpnext.hr.doctype.process_payroll.process_payroll import get_month_details
@@ -257,7 +257,6 @@
 			"doctype": "Salary Structure",
 			"name": sal_struct,
 			"company": erpnext.get_default_company(),
-			"from_date": nowdate(),
 			"employees": get_employee_details(employee),
 			"earnings": get_earnings_component(),
 			"deductions": get_deductions_component(),
@@ -270,7 +269,8 @@
 		sal_struct.append("employees", {"employee": employee,
 			"employee_name": employee,
 			"base": 32000,
-			"variable": 3200
+			"variable": 3200,
+			"from_date": add_months(nowdate(),-1)
 			})
 		sal_struct.save()
 		sal_struct = sal_struct.name
@@ -279,7 +279,8 @@
 def get_employee_details(employee):
 	return [{"employee": employee,
 			"base": 25000,
-			"variable": 5000
+			"variable": 5000,
+			"from_date": add_months(nowdate(),-1)
 			}
 		]
 
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.json b/erpnext/hr/doctype/salary_structure/salary_structure.json
index 8db8e93..526d837 100644
--- a/erpnext/hr/doctype/salary_structure/salary_structure.json
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.json
@@ -100,37 +100,6 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "default": "Monthly", 
-   "depends_on": "eval:(!doc.salary_slip_based_on_timesheet)", 
-   "fieldname": "payroll_frequency", 
-   "fieldtype": "Select", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Payroll Frequency", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "\nMonthly\nFortnightly\nBimonthly\nWeekly\nDaily", 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
    "fieldname": "column_break1", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -189,6 +158,37 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "default": "Monthly", 
+   "depends_on": "eval:(!doc.salary_slip_based_on_timesheet)", 
+   "fieldname": "payroll_frequency", 
+   "fieldtype": "Select", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "Payroll Frequency", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "\nMonthly\nFortnightly\nBimonthly\nWeekly\nDaily", 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "default": "No", 
    "fieldname": "is_default", 
    "fieldtype": "Select", 
@@ -219,64 +219,6 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "from_date", 
-   "fieldtype": "Date", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "From Date", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "from_date", 
-   "oldfieldtype": "Date", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 1, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "to_date", 
-   "fieldtype": "Date", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "To Date", 
-   "length": 0, 
-   "no_copy": 0, 
-   "oldfieldname": "to_date", 
-   "oldfieldtype": "Date", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
    "fieldname": "employee_break", 
    "fieldtype": "Section Break", 
    "hidden": 0, 
@@ -894,7 +836,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-12-14 02:02:10.848614", 
+ "modified": "2017-02-06 01:32:16.815429", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Salary Structure", 
diff --git a/erpnext/hr/doctype/salary_structure/salary_structure.py b/erpnext/hr/doctype/salary_structure/salary_structure.py
index 13622c3..b9f246a 100644
--- a/erpnext/hr/doctype/salary_structure/salary_structure.py
+++ b/erpnext/hr/doctype/salary_structure/salary_structure.py
@@ -4,8 +4,7 @@
 from __future__ import unicode_literals
 import frappe
 
-from frappe.utils import cstr, flt, getdate, cint
-from frappe.model.naming import make_autoname
+from frappe.utils import flt, cint, getdate
 from frappe import _
 from frappe.model.mapper import get_mapped_doc
 from frappe.model.document import Document
@@ -29,13 +28,13 @@
 	def validate_amount(self):
 		if flt(self.net_pay) < 0 and self.salary_slip_based_on_timesheet:
 			frappe.throw(_("Net pay cannot be negative"))
-
+			
 	def validate_joining_date(self):
 		for e in self.get('employees'):
 			joining_date = getdate(frappe.db.get_value("Employee", e.employee, "date_of_joining"))
-			if getdate(self.from_date) < joining_date:
-				frappe.throw(_("From Date in Salary Structure cannot be lesser than Employee Joining Date."))
-				
+			if e.from_date and getdate(e.from_date) < joining_date:
+				frappe.throw(_("From Date {0} for Employee {1} cannot be before employee's joining Date {2}")
+					    .format(e.from_date, e.employee, joining_date))	
 
 @frappe.whitelist()
 def make_salary_slip(source_name, target_doc = None, employee = None, as_print = False, print_format = None):
diff --git a/erpnext/hr/doctype/salary_structure/test_salary_structure.py b/erpnext/hr/doctype/salary_structure/test_salary_structure.py
index fe88d9a..7d761fd 100644
--- a/erpnext/hr/doctype/salary_structure/test_salary_structure.py
+++ b/erpnext/hr/doctype/salary_structure/test_salary_structure.py
@@ -6,7 +6,7 @@
 import unittest
 import erpnext
 from frappe.utils.make_random import get_random
-from frappe.utils import nowdate, add_days, add_years, getdate
+from frappe.utils import nowdate, add_days, add_years, getdate, add_months
 from erpnext.hr.doctype.salary_structure.salary_structure import make_salary_slip
 from erpnext.hr.doctype.salary_slip.test_salary_slip \
 	import make_earning_salary_component, make_deduction_salary_component
@@ -94,7 +94,6 @@
 			"doctype": "Salary Structure",
 			"name": sal_struct,
 			"company": erpnext.get_default_company(),
-			"from_date": nowdate(),
 			"employees": get_employee_details(),
 			"earnings": get_earnings_component(),
 			"deductions": get_deductions_component(),
@@ -108,11 +107,13 @@
 	return [{"employee": frappe.get_value("Employee", {"employee_name":"test_employee@salary.com"}, "name"),
 			"base": 25000,
 			"variable": 5000,
+			"from_date": add_months(nowdate(),-1),
 			"idx": 1
 			},
 			{"employee": frappe.get_value("Employee", {"employee_name":"test_employee_2@salary.com"}, "name"),
 			 "base": 15000,
 			 "variable": 100,
+			 "from_date": add_months(nowdate(),-1),
 			 "idx": 2
 			}
 		]
diff --git a/erpnext/hr/doctype/salary_structure_employee/salary_structure_employee.json b/erpnext/hr/doctype/salary_structure_employee/salary_structure_employee.json
index aae33e3..afbbf8f 100644
--- a/erpnext/hr/doctype/salary_structure_employee/salary_structure_employee.json
+++ b/erpnext/hr/doctype/salary_structure_employee/salary_structure_employee.json
@@ -10,11 +10,13 @@
  "doctype": "DocType", 
  "document_type": "", 
  "editable_grid": 1, 
+ "engine": "InnoDB", 
  "fields": [
   {
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "employee", 
    "fieldtype": "Link", 
    "hidden": 0, 
@@ -22,6 +24,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Employee", 
    "length": 0, 
    "no_copy": 0, 
@@ -31,6 +34,7 @@
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
    "read_only": 0, 
+   "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 1, 
    "search_index": 0, 
@@ -41,6 +45,7 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "employee_name", 
    "fieldtype": "Data", 
    "hidden": 0, 
@@ -48,6 +53,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 0, 
+   "in_standard_filter": 0, 
    "label": "Employee Name", 
    "length": 0, 
    "no_copy": 0, 
@@ -56,6 +62,7 @@
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
    "read_only": 1, 
+   "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 0, 
    "search_index": 0, 
@@ -66,14 +73,16 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
-   "fieldname": "base", 
-   "fieldtype": "Currency", 
+   "columns": 0, 
+   "fieldname": "from_date", 
+   "fieldtype": "Date", 
    "hidden": 0, 
    "ignore_user_permissions": 0, 
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
-   "label": "Base", 
+   "in_standard_filter": 0, 
+   "label": "From Date", 
    "length": 0, 
    "no_copy": 0, 
    "permlevel": 0, 
@@ -81,6 +90,7 @@
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
    "read_only": 0, 
+   "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 1, 
    "search_index": 0, 
@@ -91,6 +101,63 @@
    "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "to_date", 
+   "fieldtype": "Date", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "label": "To Date", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "base", 
+   "fieldtype": "Currency", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Base", 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 1, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "variable", 
    "fieldtype": "Currency", 
    "hidden": 0, 
@@ -98,6 +165,7 @@
    "ignore_xss_filter": 0, 
    "in_filter": 0, 
    "in_list_view": 1, 
+   "in_standard_filter": 0, 
    "label": "Variable", 
    "length": 0, 
    "no_copy": 0, 
@@ -106,6 +174,7 @@
    "print_hide": 0, 
    "print_hide_if_no_value": 0, 
    "read_only": 0, 
+   "remember_last_selected_value": 0, 
    "report_hide": 0, 
    "reqd": 0, 
    "search_index": 0, 
@@ -123,7 +192,7 @@
  "issingle": 0, 
  "istable": 1, 
  "max_attachments": 0, 
- "modified": "2016-08-11 12:18:14.526977", 
+ "modified": "2017-02-06 01:32:38.183131", 
  "modified_by": "Administrator", 
  "module": "HR", 
  "name": "Salary Structure Employee", 
diff --git a/erpnext/manufacturing/doctype/bom/bom.json b/erpnext/manufacturing/doctype/bom/bom.json
index c2c9b64..7e4b7ea 100644
--- a/erpnext/manufacturing/doctype/bom/bom.json
+++ b/erpnext/manufacturing/doctype/bom/bom.json
@@ -323,7 +323,7 @@
    "read_only": 0, 
    "remember_last_selected_value": 0, 
    "report_hide": 0, 
-   "reqd": 0, 
+   "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
    "unique": 0
@@ -378,7 +378,7 @@
    "read_only": 0, 
    "remember_last_selected_value": 0, 
    "report_hide": 0, 
-   "reqd": 0, 
+   "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
    "unique": 0
@@ -976,7 +976,7 @@
    "read_only": 0, 
    "remember_last_selected_value": 1, 
    "report_hide": 0, 
-   "reqd": 0, 
+   "reqd": 1, 
    "search_index": 0, 
    "set_only_once": 0, 
    "unique": 0
@@ -1271,8 +1271,8 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-11-21 17:06:49.349654", 
- "modified_by": "rohit@erpnext.com", 
+ "modified": "2017-02-21 13:10:27.394012", 
+ "modified_by": "Administrator", 
  "module": "Manufacturing", 
  "name": "BOM", 
  "owner": "Administrator", 
diff --git a/erpnext/manufacturing/doctype/bom/bom.py b/erpnext/manufacturing/doctype/bom/bom.py
index f4fed6e..53398ea 100644
--- a/erpnext/manufacturing/doctype/bom/bom.py
+++ b/erpnext/manufacturing/doctype/bom/bom.py
@@ -321,9 +321,9 @@
 			if d.bom_no:
 				d.rate = self.get_bom_unitcost(d.bom_no)
 
-			d.base_rate = d.rate * self.conversion_rate
+			d.base_rate = flt(d.rate) * flt(self.conversion_rate)
 			d.amount = flt(d.rate, self.precision("rate", d)) * flt(d.qty, self.precision("qty", d))
-			d.base_amount = d.amount * self.conversion_rate
+			d.base_amount = d.amount * flt(self.conversion_rate)
 			d.qty_consumed_per_unit = flt(d.qty, self.precision("qty", d)) / flt(self.quantity, self.precision("quantity"))
 			total_rm_cost += d.amount
 			base_total_rm_cost += d.base_amount
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index b997dfc..4887e3f 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -363,4 +363,6 @@
 erpnext.patches.v7_2.update_doctype_status
 erpnext.patches.v7_2.update_salary_slips
 erpnext.patches.v7_2.set_null_value_to_fields
-erpnext.patches.v7_2.update_abbr_in_salary_slips
\ No newline at end of file
+erpnext.patches.v7_2.update_abbr_in_salary_slips
+erpnext.patches.v7_2.move_dates_from_salary_structure_to_employee
+erpnext.patches.v7_2.empty_supplied_items_for_non_subcontracted
diff --git a/erpnext/patches/v7_2/empty_supplied_items_for_non_subcontracted.py b/erpnext/patches/v7_2/empty_supplied_items_for_non_subcontracted.py
new file mode 100644
index 0000000..ec6f8af
--- /dev/null
+++ b/erpnext/patches/v7_2/empty_supplied_items_for_non_subcontracted.py
@@ -0,0 +1,14 @@
+# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
+# License: GNU General Public License v3. See license.txt
+
+from __future__ import unicode_literals
+import frappe
+
+def execute():
+	for doctype in ["Purchase Order", "Purchase Invoice", "Purchase Receipt"]:
+		child_table = 'Purchase Receipt Item Supplied' if doctype != 'Purchase Order' else 'Purchase Order Item Supplied'
+		for data in frappe.db.sql(""" select distinct `tab{doctype}`.name from `tab{doctype}` , `tab{child_table}`
+			where `tab{doctype}`.name = `tab{child_table}`.parent and `tab{doctype}`.docstatus != 2
+			and `tab{doctype}`.is_subcontracted = 'No' """.format(doctype = doctype, child_table = child_table), as_dict=1):
+			frappe.db.sql(""" delete from `tab{child_table}` 
+				where parent = %s and parenttype = %s""".format(child_table= child_table), (data.name, doctype))
\ No newline at end of file
diff --git a/erpnext/patches/v7_2/move_dates_from_salary_structure_to_employee.py b/erpnext/patches/v7_2/move_dates_from_salary_structure_to_employee.py
new file mode 100644
index 0000000..98e076e
--- /dev/null
+++ b/erpnext/patches/v7_2/move_dates_from_salary_structure_to_employee.py
@@ -0,0 +1,9 @@
+import frappe
+
+def execute():
+	frappe.reload_doc('hr', 'doctype', 'salary_structure_employee')
+	salary_structures = frappe.db.sql("""select name, to_date, from_date from `tabSalary Structure`""", as_dict=True)
+
+	for salary_structure in salary_structures:
+		frappe.db.sql(""" update `tabSalary Structure Employee` set from_date = %s, to_date = %s
+			where parent = %s """, (salary_structure.from_date, salary_structure.to_date or 'null', salary_structure.name))
\ No newline at end of file
diff --git a/erpnext/projects/doctype/timesheet/test_timesheet.py b/erpnext/projects/doctype/timesheet/test_timesheet.py
index 11d0b1c..1db0610 100644
--- a/erpnext/projects/doctype/timesheet/test_timesheet.py
+++ b/erpnext/projects/doctype/timesheet/test_timesheet.py
@@ -7,7 +7,7 @@
 import unittest
 import datetime
 from frappe.utils.make_random import get_random
-from frappe.utils import now_datetime, nowdate, add_days
+from frappe.utils import now_datetime, nowdate, add_days, add_months
 from erpnext.projects.doctype.timesheet.timesheet import OverlapError
 from erpnext.projects.doctype.timesheet.timesheet import make_salary_slip, make_sales_invoice
 from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
@@ -88,7 +88,8 @@
 
 		es = salary_structure.append('employees', {
 			"employee": employee,
-			"base": 1200 
+			"base": 1200,
+			"from_date": add_months(nowdate(),-1)
 		})
 		
 		
diff --git a/erpnext/public/js/setup_wizard.js b/erpnext/public/js/setup_wizard.js
index 30323ec..c2a1595 100644
--- a/erpnext/public/js/setup_wizard.js
+++ b/erpnext/public/js/setup_wizard.js
@@ -100,7 +100,12 @@
 						fy = ["01-01", "12-31"];
 						next_year = current_year;
 					}
-
+					
+					var year_start_date = current_year + "-" + fy[0];
+					if(year_start_date > get_today()) {
+						next_year = current_year
+						current_year -= 1;
+					}
 					slide.get_field("fy_start_date").set_input(current_year + "-" + fy[0]);
 					slide.get_field("fy_end_date").set_input(next_year + "-" + fy[1]);
 				}
diff --git a/erpnext/schools/doctype/assessment/assessment.py b/erpnext/schools/doctype/assessment/assessment.py
index 003b427..5088336 100644
--- a/erpnext/schools/doctype/assessment/assessment.py
+++ b/erpnext/schools/doctype/assessment/assessment.py
@@ -34,7 +34,7 @@
 			validate_overlap_for(self, "Assessment", "student_group")
 		
 		validate_overlap_for(self, "Assessment", "room")
-		validate_overlap_for(self, "Assessment", "supervisor", self.instructor)
+		validate_overlap_for(self, "Assessment", "supervisor", self.supervisor)
 
 
 def get_assessment_list(doctype, txt, filters, limit_start, limit_page_length=20):
diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js
index 1f793d1..985bd4f 100644
--- a/erpnext/stock/doctype/item/item.js
+++ b/erpnext/stock/doctype/item/item.js
@@ -4,6 +4,13 @@
 frappe.provide("erpnext.item");
 
 frappe.ui.form.on("Item", {
+	setup: function(frm) {
+		frm.add_fetch('attribute', 'numeric_values', 'numeric_values');
+		frm.add_fetch('attribute', 'from_range', 'from_range');
+		frm.add_fetch('attribute', 'to_range', 'to_range');
+		frm.add_fetch('attribute', 'increment', 'increment');
+		frm.add_fetch('tax_type', 'tax_rate', 'tax_rate');
+	},
 	onload: function(frm) {
 		erpnext.item.setup_queries(frm);
 		if (frm.doc.variant_of){
@@ -16,7 +23,6 @@
 	},
 
 	refresh: function(frm) {
-
 		if(frm.doc.is_stock_item) {
 			frm.add_custom_button(__("Balance"), function() {
 				frappe.route_options = {
@@ -54,9 +60,9 @@
 			}, __("View"));
 
 			frm.add_custom_button(__("Variant"), function() {
-				erpnext.item.make_variant()
+				erpnext.item.make_variant(frm);
 			}, __("Make"));
-			cur_frm.page.set_inner_btn_group_as_primary(__("Make"));
+			frm.page.set_inner_btn_group_as_primary(__("Make"));
 		}
 		if (frm.doc.variant_of) {
 			frm.set_intro(__("This Item is a Variant of {0} (Template). Attributes will be copied over from the template unless 'No Copy' is set", [frm.doc.variant_of]), true);
@@ -79,6 +85,17 @@
 
 		frm.toggle_enable("is_fixed_asset", (frm.doc.__islocal || (!frm.doc.is_stock_item &&
 			((frm.doc.__onload && frm.doc.__onload.asset_exists) ? false : true))));
+
+		frm.add_custom_button(__('Duplicate'), function() {
+			var new_item = frappe.model.copy_doc(frm.doc);
+			if(new_item.item_name===new_item.item_code) {
+				new_item.item_name = null;
+			}
+			if(new_item.description===new_item.description) {
+				new_item.description = null;
+			}
+			frappe.set_route('Form', 'Item', new_item.name);
+		});
 	},
 
 	validate: function(frm){
@@ -88,13 +105,13 @@
 	image: function(frm) {
 		refresh_field("image_view");
 	},
-	
+
 	is_fixed_asset: function(frm) {
 		if (frm.doc.is_fixed_asset) {
 			frm.set_value("is_stock_item", 0);
 		}
 	},
-	
+
 	page_name: frappe.utils.warn_page_name_change,
 
 	item_code: function(frm) {
@@ -191,15 +208,15 @@
 
 		frm.fields_dict.reorder_levels.grid.get_field("warehouse").get_query = function(doc, cdt, cdn) {
 			var d = locals[cdt][cdn];
-			
+
 			var filters = {
 				"is_group": 0
 			}
-			
+
 			if (d.parent_warehouse) {
 				filters.extend({"parent_warehouse": d.warehouse_group})
 			}
-			
+
 			return {
 				filters: filters
 			}
@@ -212,7 +229,8 @@
 			return;
 
 		frappe.require('assets/js/item-dashboard.min.js', function() {
-			var section = frm.dashboard.add_section('<h5 style="margin-top: 0px;"><a href="#stock-balance">Stock Levels</a></h5>');
+			var section = frm.dashboard.add_section('<h5 style="margin-top: 0px;">\
+				<a href="#stock-balance">Stock Levels</a></h5>');
 			erpnext.item.item_dashboard = new erpnext.stock.ItemDashboard({
 				parent: section,
 				item_code: frm.doc.name
@@ -234,12 +252,12 @@
 		}
 	},
 
-	make_variant: function(doc) {
+	make_variant: function(frm) {
 		var fields = []
 
-		for(var i=0;i< cur_frm.doc.attributes.length;i++){
+		for(var i=0;i< frm.doc.attributes.length;i++){
 			var fieldtype, desc;
-			var row = cur_frm.doc.attributes[i];
+			var row = frm.doc.attributes[i];
 			if (row.numeric_values){
 				fieldtype = "Float";
 				desc = "Min Value: "+ row.from_range +" , Max Value: "+ row.to_range +", in Increments of: "+ row.increment
@@ -268,7 +286,7 @@
 			frappe.call({
 				method:"erpnext.controllers.item_variant.get_variant",
 				args: {
-					"template": cur_frm.doc.name,
+					"template": frm.doc.name,
 					"args": d.get_values()
 				},
 				callback: function(r) {
@@ -290,7 +308,7 @@
 						frappe.call({
 							method:"erpnext.controllers.item_variant.create_variant",
 							args: {
-								"item": cur_frm.doc.name,
+								"item": frm.doc.name,
 								"args": d.get_values()
 							},
 							callback: function(r) {
@@ -358,10 +376,3 @@
 		frm.fields_dict.attributes.grid.toggle_enable("attribute_value", !frm.doc.variant_of);
 	}
 });
-
-
-cur_frm.add_fetch('attribute', 'numeric_values', 'numeric_values');
-cur_frm.add_fetch('attribute', 'from_range', 'from_range');
-cur_frm.add_fetch('attribute', 'to_range', 'to_range');
-cur_frm.add_fetch('attribute', 'increment', 'increment');
-cur_frm.add_fetch('tax_type', 'tax_rate', 'tax_rate');
diff --git a/erpnext/stock/doctype/item/item.json b/erpnext/stock/doctype/item/item.json
index 6dfe76e..60f6fdf 100644
--- a/erpnext/stock/doctype/item/item.json
+++ b/erpnext/stock/doctype/item/item.json
@@ -87,7 +87,7 @@
    "in_standard_filter": 0, 
    "label": "Item Code", 
    "length": 0, 
-   "no_copy": 1, 
+   "no_copy": 0, 
    "oldfieldname": "item_code", 
    "oldfieldtype": "Data", 
    "permlevel": 0, 
@@ -134,7 +134,7 @@
   }, 
   {
    "allow_on_submit": 0, 
-   "bold": 0, 
+   "bold": 1, 
    "collapsible": 0, 
    "columns": 0, 
    "fieldname": "item_name", 
@@ -156,7 +156,7 @@
    "read_only": 0, 
    "remember_last_selected_value": 0, 
    "report_hide": 0, 
-   "reqd": 1, 
+   "reqd": 0, 
    "search_index": 1, 
    "set_only_once": 0, 
    "unique": 0
@@ -2713,7 +2713,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 1, 
- "modified": "2017-01-18 17:43:20.262925", 
+ "modified": "2017-02-17 04:00:38.825621", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Item", 
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 53faa43..0f0205b 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -7,7 +7,7 @@
 import json
 import itertools
 from frappe import msgprint, _
-from frappe.utils import cstr, flt, cint, getdate, now_datetime, formatdate, strip
+from frappe.utils import cstr, flt, cint, getdate, now_datetime, formatdate, strip, get_timestamp
 from frappe.website.website_generator import WebsiteGenerator
 from erpnext.setup.doctype.item_group.item_group import invalidate_cache_for, get_parent_item_groups
 from frappe.website.render import clear_cache
@@ -63,6 +63,9 @@
 	def validate(self):
 		super(Item, self).validate()
 
+		if not self.item_name:
+			self.item_name = self.item_code
+
 		if not self.description:
 			self.description = self.item_name
 
@@ -451,24 +454,32 @@
 				"valuation_method", "has_batch_no", "is_fixed_asset")
 
 			vals = frappe.db.get_value("Item", self.name, to_check, as_dict=True)
+			if not vals.get('valuation_method') and self.get('valuation_method'):
+				vals['valuation_method'] = frappe.db.get_single_value("Stock Settings", "valuation_method") or "FIFO"
 
 			if vals:
 				for key in to_check:
-					if self.get(key) != vals.get(key):
-						if not self.check_if_linked_document_exists():
+					if cstr(self.get(key)) != cstr(vals.get(key)):
+						if not self.check_if_linked_document_exists(key):
 							break # no linked document, allowed
 						else:
-							frappe.throw(_("As there are existing transactions for this item, you can not change the value of {0}").format(frappe.bold(self.meta.get_label(key))))
+							frappe.throw(_("As there are existing transactions against item {0}, you can not change the value of {1}").format(self.name, frappe.bold(self.meta.get_label(key))))
 
 			if vals and not self.is_fixed_asset and self.is_fixed_asset != vals.is_fixed_asset:
 				asset = frappe.db.get_all("Asset", filters={"item_code": self.name, "docstatus": 1}, limit=1)
 				if asset:
 					frappe.throw(_('"Is Fixed Asset" cannot be unchecked, as Asset record exists against the item'))
 
-	def check_if_linked_document_exists(self):
-		for doctype in ("Sales Order Item", "Delivery Note Item", "Sales Invoice Item",
-			"Material Request Item", "Purchase Order Item", "Purchase Receipt Item",
-			"Purchase Invoice Item", "Stock Entry Detail", "Stock Reconciliation Item"):
+	def check_if_linked_document_exists(self, key):
+		linked_doctypes = ["Delivery Note Item", "Sales Invoice Item", "Purchase Receipt Item",
+			"Purchase Invoice Item", "Stock Entry Detail", "Stock Reconciliation Item"]
+
+		# For "Is Stock Item", following doctypes is important
+		# because reserved_qty, ordered_qty and requested_qty updated from these doctypes
+		if key == "is_stock_item":
+			linked_doctypes += ["Sales Order Item", "Purchase Order Item", "Material Request Item"]
+
+		for doctype in linked_doctypes:
 			if frappe.db.get_value(doctype, filters={"item_code": self.name, "docstatus": 1}) or \
 				frappe.db.get_value("Production Order",
 					filters={"production_item": self.name, "docstatus": 1}):
@@ -659,10 +670,17 @@
 
 def get_timeline_data(doctype, name):
 	'''returns timeline data based on stock ledger entry'''
-	return dict(frappe.db.sql('''select unix_timestamp(posting_date), count(*)
+	out = {}
+	items = dict(frappe.db.sql('''select posting_date, count(*)
 		from `tabStock Ledger Entry` where item_code=%s
 			and posting_date > date_sub(curdate(), interval 1 year)
 			group by posting_date''', name))
+	
+	for date, count in items.iteritems():
+		timestamp = get_timestamp(date)
+		out.update({ timestamp: count })
+
+	return out
 
 def validate_end_of_life(item_code, end_of_life=None, disabled=None, verbose=1):
 	if (not end_of_life) or (disabled is None):
diff --git a/erpnext/stock/doctype/item_price/item_price.json b/erpnext/stock/doctype/item_price/item_price.json
index 5f08262..0685c80 100644
--- a/erpnext/stock/doctype/item_price/item_price.json
+++ b/erpnext/stock/doctype/item_price/item_price.json
@@ -74,6 +74,33 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
+   "fieldname": "column_break_3", 
+   "fieldtype": "Column Break", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 0, 
+   "in_standard_filter": 0, 
+   "length": 0, 
+   "no_copy": 0, 
+   "permlevel": 0, 
+   "precision": "", 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 0, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
+   "bold": 0, 
+   "collapsible": 0, 
+   "columns": 0, 
    "fieldname": "buying", 
    "fieldtype": "Check", 
    "hidden": 0, 
@@ -153,6 +180,34 @@
   }, 
   {
    "allow_on_submit": 0, 
+   "bold": 1, 
+   "collapsible": 0, 
+   "columns": 0, 
+   "fieldname": "currency", 
+   "fieldtype": "Link", 
+   "hidden": 0, 
+   "ignore_user_permissions": 0, 
+   "ignore_xss_filter": 0, 
+   "in_filter": 0, 
+   "in_list_view": 1, 
+   "in_standard_filter": 0, 
+   "label": "Currency", 
+   "length": 0, 
+   "no_copy": 0, 
+   "options": "Currency", 
+   "permlevel": 0, 
+   "print_hide": 0, 
+   "print_hide_if_no_value": 0, 
+   "read_only": 1, 
+   "remember_last_selected_value": 0, 
+   "report_hide": 0, 
+   "reqd": 0, 
+   "search_index": 0, 
+   "set_only_once": 0, 
+   "unique": 0
+  }, 
+  {
+   "allow_on_submit": 0, 
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
@@ -216,34 +271,6 @@
    "bold": 0, 
    "collapsible": 0, 
    "columns": 0, 
-   "fieldname": "currency", 
-   "fieldtype": "Link", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 1, 
-   "in_standard_filter": 0, 
-   "label": "Currency", 
-   "length": 0, 
-   "no_copy": 0, 
-   "options": "Currency", 
-   "permlevel": 0, 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 1, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
    "fieldname": "col_br_1", 
    "fieldtype": "Column Break", 
    "hidden": 0, 
@@ -318,61 +345,6 @@
    "search_index": 0, 
    "set_only_once": 0, 
    "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "section_break_12", 
-   "fieldtype": "Section Break", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
-  }, 
-  {
-   "allow_on_submit": 0, 
-   "bold": 0, 
-   "collapsible": 0, 
-   "columns": 0, 
-   "fieldname": "bulk_import_help", 
-   "fieldtype": "HTML", 
-   "hidden": 0, 
-   "ignore_user_permissions": 0, 
-   "ignore_xss_filter": 0, 
-   "in_filter": 0, 
-   "in_list_view": 0, 
-   "in_standard_filter": 0, 
-   "label": "Bulk Import Help", 
-   "length": 0, 
-   "no_copy": 0, 
-   "permlevel": 0, 
-   "precision": "", 
-   "print_hide": 0, 
-   "print_hide_if_no_value": 0, 
-   "read_only": 0, 
-   "remember_last_selected_value": 0, 
-   "report_hide": 0, 
-   "reqd": 0, 
-   "search_index": 0, 
-   "set_only_once": 0, 
-   "unique": 0
   }
  ], 
  "hide_heading": 0, 
@@ -386,7 +358,7 @@
  "issingle": 0, 
  "istable": 0, 
  "max_attachments": 0, 
- "modified": "2016-12-15 14:52:09.842544", 
+ "modified": "2017-02-17 04:24:30.453863", 
  "modified_by": "Administrator", 
  "module": "Stock", 
  "name": "Item Price", 
@@ -435,7 +407,7 @@
    "write": 1
   }
  ], 
- "quick_entry": 0, 
+ "quick_entry": 1, 
  "read_only": 0, 
  "read_only_onload": 0, 
  "sort_order": "ASC", 
diff --git a/erpnext/templates/generators/job_opening.html b/erpnext/templates/generators/job_opening.html
index 5998e3f..f92e72e 100644
--- a/erpnext/templates/generators/job_opening.html
+++ b/erpnext/templates/generators/job_opening.html
@@ -15,7 +15,7 @@
 {% endif %}
 <p style='margin-top: 30px'>
 	<a class='btn btn-primary'
-	href='/job_application?job_title={{ doc.name }}'>
+	href='/job_application?new=1&job_title={{ doc.name }}'>
 	{{ _("Apply Now") }}</a>
 </p>
 
diff --git a/erpnext/utilities/__init__.py b/erpnext/utilities/__init__.py
index bba21e6..b94061c 100644
--- a/erpnext/utilities/__init__.py
+++ b/erpnext/utilities/__init__.py
@@ -1,6 +1,7 @@
 ## temp utility
 
 import frappe
+from erpnext.utilities.activation import get_level
 
 def update_doctypes():
 	for d in frappe.db.sql("""select df.parent, df.fieldname
@@ -29,5 +30,6 @@
 
 	return {
 		'company': company,
-		'domain': domain
+		'domain': domain,
+		'activation': get_level()
 	}
diff --git a/erpnext/utilities/activation.py b/erpnext/utilities/activation.py
new file mode 100644
index 0000000..563f71e
--- /dev/null
+++ b/erpnext/utilities/activation.py
@@ -0,0 +1,36 @@
+import frappe
+
+def get_level():
+	activation_level = 0
+	if frappe.db.get_single_value('System Settings', 'setup_complete'):
+		activation_level = 1
+
+	if frappe.db.count('Item') > 5:
+		activation_level += 1
+
+	if frappe.db.count('Customer') > 5:
+		activation_level += 1
+
+	if frappe.db.count('Sales Order') > 2:
+		activation_level += 1
+
+	if frappe.db.count('Purchase Order') > 2:
+		activation_level += 1
+
+	if frappe.db.count('Employee') > 3:
+		activation_level += 1
+
+	if frappe.db.count('Payment Entry') > 2:
+		activation_level += 1
+
+	if frappe.db.count('Communication', dict(communication_medium='Email')) > 10:
+		activation_level += 1
+
+	if frappe.db.count('User') > 5:
+		activation_level += 1
+
+	# recent login
+	if frappe.db.sql('select name from tabUser where last_login > date_sub(now(), interval 2 day) limit 1'):
+		activation_level += 1
+
+	return activation_level
\ No newline at end of file