Removed from Delivery Note and Appraisal
Added back in Stock Ledger Entry
Added validation in GL Entry and SL Entry
Stock Controller sets Fiscal Year using Posting Date
diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py
index f2f3443..906c131 100644
--- a/erpnext/accounts/doctype/gl_entry/gl_entry.py
+++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py
@@ -9,6 +9,7 @@
from erpnext.accounts.party import validate_party_gle_currency, validate_party_frozen_disabled
from erpnext.accounts.utils import get_account_currency
from erpnext.setup.doctype.company.company import get_company_currency
+from erpnext.accounts.utils import get_fiscal_year
from erpnext.exceptions import InvalidAccountCurrency
exclude_from_linked_with = True
@@ -22,6 +23,7 @@
self.validate_cost_center()
self.validate_party()
self.validate_currency()
+ self.validate_and_set_fiscal_year()
def on_update_with_args(self, adv_adj, update_outstanding = 'Yes'):
self.validate_account_details(adv_adj)
@@ -107,6 +109,12 @@
if self.party_type and self.party:
validate_party_gle_currency(self.party_type, self.party, self.company, self.account_currency)
+
+ def validate_and_set_fiscal_year(self):
+ if not self.fiscal_year:
+ self.fiscal_year = get_fiscal_year(self.posting_date, company=self.company)[0]
+
+
def validate_balance_type(account, adv_adj=False):
if not adv_adj and account:
balance_must_be = frappe.db.get_value("Account", account, "balance_must_be")
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 3f3e658..83c3b6f 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -6,6 +6,7 @@
from frappe.utils import cint, flt, cstr
from frappe import msgprint, _
import frappe.defaults
+from erpnext.accounts.utils import get_fiscal_year
from erpnext.accounts.general_ledger import make_gl_entries, delete_gl_entries, process_gl_map
from erpnext.stock.utils import get_incoming_rate
@@ -181,6 +182,7 @@
"warehouse": d.get("warehouse", None),
"posting_date": self.posting_date,
"posting_time": self.posting_time,
+ 'fiscal_year': get_fiscal_year(self.posting_date, company=self.company)[0],
"voucher_type": self.doctype,
"voucher_no": self.name,
"voucher_detail_no": d.name,
diff --git a/erpnext/hr/doctype/appraisal/appraisal.json b/erpnext/hr/doctype/appraisal/appraisal.json
index b0d5ae8..e353e34 100644
--- a/erpnext/hr/doctype/appraisal/appraisal.json
+++ b/erpnext/hr/doctype/appraisal/appraisal.json
@@ -17,6 +17,7 @@
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "",
@@ -42,6 +43,7 @@
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Appraisal Template",
@@ -70,6 +72,7 @@
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
"label": "For Employee",
@@ -97,6 +100,7 @@
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
"label": "For Employee Name",
@@ -123,6 +127,7 @@
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"length": 0,
@@ -149,6 +154,7 @@
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
"label": "Status",
@@ -176,6 +182,7 @@
"fieldtype": "Date",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 1,
"label": "Start Date",
@@ -202,6 +209,7 @@
"fieldtype": "Date",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
"label": "End Date",
@@ -228,6 +236,7 @@
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Goals",
@@ -253,6 +262,7 @@
"fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Goals",
@@ -279,6 +289,7 @@
"fieldtype": "Button",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Calculate Total Score",
@@ -304,6 +315,7 @@
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"label": "Total Score (Out of 5)",
@@ -330,6 +342,7 @@
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"length": 0,
@@ -353,6 +366,7 @@
"fieldtype": "Text",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Remarks",
@@ -377,6 +391,7 @@
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "",
@@ -400,6 +415,7 @@
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
"label": "Company",
@@ -426,6 +442,7 @@
"fieldtype": "Column Break",
"hidden": 0,
"ignore_user_permissions": 0,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"length": 0,
@@ -445,36 +462,11 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
- "fieldname": "fiscal_year",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "in_filter": 1,
- "in_list_view": 0,
- "label": "Fiscal Year",
- "length": 0,
- "no_copy": 0,
- "oldfieldname": "fiscal_year",
- "oldfieldtype": "Select",
- "options": "Fiscal Year",
- "permlevel": 0,
- "print_hide": 0,
- "print_hide_if_no_value": 0,
- "read_only": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 0,
- "set_only_once": 0,
- "unique": 0
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
"fieldname": "amended_from",
"fieldtype": "Link",
"hidden": 1,
"ignore_user_permissions": 1,
+ "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Amended From",
@@ -505,7 +497,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-02-03 01:17:20.561443",
+ "modified": "2016-03-04 02:08:11.258389",
"modified_by": "Administrator",
"module": "HR",
"name": "Appraisal",
diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json
index 94626ab..b10c90d 100644
--- a/erpnext/stock/doctype/delivery_note/delivery_note.json
+++ b/erpnext/stock/doctype/delivery_note/delivery_note.json
@@ -2215,35 +2215,6 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
- "fieldname": "fiscal_year",
- "fieldtype": "Link",
- "hidden": 0,
- "ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
- "in_filter": 1,
- "in_list_view": 0,
- "label": "Fiscal Year",
- "length": 0,
- "no_copy": 0,
- "oldfieldname": "fiscal_year",
- "oldfieldtype": "Select",
- "options": "Fiscal Year",
- "permlevel": 0,
- "print_hide": 1,
- "print_hide_if_no_value": 0,
- "print_width": "150px",
- "read_only": 0,
- "report_hide": 0,
- "reqd": 1,
- "search_index": 1,
- "set_only_once": 0,
- "unique": 0,
- "width": "150px"
- },
- {
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
"fieldname": "per_billed",
"fieldtype": "Currency",
"hidden": 0,
@@ -2828,7 +2799,7 @@
"istable": 0,
"max_attachments": 0,
"menu_index": 0,
- "modified": "2016-03-02 05:09:26.868653",
+ "modified": "2016-03-04 02:11:17.177846",
"modified_by": "Administrator",
"module": "Stock",
"name": "Delivery Note",
diff --git a/erpnext/stock/doctype/delivery_note/test_records.json b/erpnext/stock/doctype/delivery_note/test_records.json
index 4bfbace..9c11286 100644
--- a/erpnext/stock/doctype/delivery_note/test_records.json
+++ b/erpnext/stock/doctype/delivery_note/test_records.json
@@ -23,7 +23,6 @@
}
],
"doctype": "Delivery Note",
- "fiscal_year": "_Test Fiscal Year 2013",
"base_grand_total": 100.0,
"grand_total": 100.0,
"naming_series": "_T-Delivery Note-",
diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json
index 7ba3334..180f114 100644
--- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json
+++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.json
@@ -17,7 +17,6 @@
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 1,
"label": "Item Code",
@@ -28,7 +27,6 @@
"options": "Item",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"print_width": "100px",
"read_only": 1,
"report_hide": 0,
@@ -46,7 +44,6 @@
"fieldtype": "Text",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"label": "Serial No",
@@ -54,7 +51,6 @@
"no_copy": 0,
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"print_width": "100px",
"read_only": 1,
"report_hide": 0,
@@ -72,7 +68,6 @@
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 1,
"label": "Batch No",
@@ -82,7 +77,6 @@
"oldfieldtype": "Data",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
@@ -98,7 +92,6 @@
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 1,
"label": "Warehouse",
@@ -109,7 +102,6 @@
"options": "Warehouse",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"print_width": "100px",
"read_only": 1,
"report_hide": 0,
@@ -127,7 +119,6 @@
"fieldtype": "Date",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 1,
"label": "Posting Date",
@@ -137,7 +128,6 @@
"oldfieldtype": "Date",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"print_width": "100px",
"read_only": 1,
"report_hide": 0,
@@ -155,7 +145,6 @@
"fieldtype": "Time",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Posting Time",
@@ -165,7 +154,6 @@
"oldfieldtype": "Time",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"print_width": "100px",
"read_only": 1,
"report_hide": 0,
@@ -183,7 +171,6 @@
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
"label": "Voucher Type",
@@ -194,7 +181,6 @@
"options": "DocType",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"print_width": "150px",
"read_only": 1,
"report_hide": 0,
@@ -212,7 +198,6 @@
"fieldtype": "Dynamic Link",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
"label": "Voucher No",
@@ -223,7 +208,6 @@
"options": "voucher_type",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"print_width": "150px",
"read_only": 1,
"report_hide": 0,
@@ -241,7 +225,6 @@
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Voucher Detail No",
@@ -251,7 +234,6 @@
"oldfieldtype": "Data",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"print_width": "150px",
"read_only": 1,
"report_hide": 0,
@@ -269,7 +251,6 @@
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
"label": "Actual Quantity",
@@ -279,7 +260,6 @@
"oldfieldtype": "Currency",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"print_width": "150px",
"read_only": 1,
"report_hide": 0,
@@ -297,7 +277,6 @@
"fieldtype": "Currency",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Incoming Rate",
@@ -308,7 +287,6 @@
"options": "Company:company:default_currency",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
@@ -324,7 +302,6 @@
"fieldtype": "Currency",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Outgoing Rate",
@@ -334,7 +311,6 @@
"permlevel": 0,
"precision": "",
"print_hide": 0,
- "print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
@@ -350,7 +326,6 @@
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Stock UOM",
@@ -361,7 +336,6 @@
"options": "UOM",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"print_width": "150px",
"read_only": 1,
"report_hide": 0,
@@ -379,7 +353,6 @@
"fieldtype": "Float",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
"label": "Actual Qty After Transaction",
@@ -389,7 +362,6 @@
"oldfieldtype": "Currency",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"print_width": "150px",
"read_only": 1,
"report_hide": 0,
@@ -407,7 +379,6 @@
"fieldtype": "Currency",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Valuation Rate",
@@ -418,7 +389,6 @@
"options": "Company:company:default_currency",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"print_width": "150px",
"read_only": 1,
"report_hide": 0,
@@ -436,7 +406,6 @@
"fieldtype": "Currency",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Stock Value",
@@ -447,7 +416,6 @@
"options": "Company:company:default_currency",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
@@ -463,7 +431,6 @@
"fieldtype": "Currency",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Stock Value Difference",
@@ -472,7 +439,6 @@
"options": "Company:company:default_currency",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 0,
"reqd": 0,
@@ -488,7 +454,6 @@
"fieldtype": "Text",
"hidden": 1,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Stock Queue (FIFO)",
@@ -498,7 +463,6 @@
"oldfieldtype": "Text",
"permlevel": 0,
"print_hide": 1,
- "print_hide_if_no_value": 0,
"read_only": 1,
"report_hide": 1,
"reqd": 0,
@@ -514,7 +478,6 @@
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Project",
@@ -523,7 +486,6 @@
"options": "Project",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 0,
"reqd": 0,
@@ -539,7 +501,6 @@
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 1,
"in_list_view": 0,
"label": "Company",
@@ -550,7 +511,32 @@
"options": "Company",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
+ "print_width": "150px",
+ "read_only": 1,
+ "report_hide": 0,
+ "reqd": 0,
+ "search_index": 0,
+ "set_only_once": 0,
+ "unique": 0,
+ "width": "150px"
+ },
+ {
+ "allow_on_submit": 0,
+ "bold": 0,
+ "collapsible": 0,
+ "fieldname": "fiscal_year",
+ "fieldtype": "Data",
+ "hidden": 0,
+ "ignore_user_permissions": 0,
+ "in_filter": 1,
+ "in_list_view": 0,
+ "label": "Fiscal Year",
+ "length": 0,
+ "no_copy": 0,
+ "oldfieldname": "fiscal_year",
+ "oldfieldtype": "Data",
+ "permlevel": 0,
+ "print_hide": 0,
"print_width": "150px",
"read_only": 1,
"report_hide": 0,
@@ -568,7 +554,6 @@
"fieldtype": "Select",
"hidden": 1,
"ignore_user_permissions": 0,
- "ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Is Cancelled",
@@ -577,7 +562,6 @@
"options": "\nNo\nYes",
"permlevel": 0,
"print_hide": 0,
- "print_hide_if_no_value": 0,
"read_only": 0,
"report_hide": 1,
"reqd": 0,
@@ -596,7 +580,7 @@
"issingle": 0,
"istable": 0,
"max_attachments": 0,
- "modified": "2016-03-04 01:46:58.056322",
+ "modified": "2015-11-16 06:29:58.277731",
"modified_by": "Administrator",
"module": "Stock",
"name": "Stock Ledger Entry",
diff --git a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
index 647b71a..9931ffa 100644
--- a/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
+++ b/erpnext/stock/doctype/stock_ledger_entry/stock_ledger_entry.py
@@ -9,6 +9,7 @@
from frappe.model.document import Document
from datetime import date
from erpnext.controllers.item_variant import ItemTemplateCannotHaveStock
+from erpnext.accounts.utils import get_fiscal_year
class StockFreezeError(frappe.ValidationError): pass
@@ -23,6 +24,10 @@
self.validate_batch()
validate_warehouse_company(self.warehouse, self.company)
self.scrub_posting_time()
+ self.validate_and_set_fiscal_year()
+
+ from erpnext.accounts.utils import validate_fiscal_year
+ validate_fiscal_year(self.posting_date, self.fiscal_year, self.meta.get_label("posting_date"), self)
def on_submit(self):
self.check_stock_frozen_date()
@@ -108,6 +113,11 @@
if getdate(self.posting_date) > getdate(expiry_date):
frappe.throw(_("Batch {0} of Item {1} has expired.").format(self.batch_no, self.item_code))
+ def validate_and_set_fiscal_year(self):
+ if not self.fiscal_year:
+ self.fiscal_year = get_fiscal_year(self.posting_date, company=self.company)[0]
+
+
def on_doctype_update():
if not frappe.db.sql("""show index from `tabStock Ledger Entry`
where Key_name="posting_sort_index" """):