Merge pull request #9858 from mbauskar/expense-claim
[minor] don't trigger the expense type trigger if value is not set
diff --git a/erpnext/accounts/doctype/account/account.js b/erpnext/accounts/doctype/account/account.js
index 8a9a439..ed7e39a 100644
--- a/erpnext/accounts/doctype/account/account.js
+++ b/erpnext/accounts/doctype/account/account.js
@@ -1,94 +1,94 @@
-// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
+// Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
-
-cur_frm.cscript.refresh = function (doc, cdt, cdn) {
- if (doc.__islocal) {
- frappe.msgprint(__("Please create new account from Chart of Accounts."));
- throw "cannot create";
- }
-
- cur_frm.toggle_display('account_name', doc.__islocal);
-
- // hide fields if group
- cur_frm.toggle_display(['account_type', 'tax_rate'], cint(doc.is_group) == 0)
-
- // disable fields
- cur_frm.toggle_enable(['account_name', 'is_group', 'company'], false);
-
- if (cint(doc.is_group) == 0) {
- cur_frm.toggle_display('freeze_account', doc.__onload && doc.__onload.can_freeze_account);
- }
-
- // read-only for root accounts
- if (!doc.parent_account) {
- cur_frm.set_read_only();
- cur_frm.set_intro(__("This is a root account and cannot be edited."));
- } else {
- // credit days and type if customer or supplier
- cur_frm.set_intro(null);
-
- cur_frm.cscript.account_type(doc, cdt, cdn);
-
- // show / hide convert buttons
- cur_frm.cscript.add_toolbar_buttons(doc);
- }
-}
-
-cur_frm.add_fetch('parent_account', 'report_type', 'report_type');
-cur_frm.add_fetch('parent_account', 'root_type', 'root_type');
-
-cur_frm.cscript.account_type = function (doc, cdt, cdn) {
- if (doc.is_group == 0) {
- cur_frm.toggle_display(['tax_rate'], doc.account_type == 'Tax');
- cur_frm.toggle_display('warehouse', doc.account_type == 'Stock');
- }
-}
-
-cur_frm.cscript.add_toolbar_buttons = function (doc) {
- cur_frm.add_custom_button(__('Chart of Accounts'),
- function () { frappe.set_route("Tree", "Account"); });
-
- if (doc.is_group == 1) {
- cur_frm.add_custom_button(__('Group to Non-Group'),
- function () { cur_frm.cscript.convert_to_ledger(); }, 'fa fa-retweet', 'btn-default');
- } else if (cint(doc.is_group) == 0) {
- cur_frm.add_custom_button(__('Ledger'), function () {
- frappe.route_options = {
- "account": doc.name,
- "from_date": frappe.sys_defaults.year_start_date,
- "to_date": frappe.sys_defaults.year_end_date,
- "company": doc.company
+frappe.ui.form.on('Account', {
+ setup: function(frm) {
+ frm.add_fetch('parent_account', 'report_type', 'report_type');
+ frm.add_fetch('parent_account', 'root_type', 'root_type');
+ },
+ onload: function(frm) {
+ frm.set_query('parent_account', function(doc) {
+ return {
+ filters: {
+ "is_group": 1,
+ "company": doc.company
+ }
};
- frappe.set_route("query-report", "General Ledger");
});
+ },
+ refresh: function(frm) {
+ if (frm.doc.__islocal) {
+ frappe.msgprint(__("Please create new account from Chart of Accounts."));
+ throw "cannot create";
+ }
- cur_frm.add_custom_button(__('Non-Group to Group'),
- function () { cur_frm.cscript.convert_to_group(); }, 'fa fa-retweet', 'btn-default')
+ frm.toggle_display('account_name', frm.doc.__islocal);
+
+ // hide fields if group
+ frm.toggle_display(['account_type', 'tax_rate'], cint(frm.doc.is_group) == 0);
+
+ // disable fields
+ frm.toggle_enable(['account_name', 'is_group', 'company'], false);
+
+ if (cint(frm.doc.is_group) == 0) {
+ frm.toggle_display('freeze_account', frm.doc.__onload
+ && frm.doc.__onload.can_freeze_account);
+ }
+
+ // read-only for root accounts
+ if (!frm.doc.parent_account) {
+ frm.set_read_only();
+ frm.set_intro(__("This is a root account and cannot be edited."));
+ } else {
+ // credit days and type if customer or supplier
+ frm.set_intro(null);
+ frm.trigger('account_type');
+
+ // show / hide convert buttons
+ frm.trigger('add_toolbar_buttons');
+ }
+ },
+ account_type: function (frm) {
+ if (frm.doc.is_group == 0) {
+ frm.toggle_display(['tax_rate'], frm.doc.account_type == 'Tax');
+ frm.toggle_display('warehouse', frm.doc.account_type == 'Stock');
+ }
+ },
+ add_toolbar_buttons: function(frm) {
+ frm.add_custom_button(__('Chart of Accounts'),
+ function () { frappe.set_route("Tree", "Account"); });
+
+ if (frm.doc.is_group == 1) {
+ frm.add_custom_button(__('Group to Non-Group'), function () {
+ return frappe.call({
+ doc: frm.doc,
+ method: 'convert_group_to_ledger',
+ callback: function() {
+ frm.refresh();
+ }
+ });
+ });
+ } else if (cint(frm.doc.is_group) == 0) {
+ cur_frm.add_custom_button(__('Ledger'), function () {
+ frappe.route_options = {
+ "account": frm.doc.name,
+ "from_date": frappe.sys_defaults.year_start_date,
+ "to_date": frappe.sys_defaults.year_end_date,
+ "company": frm.doc.company
+ };
+ frappe.set_route("query-report", "General Ledger");
+ });
+
+ frm.add_custom_button(__('Non-Group to Group'), function () {
+ return frappe.call({
+ doc: frm.doc,
+ method: 'convert_ledger_to_group',
+ callback: function() {
+ frm.refresh();
+ }
+ });
+ });
+ }
+
}
-}
-
-cur_frm.cscript.convert_to_ledger = function (doc, cdt, cdn) {
- return $c_obj(cur_frm.doc, 'convert_group_to_ledger', '', function (r, rt) {
- if (r.message == 1) {
- cur_frm.refresh();
- }
- });
-}
-
-cur_frm.cscript.convert_to_group = function (doc, cdt, cdn) {
- return $c_obj(cur_frm.doc, 'convert_ledger_to_group', '', function (r, rt) {
- if (r.message == 1) {
- cur_frm.refresh();
- }
- });
-}
-
-cur_frm.fields_dict['parent_account'].get_query = function (doc) {
- return {
- filters: {
- "is_group": 1,
- "company": doc.company
- }
- }
-}
+});
\ No newline at end of file
diff --git a/erpnext/hooks.py b/erpnext/hooks.py
index 6ff0a13..fedc6d5 100644
--- a/erpnext/hooks.py
+++ b/erpnext/hooks.py
@@ -79,13 +79,7 @@
"parents": [{"title": _("Supplier Quotation"), "name": "quotations"}]
}
},
- {"from_route": "/quotes", "to_route": "Quotation"},
- {"from_route": "/quotes/<path:name>", "to_route": "order",
- "defaults": {
- "doctype": "Quotation",
- "parents": [{"title": _("Quotes"), "name": "quotes"}]
- }
- },
+ {"from_route": "/quotation", "to_route": "Quotation"},
{"from_route": "/shipments", "to_route": "Delivery Note"},
{"from_route": "/shipments/<path:name>", "to_route": "order",
"defaults": {
@@ -116,7 +110,7 @@
{"title": _("Projects"), "route": "/project", "reference_doctype": "Project"},
{"title": _("Request for Quotations"), "route": "/rfq", "reference_doctype": "Request for Quotation", "role": "Supplier"},
{"title": _("Supplier Quotation"), "route": "/quotations", "reference_doctype": "Supplier Quotation", "role": "Supplier"},
- {"title": _("Quotes"), "route": "/quotes", "reference_doctype": "Quotation", "role":"Customer"},
+ {"title": _("Quotations"), "route": "/quotation", "reference_doctype": "Quotation", "role":"Customer"},
{"title": _("Orders"), "route": "/orders", "reference_doctype": "Sales Order", "role":"Customer"},
{"title": _("Invoices"), "route": "/invoices", "reference_doctype": "Sales Invoice", "role":"Customer"},
{"title": _("Shipments"), "route": "/shipments", "reference_doctype": "Delivery Note", "role":"Customer"},
diff --git a/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py b/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py
index d0e816a..2b92b17 100644
--- a/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py
+++ b/erpnext/patches/v7_0/fix_nonwarehouse_ledger_gl_entries_for_transactions.py
@@ -7,10 +7,11 @@
def execute():
frappe.reload_doctype("Account")
- warehouses = frappe.db.sql_list("""select name, company from tabAccount
+ warehouses = frappe.db.sql("""select name, company from tabAccount
where account_type = 'Stock' and is_group = 0
- and (warehouse is null or warehouse = '')""", as_dict)
+ and (warehouse is null or warehouse = '')""", as_dict=1)
warehouses = [d.name for d in warehouses if erpnext.is_perpetual_inventory_enabled(d.company)]
+
if len(warehouses) > 0:
warehouses = set_warehouse_for_stock_account(warehouses)
if not warehouses:
diff --git a/erpnext/selling/doctype/quotation/quotation.py b/erpnext/selling/doctype/quotation/quotation.py
index a4d4bf9..420b84a 100644
--- a/erpnext/selling/doctype/quotation/quotation.py
+++ b/erpnext/selling/doctype/quotation/quotation.py
@@ -93,7 +93,7 @@
'show_sidebar': True,
'show_search': True,
'no_breadcrumbs': True,
- 'title': _('Quotes'),
+ 'title': _('Quotations'),
})
return list_context
diff --git a/erpnext/tests/ui/accounts/test_account.js b/erpnext/tests/ui/accounts/test_account.js
new file mode 100644
index 0000000..6d7709b
--- /dev/null
+++ b/erpnext/tests/ui/accounts/test_account.js
@@ -0,0 +1,27 @@
+QUnit.module('accounts');
+
+QUnit.test("test account", function(assert) {
+ assert.expect(4);
+ let done = assert.async();
+ frappe.run_serially([
+ () => frappe.set_route('Tree', 'Account'),
+ () => frappe.tests.click_button('Expand All'),
+ () => frappe.tests.click_link('Debtors'),
+ () => frappe.tests.click_button('Edit'),
+ () => frappe.timeout(1),
+ () => {
+ assert.ok(cur_frm.doc.root_type=='Asset');
+ assert.ok(cur_frm.doc.report_type=='Balance Sheet');
+ assert.ok(cur_frm.doc.account_type=='Receivable');
+ },
+ () => frappe.tests.click_button('Ledger'),
+ () => frappe.timeout(1),
+ () => {
+ // check if general ledger report shown
+ assert.deepEqual(frappe.get_route(), ['query-report', 'General Ledger']);
+ window.history.back();
+ return frappe.timeout(1);
+ },
+ () => done()
+ ]);
+});