Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
commit
cf9668758a
@ -23,6 +23,11 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
// Refresh
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
if(doc.__islocal) {
|
||||
msgprint("Please create new account from Chart of Accounts.");
|
||||
throw "cannot create";
|
||||
}
|
||||
|
||||
cur_frm.toggle_display('account_name', doc.__islocal);
|
||||
|
||||
// hide fields if group
|
||||
@ -34,7 +39,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
'is_pl_account', 'company'], false);
|
||||
|
||||
// read-only for root accounts
|
||||
root_acc = ['Application of Funds (Assets)','Expenses','Income','Source of Funds (Liabilities)'];
|
||||
root_acc = doc.parent ? false : true;
|
||||
if(in_list(root_acc, doc.account_name)) {
|
||||
cur_frm.perm = [[1,0,0], [1,0,0]];
|
||||
cur_frm.set_intro("This is a root account and cannot be edited.");
|
||||
@ -48,7 +53,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
cur_frm.cscript.account_type(doc, cdt, cdn);
|
||||
|
||||
// show / hide convert buttons
|
||||
cur_frm.cscript.hide_unhide_group_ledger(doc);
|
||||
cur_frm.cscript.add_toolbar_buttons(doc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,7 +81,10 @@ cur_frm.cscript.account_type = function(doc, cdt, cdn) {
|
||||
|
||||
// Hide/unhide group or ledger
|
||||
// -----------------------------------------
|
||||
cur_frm.cscript.hide_unhide_group_ledger = function(doc) {
|
||||
cur_frm.cscript.add_toolbar_buttons = function(doc) {
|
||||
cur_frm.add_custom_button('Chart of Accounts',
|
||||
function() { wn.set_route("Accounts Browser", "Account"); }, 'icon-list')
|
||||
|
||||
if (cstr(doc.group_or_ledger) == 'Group') {
|
||||
cur_frm.add_custom_button('Convert to Ledger',
|
||||
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet')
|
||||
|
@ -61,10 +61,13 @@ class DocType:
|
||||
elif par and not self.doc.is_pl_account:
|
||||
self.doc.is_pl_account = par[0][2]
|
||||
self.doc.debit_or_credit = par[0][3]
|
||||
elif self.doc.account_name not in ['Income','Source of Funds (Liabilities)',\
|
||||
'Expenses','Application of Funds (Assets)']:
|
||||
msgprint("Parent Account is mandatory", raise_exception=1)
|
||||
|
||||
def validate_max_root_accounts(self):
|
||||
if webnotes.conn.sql("""select count(*) from tabAccount where
|
||||
company=%s and ifnull(parent_account,'')='' and docstatus != 2""",
|
||||
self.doc.company)[0][0] > 4:
|
||||
webnotes.msgprint("One company cannot have more than 4 root Accounts",
|
||||
raise_exception=1)
|
||||
|
||||
# Account name must be unique
|
||||
def validate_duplicate_account(self):
|
||||
@ -74,21 +77,10 @@ class DocType:
|
||||
|
||||
def validate_root_details(self):
|
||||
#does not exists parent
|
||||
if self.doc.account_name in ['Income','Source of Funds', 'Expenses','Application of Funds'] and self.doc.parent_account:
|
||||
msgprint("You can not assign parent for root account", raise_exception=1)
|
||||
|
||||
# Debit / Credit
|
||||
if self.doc.account_name in ['Income','Source of Funds']:
|
||||
self.doc.debit_or_credit = 'Credit'
|
||||
elif self.doc.account_name in ['Expenses','Application of Funds']:
|
||||
self.doc.debit_or_credit = 'Debit'
|
||||
|
||||
# Is PL Account
|
||||
if self.doc.account_name in ['Income','Expenses']:
|
||||
self.doc.is_pl_account = 'Yes'
|
||||
elif self.doc.account_name in ['Source of Funds','Application of Funds']:
|
||||
self.doc.is_pl_account = 'No'
|
||||
|
||||
if webnotes.conn.exists("Account", self.doc.name):
|
||||
if not self.doc.get_value("Account", self.doc.name, "parent_account"):
|
||||
webnotes.msgprint("Root cannot be edited.", raise_exception=1)
|
||||
|
||||
def convert_group_to_ledger(self):
|
||||
if self.check_if_child_exists():
|
||||
msgprint("Account: %s has existing child. You can not convert this account to ledger" % (self.doc.name), raise_exception=1)
|
||||
@ -144,6 +136,7 @@ class DocType:
|
||||
|
||||
def on_update(self):
|
||||
# update nsm
|
||||
self.validate_max_root_accounts()
|
||||
self.update_nsm_model()
|
||||
|
||||
# Check user role for approval process
|
||||
|
@ -52,6 +52,12 @@ pscript['onload_Accounts Browser'] = function(wrapper){
|
||||
wrapper.$company_select.val(sys_defaults.company || r[0]).change();
|
||||
}
|
||||
});
|
||||
|
||||
// refresh on rename
|
||||
$(document).bind('rename', function(event, dt, old_name, new_name) {
|
||||
if(erpnext.account_chart.ctype==dt)
|
||||
wrapper.$company_select.change();
|
||||
});
|
||||
}
|
||||
|
||||
pscript['onshow_Accounts Browser'] = function(wrapper){
|
||||
@ -71,6 +77,11 @@ erpnext.AccountsChart = Class.extend({
|
||||
$(wrapper).find('.tree-area').empty();
|
||||
var me = this;
|
||||
me.ctype = ctype;
|
||||
me.can_create = wn.boot.profile.can_create.indexOf(this.ctype);
|
||||
me.can_delete = wn.model.can_delete(this.ctype);
|
||||
me.can_write = wn.boot.profile.can_write.indexOf(this.ctype);
|
||||
|
||||
|
||||
me.company = company;
|
||||
this.tree = new wn.ui.Tree({
|
||||
parent: $(wrapper).find('.tree-area'),
|
||||
@ -116,17 +127,24 @@ erpnext.AccountsChart = Class.extend({
|
||||
var node_links = [];
|
||||
// edit
|
||||
if (wn.boot.profile.can_read.indexOf(this.ctype) !== -1) {
|
||||
node_links.push('<a href="#!Form/'+encodeURIComponent(this.ctype)+'/'
|
||||
node_links.push('<a href="#Form/'+encodeURIComponent(this.ctype)+'/'
|
||||
+encodeURIComponent(data.value)+'">Edit</a>');
|
||||
}
|
||||
if (data.expandable) {
|
||||
if((wn.boot.profile.can_create.indexOf(this.ctype) !== -1) ||
|
||||
(wn.boot.profile.in_create.indexOf(this.ctype) !== -1)) {
|
||||
if(this.can_create) {
|
||||
node_links.push('<a onclick="erpnext.account_chart.new_node();">Add Child</a>');
|
||||
}
|
||||
} else if (this.ctype === 'Account' && wn.boot.profile.can_read.indexOf("GL Entry") !== -1) {
|
||||
node_links.push('<a onclick="erpnext.account_chart.show_ledger();">View Ledger</a>');
|
||||
}
|
||||
|
||||
if (this.can_write !== -1) {
|
||||
node_links.push('<a onclick="erpnext.account_chart.rename()">Rename</a>');
|
||||
};
|
||||
|
||||
if (this.can_delete !== -1) {
|
||||
node_links.push('<a onclick="erpnext.account_chart.delete()">Delete</a>');
|
||||
};
|
||||
|
||||
link.toolbar.append(node_links.join(" | "));
|
||||
},
|
||||
@ -135,6 +153,18 @@ erpnext.AccountsChart = Class.extend({
|
||||
var node = me.selected_node();
|
||||
wn.set_route("general-ledger", "account=" + node.data('label'));
|
||||
},
|
||||
rename: function() {
|
||||
var me = this;
|
||||
var node = me.selected_node();
|
||||
wn.model.rename_doc("Account", node.data('label'));
|
||||
},
|
||||
delete: function() {
|
||||
var me = this;
|
||||
var node = me.selected_node();
|
||||
wn.model.delete_doc("Account", node.data('label'), function() {
|
||||
node.parent().remove();
|
||||
});
|
||||
},
|
||||
new_node: function() {
|
||||
if(this.ctype=='Account') {
|
||||
this.new_account();
|
||||
@ -216,6 +246,8 @@ erpnext.AccountsChart = Class.extend({
|
||||
$(fd.group_or_ledger.input).change();
|
||||
$(fd.account_type.input).change();
|
||||
}
|
||||
|
||||
$(fd.group_or_ledger.input).val("Ledger").change();
|
||||
d.show();
|
||||
},
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
"docstatus": 0,
|
||||
"creation": "2012-08-06 20:00:37",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2012-08-06 17:14:19"
|
||||
"modified": "2012-08-06 17:14:18"
|
||||
},
|
||||
{
|
||||
"is_submittable": 1,
|
||||
|
@ -1,4 +1,8 @@
|
||||
erpnext.updates = [
|
||||
["3rd December 2012", [
|
||||
"Rename Tool: Documents that can be renamed will have a 'Rename' option in the sidebar (wherever applicable).",
|
||||
"Chart of Accounts: Ability to rename / delete from Chart of Accouns.",
|
||||
]],
|
||||
["30th November 2012", [
|
||||
"Auto Notifications: System will prompt user with pre-set message for auto-notification.",
|
||||
"Employee: Users with role Employee will only be able to see their Employee Records.",
|
||||
|
@ -2,19 +2,20 @@
|
||||
{
|
||||
"owner": "Administrator",
|
||||
"docstatus": 0,
|
||||
"creation": "2012-11-24 17:21:44",
|
||||
"creation": "2012-12-03 10:31:06",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2012-11-30 10:54:00"
|
||||
"modified": "2012-12-03 13:57:32"
|
||||
},
|
||||
{
|
||||
"is_submittable": 1,
|
||||
"autoname": "naming_series:",
|
||||
"name": "__common__",
|
||||
"description": "Potential Sales Deal",
|
||||
"default_print_format": "Standard",
|
||||
"search_fields": "status,transaction_date,customer,lead,enquiry_type,territory,company",
|
||||
"module": "Selling",
|
||||
"doctype": "DocType",
|
||||
"document_type": "Transaction"
|
||||
"document_type": "Transaction",
|
||||
"name": "__common__"
|
||||
},
|
||||
{
|
||||
"name": "__common__",
|
||||
@ -35,16 +36,6 @@
|
||||
"name": "Opportunity",
|
||||
"doctype": "DocType"
|
||||
},
|
||||
{
|
||||
"description": "Enter customer enquiry for which you might raise a quotation in future",
|
||||
"oldfieldtype": "Section Break",
|
||||
"colour": "White:FFF",
|
||||
"doctype": "DocField",
|
||||
"label": "Basic Info",
|
||||
"fieldname": "basic_info",
|
||||
"fieldtype": "Section Break",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"description": "To manage multiple series please go to Setup > Manage Series",
|
||||
"no_copy": 1,
|
||||
@ -474,14 +465,24 @@
|
||||
"fieldtype": "Date",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"submit": 0,
|
||||
"write": 0,
|
||||
"cancel": 0,
|
||||
"role": "Sales Manager",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
"amend": 1,
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"submit": 1,
|
||||
"write": 1,
|
||||
"role": "System Manager",
|
||||
"cancel": 1,
|
||||
"role": "System Manager",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
@ -495,8 +496,8 @@
|
||||
"doctype": "DocPerm",
|
||||
"submit": 1,
|
||||
"write": 1,
|
||||
"role": "Sales User",
|
||||
"cancel": 1,
|
||||
"role": "Sales User",
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
@ -505,8 +506,8 @@
|
||||
"doctype": "DocPerm",
|
||||
"submit": 0,
|
||||
"write": 0,
|
||||
"role": "Sales User",
|
||||
"cancel": 0,
|
||||
"role": "Sales User",
|
||||
"permlevel": 1
|
||||
},
|
||||
{
|
||||
@ -515,18 +516,8 @@
|
||||
"doctype": "DocPerm",
|
||||
"submit": 1,
|
||||
"write": 1,
|
||||
"role": "Sales Manager",
|
||||
"cancel": 1,
|
||||
"permlevel": 0
|
||||
},
|
||||
{
|
||||
"amend": 0,
|
||||
"create": 0,
|
||||
"doctype": "DocPerm",
|
||||
"submit": 0,
|
||||
"write": 0,
|
||||
"role": "Sales Manager",
|
||||
"cancel": 0,
|
||||
"permlevel": 1
|
||||
"permlevel": 0
|
||||
}
|
||||
]
|
@ -46,8 +46,8 @@
|
||||
<span class="help">Un-trash items</span>
|
||||
</p>
|
||||
<p>
|
||||
<b><a href="#!Form/Rename Tool/Rename Tool">Rename Master</a></b><br>
|
||||
<span class="help">Rename a single master record</span>
|
||||
<b>Rename Master</b><br>
|
||||
<span class="help">Click on "Rename" on the sidebar of an item for renaming.</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="setup-column">
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1 +0,0 @@
|
||||
from __future__ import unicode_literals
|
@ -1,21 +0,0 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// over-ride the link query to return relevant link names
|
||||
|
||||
cur_frm.fields_dict.document_to_rename.get_query = function(doc, dt, dn) {
|
||||
return "SELECT name FROM `tab"+doc.select_doctype+"` WHERE docstatus<2 AND name LIKE '%s' LIMIT 50";
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
# ERPNext - web based ERP (http://erpnext.com)
|
||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
class DocType:
|
||||
def __init__(self, d, dl=[]):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def rename(self):
|
||||
"""
|
||||
Generate update quereies for rename
|
||||
"""
|
||||
import webnotes.model
|
||||
|
||||
# rename the document
|
||||
webnotes.model.rename(self.doc.select_doctype, self.doc.document_to_rename, self.doc.new_name)
|
||||
|
||||
webnotes.msgprint("Successfully renamed "+self.doc.select_doctype+" : '"+self.doc.document_to_rename+"' to <b>"+self.doc.new_name+"</b>")
|
@ -1,73 +0,0 @@
|
||||
[
|
||||
{
|
||||
"owner": "Administrator",
|
||||
"docstatus": 0,
|
||||
"creation": "2012-11-30 18:14:18",
|
||||
"modified_by": "Administrator",
|
||||
"modified": "2012-12-03 09:48:37"
|
||||
},
|
||||
{
|
||||
"allow_email": 1,
|
||||
"hide_heading": 0,
|
||||
"issingle": 1,
|
||||
"name": "__common__",
|
||||
"allow_print": 1,
|
||||
"doctype": "DocType",
|
||||
"module": "Utilities",
|
||||
"hide_toolbar": 0
|
||||
},
|
||||
{
|
||||
"name": "__common__",
|
||||
"parent": "Rename Tool",
|
||||
"doctype": "DocField",
|
||||
"parenttype": "DocType",
|
||||
"permlevel": 0,
|
||||
"parentfield": "fields"
|
||||
},
|
||||
{
|
||||
"parent": "Rename Tool",
|
||||
"read": 1,
|
||||
"name": "__common__",
|
||||
"create": 1,
|
||||
"doctype": "DocPerm",
|
||||
"write": 1,
|
||||
"parenttype": "DocType",
|
||||
"role": "System Manager",
|
||||
"permlevel": 0,
|
||||
"parentfield": "permissions"
|
||||
},
|
||||
{
|
||||
"name": "Rename Tool",
|
||||
"doctype": "DocType"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Select DocType",
|
||||
"fieldname": "select_doctype",
|
||||
"fieldtype": "Select",
|
||||
"options": "\nAccount\nCompany\nCustomer\nSupplier\nEmployee\nWarehouse\nItem\nProfile\nSerial No"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Document to rename",
|
||||
"fieldname": "document_to_rename",
|
||||
"fieldtype": "Link",
|
||||
"options": "[Select]"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "New Name",
|
||||
"fieldname": "new_name",
|
||||
"fieldtype": "Data"
|
||||
},
|
||||
{
|
||||
"doctype": "DocField",
|
||||
"label": "Rename",
|
||||
"fieldname": "rename",
|
||||
"fieldtype": "Button",
|
||||
"options": "rename"
|
||||
},
|
||||
{
|
||||
"doctype": "DocPerm"
|
||||
}
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user