Fixes in account query, fiscal year and cost center

This commit is contained in:
Anand Doshi 2014-04-28 20:33:33 +05:30
parent 6777efa7fa
commit cd17bdffcd
4 changed files with 30 additions and 13 deletions

View File

@ -1,8 +1,18 @@
// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
cur_frm.add_fetch("bank_account", "company", "company");
cur_frm.cscript.onload = function(doc, cdt, cdn){
cur_frm.set_intro('<i class="icon-question" /> ' +
__("Update clearance date of Journal Entries marked as 'Bank Vouchers'"))
}
cur_frm.set_intro('<i class="icon-question" /> ' +
__("Update clearance date of Journal Entries marked as 'Bank Vouchers'"));
cur_frm.add_fetch("bank_account", "company", "company");
cur_frm.set_query("bank_account", function() {
return {
"filters": {
"account_type": "Bank",
"group_or_ledger": "Ledger"
}
};
});
}

View File

@ -64,7 +64,10 @@ class CostCenter(NestedSet):
"""
Cost Center name must be unique
"""
if (self.get("__islocal") or not self.name) and frappe.db.sql("select name from `tabCost Center` where cost_center_name = %s and company=%s", (self.cost_center_name, self.company)):
if ((self.get("__islocal") or not self.name) and
frappe.db.sql("select name from `tabCost Center` where cost_center_name=%s and company=%s",
(self.cost_center_name, self.company))
):
msgprint(_("Cost Center Name already exists"), raise_exception=1)
self.validate_mandatory()

View File

@ -2,15 +2,23 @@
// License: GNU General Public License v3. See license.txt
$.extend(cur_frm.cscript, {
onload: function() {
if(cur_frm.doc.__islocal) {
cur_frm.set_value("year_start_date",
frappe.datetime.add_days(frappe.defaults.get_default("year_end_date"), 1));
}
},
refresh: function (doc, dt, dn) {
var me = this;
this.frm.toggle_enable('year_start_date', doc.__islocal)
this.frm.toggle_enable('year_end_date', doc.__islocal)
if (!doc.__islocal && (doc.name != sys_defaults.fiscal_year)) {
this.frm.add_custom_button(__("Set as Default"), this.frm.cscript.set_as_default);
this.frm.set_intro(__("To set this Fiscal Year as Default, click on 'Set as Default'"));
} else this.frm.set_intro("");
} else {
this.frm.set_intro("");
}
},
set_as_default: function() {
return frappe.call({
@ -21,8 +29,8 @@ $.extend(cur_frm.cscript, {
year_start_date: function(doc, dt, dn) {
var me = this;
year_end_date =
year_end_date =
frappe.datetime.add_days(frappe.datetime.add_months(this.frm.doc.year_start_date, 12), -1);
this.frm.set_value("year_end_date", year_end_date);
},
});
});

View File

@ -20,10 +20,6 @@ $.extend(erpnext.queries, {
return { query: "erpnext.controllers.queries.supplier_query" };
},
account: function() {
return { query: "erpnext.controllers.queries.account_query" };
},
item: function(filters) {
var args = { query: "erpnext.controllers.queries.item_query" };
if(filters) args["filters"] = filters;