Merge branch 'dev' of github.com:webnotes/erpnext into dev

This commit is contained in:
Nabin Hait 2012-07-11 11:54:08 +05:30
commit e4e78b469a
12 changed files with 370 additions and 413 deletions

View File

@ -14,6 +14,41 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// Onload
// -----------------------------------------
cur_frm.cscript.onload = function(doc, cdt, cdn) {
}
// Refresh
// -----------------------------------------
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
// read-only for root accounts
root_acc = ['Application of Funds (Assets)','Expenses','Income','Source of Funds (Liabilities)'];
if(inList(root_acc, doc.account_name))
cur_frm.perm = [[1,0,0], [1,0,0]];
// hide fields if group
cur_frm.toggle_fields(['account_type', 'master_type', 'master_name', 'freeze_account',
'credit_days', 'credit_limit'], doc.group_or_ledger=='Ledger')
// credit days and type if customer or supplier
cur_frm.toggle_fields(['credit_days', 'credit_limit'],
in_list(['Customer', 'Supplier'], doc.master_type))
// hide tax_rate
cur_frm.cscript.account_type(doc, cdt, cdn);
// show / hide convert buttons
cur_frm.cscript.hide_unhide_group_ledger(doc);
// back to chart of accounts
cur_frm.add_custom_button('Back To Chart of Accounts', function() {
wn.set_route('Accounts Browser', 'Account');
}, 'icon-arrow-left')
}
// Fetch parent details
// -----------------------------------------
cur_frm.add_fetch('parent_account', 'debit_or_credit', 'debit_or_credit');
@ -22,47 +57,28 @@ cur_frm.add_fetch('parent_account', 'is_pl_account', 'is_pl_account');
// Hide tax rate based on account type
// -----------------------------------------
cur_frm.cscript.account_type = function(doc, cdt, cdn) {
if(doc.account_type == 'Tax') unhide_field(['tax_rate']);
else hide_field(['tax_rate']);
}
// Onload
// -----------------------------------------
cur_frm.cscript.onload = function(doc, cdt, cdn) {
cur_frm.cscript.account_type(doc, cdt, cdn);
// hide India specific fields
var cp = wn.control_panel;
if(cp.country == 'India')
unhide_field(['pan_number', 'tds_applicable', 'tds_details', 'tds']);
else
hide_field(['pan_number', 'tds_applicable', 'tds_details', 'tds']);
}
// Refresh
// -----------------------------------------
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
root_acc = [' Application of Funds (Assets)','Expenses','Income','Source of Funds (Liabilities)'];
if(inList(root_acc, doc.account_name))
cur_frm.perm = [[1,0,0], [1,0,0]];
cur_frm.cscript.hide_unhide_group_ledger(doc);
cur_frm.toggle_fields(['tax_rate'], doc.account_type == 'Tax')
cur_frm.toggle_fields(['master_type', 'master_name'], cstr(doc.account_type)=='')
}
// Hide/unhide group or ledger
// -----------------------------------------
cur_frm.cscript.hide_unhide_group_ledger = function(doc) {
hide_field(['convert_to_group', 'convert_to_ledger']);
if (cstr(doc.group_or_ledger) == 'Group') unhide_field('convert_to_ledger');
else if (cstr(doc.group_or_ledger) == 'Ledger') unhide_field('convert_to_group');
if (cstr(doc.group_or_ledger) == 'Group') {
cur_frm.add_custom_button('Convert to Ledger',
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet')
} else if (cstr(doc.group_or_ledger) == 'Ledger') {
cur_frm.add_custom_button('Convert to Group',
function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet')
}
}
// Convert group to ledger
// -----------------------------------------
cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
$c_obj(make_doclist(cdt,cdn),'convert_group_to_ledger','',function(r,rt) {
$c_obj(cur_frm.get_doclist(),'convert_group_to_ledger','',function(r,rt) {
if(r.message == 1) {
doc.group_or_ledger = 'Ledger';
refresh_field('group_or_ledger');
cur_frm.cscript.hide_unhide_group_ledger(doc);
cur_frm.cscript.hide_unhide_group_ledger(cur_frm.get_doc());
}
});
}
@ -70,11 +86,11 @@ cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
// Convert ledger to group
// -----------------------------------------
cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) {
$c_obj(make_doclist(cdt,cdn),'convert_ledger_to_group','',function(r,rt) {
$c_obj(cur_frm.get_doclist(),'convert_ledger_to_group','',function(r,rt) {
if(r.message == 1) {
doc.group_or_ledger = 'Group';
refresh_field('group_or_ledger');
cur_frm.cscript.hide_unhide_group_ledger(doc);
cur_frm.cscript.hide_unhide_group_ledger(cur_frm.get_doc());
}
});
}
@ -85,11 +101,13 @@ cur_frm.fields_dict['master_name'].get_query=function(doc){
if (doc.master_type){
return 'SELECT `tab'+doc.master_type+'`.name FROM `tab'+doc.master_type+'` WHERE `tab'+doc.master_type+'`.name LIKE "%s" and `tab'+doc.master_type+'`.docstatus != 2 ORDER BY `tab'+doc.master_type+'`.name LIMIT 50';
}
else alert("Please select master type");
}
// parent account get query
// -----------------------------------------
cur_frm.fields_dict['parent_account'].get_query = function(doc){
return 'SELECT DISTINCT `tabAccount`.name FROM `tabAccount` WHERE `tabAccount`.group_or_ledger="Group" AND `tabAccount`.docstatus != 2 AND `tabAccount`.company="'+ doc.company+'" AND `tabAccount`.company is not NULL AND `tabAccount`.name LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
return 'SELECT DISTINCT `tabAccount`.name FROM `tabAccount` WHERE \
`tabAccount`.group_or_ledger="Group" AND `tabAccount`.docstatus != 2 AND \
`tabAccount`.company="'+ doc.company+'" AND `tabAccount`.company is not NULL AND \
`tabAccount`.name LIKE "%s" ORDER BY `tabAccount`.name LIMIT 50';
}

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:35:39',
'creation': '2012-07-03 13:30:50',
'docstatus': 0,
'modified': '2012-03-27 14:35:39',
'modified': '2012-07-11 09:21:01',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@ -26,7 +26,7 @@
'section_style': u'Tray',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 138
'version': 1
},
# These values are common for all DocField
@ -58,14 +58,34 @@
# DocPerm
{
'cancel': 1,
'create': 1,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Accounts User',
'role': u'Auditor',
'write': 1
},
# DocPerm
{
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Auditor',
'write': 0
},
# DocPerm
{
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 2,
'role': u'Auditor',
'write': 0
},
# DocPerm
{
'cancel': 0,
@ -86,6 +106,26 @@
'write': 0
},
# DocPerm
{
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Accounts User',
'write': 1
},
# DocPerm
{
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Accounts Manager',
'write': 1
},
# DocPerm
{
'cancel': 0,
@ -106,16 +146,6 @@
'write': 0
},
# DocPerm
{
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Accounts Manager',
'write': 1
},
# DocPerm
{
'cancel': 0,
@ -141,7 +171,7 @@
'doctype': u'DocField',
'fieldname': u'properties',
'fieldtype': u'Section Break',
'label': u'Properties',
'label': u'Account Details',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
@ -170,20 +200,6 @@
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'parent_account',
'fieldtype': u'Link',
'label': u'Parent Account',
'oldfieldname': u'parent_account',
'oldfieldtype': u'Link',
'options': u'Account',
'permlevel': 0,
'search_index': 1,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
@ -213,26 +229,6 @@
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'convert_to_group',
'fieldtype': u'Button',
'label': u'Convert to Group',
'permlevel': 0,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'convert_to_ledger',
'fieldtype': u'Button',
'label': u'Convert to Ledger',
'permlevel': 0,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
@ -262,6 +258,46 @@
# DocField
{
'doctype': u'DocField',
'fieldname': u'company',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Company',
'oldfieldname': u'company',
'oldfieldtype': u'Link',
'options': u'Company',
'permlevel': 1,
'reqd': 1,
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break1',
'fieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'parent_account',
'fieldtype': u'Link',
'label': u'Parent Account',
'oldfieldname': u'parent_account',
'oldfieldtype': u'Link',
'options': u'Account',
'permlevel': 0,
'search_index': 1,
'trigger': u'Client'
},
# DocField
{
'colour': u'White:FFF',
'description': u'Setting Account Type helps in selecting this Account in transactions.',
'doctype': u'DocField',
'fieldname': u'account_type',
'fieldtype': u'Select',
@ -278,7 +314,7 @@
# DocField
{
'colour': u'White:FFF',
'description': u'If Account Type is "Tax" then the default rate is required.',
'description': u'Rate at which this tax is applied',
'doctype': u'DocField',
'fieldname': u'tax_rate',
'fieldtype': u'Currency',
@ -292,19 +328,12 @@
# DocField
{
'doctype': u'DocField',
'fieldname': u'column_break1',
'fieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
'description': u'If the account is frozen, entries are allowed for the "Account Manager" only.',
'doctype': u'DocField',
'fieldname': u'freeze_account',
'fieldtype': u'Select',
'label': u'Freeze Account',
'label': u'Frozen',
'oldfieldname': u'freeze_account',
'oldfieldtype': u'Select',
'options': u'No\nYes',
@ -313,21 +342,7 @@
# DocField
{
'doctype': u'DocField',
'fieldname': u'company',
'fieldtype': u'Link',
'in_filter': 1,
'label': u'Company',
'oldfieldname': u'company',
'oldfieldtype': u'Link',
'options': u'Company',
'permlevel': 1,
'reqd': 1,
'search_index': 1
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'credit_days',
'fieldtype': u'Int',
@ -354,13 +369,15 @@
# DocField
{
'colour': u'White:FFF',
'description': u'If this Account represents a Customer, Supplier or Employee, set it here.',
'doctype': u'DocField',
'fieldname': u'master_type',
'fieldtype': u'Select',
'label': u'Master Type',
'oldfieldname': u'master_type',
'oldfieldtype': u'Select',
'options': u'\nNA\nSupplier\nCustomer\nEmployee',
'options': u'\nSupplier\nCustomer\nEmployee',
'permlevel': 0
},
@ -374,116 +391,5 @@
'oldfieldtype': u'Link',
'permlevel': 0,
'trigger': u'Client'
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'tds',
'fieldtype': u'Section Break',
'label': u'TDS',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'pan_number',
'fieldtype': u'Data',
'label': u'PAN Number',
'oldfieldname': u'pan_number',
'oldfieldtype': u'Data',
'permlevel': 0
},
# DocField
{
'default': u'No',
'doctype': u'DocField',
'fieldname': u'tds_applicable',
'fieldtype': u'Select',
'label': u'TDS Applicable',
'oldfieldname': u'tds_applicable',
'oldfieldtype': u'Select',
'options': u'\nYes\nNo',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'tds_details',
'fieldtype': u'Table',
'label': u'TDS Details',
'oldfieldname': u'tds_details',
'oldfieldtype': u'Table',
'options': u'TDS Detail',
'permlevel': 0
},
# DocField
{
'description': u"Don't delete this field at any cost",
'doctype': u'DocField',
'fieldname': u'old_parent',
'fieldtype': u'Link',
'hidden': 1,
'label': u'Old Parent',
'no_copy': 1,
'oldfieldname': u'old_parent',
'oldfieldtype': u'Data',
'options': u'Account',
'permlevel': 0,
'report_hide': 1
},
# DocField
{
'colour': u'White:FFF',
'description': u"Don't delete this field at any cost",
'doctype': u'DocField',
'fieldname': u'lft',
'fieldtype': u'Int',
'hidden': 1,
'in_filter': 1,
'label': u'Lft',
'no_copy': 1,
'oldfieldname': u'lft',
'oldfieldtype': u'Int',
'permlevel': 3,
'print_hide': 1,
'report_hide': 1,
'search_index': 1
},
# DocField
{
'colour': u'White:FFF',
'description': u"Don't delete this field at any cost",
'doctype': u'DocField',
'fieldname': u'rgt',
'fieldtype': u'Int',
'hidden': 1,
'in_filter': 1,
'label': u'Rgt',
'no_copy': 1,
'oldfieldname': u'rgt',
'oldfieldtype': u'Int',
'permlevel': 3,
'print_hide': 1,
'report_hide': 1,
'search_index': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'trash_reason',
'fieldtype': u'Small Text',
'label': u'Trash Reason',
'oldfieldname': u'trash_reason',
'oldfieldtype': u'Small Text',
'permlevel': 1
}
]

View File

@ -15,6 +15,30 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//onload if cost center is group
cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(!doc.__islocal && doc.docstatus == 0){
get_field(doc.doctype,'group_or_ledger',doc.name).permlevel = 1;
refresh_field('group_or_ledger');
get_field(doc.doctype,'company_name',doc.name).permlevel = 1;
refresh_field('company_name');
}
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.cscript.hide_unhide_group_ledger(doc);
cur_frm.add_custom_button('Back To Chart of Cost Centers', function() {
wn.set_route('Accounts Browser', 'Cost Center');
}, 'icon-arrow-left')
var intro_txt = '';
if(!doc.__islocal && doc.group_or_ledger=='Group') {
intro_txt += '<p><b>Note:</b> This is Cost Center is a <i>Group</i>, \
Accounting Entries are not allowed against groups.</p>';
}
cur_frm.set_intro(intro_txt);
}
//Account filtering for cost center
cur_frm.fields_dict['budget_details'].grid.get_field('account').get_query = function(doc) {
@ -38,39 +62,26 @@ cur_frm.cscript.company_name = function(doc,cdt,cdn){
get_server_fields('get_abbr','','',doc,cdt,cdn,1);
}
//onload if cost center is group
cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(!doc.__islocal && doc.docstatus == 0){
get_field(doc.doctype,'group_or_ledger',doc.name).permlevel = 1;
refresh_field('group_or_ledger');
get_field(doc.doctype,'company_name',doc.name).permlevel = 1;
refresh_field('company_name');
}
}
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.cscript.hide_unhide_group_ledger(doc);
}
// Hide/unhide group or ledger
// -----------------------------------------
cur_frm.cscript.hide_unhide_group_ledger = function(doc) {
hide_field(['convert_to_group', 'convert_to_ledger']);
if (cstr(doc.group_or_ledger) == 'Group') unhide_field('convert_to_ledger');
else if (cstr(doc.group_or_ledger) == 'Ledger') unhide_field('convert_to_group');
if (cstr(doc.group_or_ledger) == 'Group') {
cur_frm.add_custom_button('Convert to Ledger',
function() { cur_frm.cscript.convert_to_ledger(); }, 'icon-retweet')
} else if (cstr(doc.group_or_ledger) == 'Ledger') {
cur_frm.add_custom_button('Convert to Group',
function() { cur_frm.cscript.convert_to_group(); }, 'icon-retweet')
}
}
// Convert group to ledger
// -----------------------------------------
cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
$c_obj(make_doclist(cdt,cdn),'convert_group_to_ledger','',function(r,rt) {
$c_obj(cur_frm.get_doclist(),'convert_group_to_ledger','',function(r,rt) {
if(r.message == 1) {
doc.group_or_ledger = 'Ledger';
refresh_field('group_or_ledger');
cur_frm.cscript.hide_unhide_group_ledger(doc);
cur_frm.cscript.hide_unhide_group_ledger(cur_frm.get_doc());
}
});
}
@ -78,11 +89,10 @@ cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
// Convert ledger to group
// -----------------------------------------
cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) {
$c_obj(make_doclist(cdt,cdn),'convert_ledger_to_group','',function(r,rt) {
$c_obj(cur_frm.get_doclist(),'convert_ledger_to_group','',function(r,rt) {
if(r.message == 1) {
doc.group_or_ledger = 'Group';
refresh_field('group_or_ledger');
cur_frm.cscript.hide_unhide_group_ledger(doc);
cur_frm.cscript.hide_unhide_group_ledger(cur_frm.get_doc());
}
});
}

View File

@ -49,6 +49,13 @@ class DocType:
}
return ret
def validate_mandatory(self):
if not self.doc.group_or_ledger:
msgprint("Please select Group or Ledger value", raise_exception=1)
if self.doc.cost_center_name != 'Root' and not self.doc.parent_cost_center:
msgprint("Please enter parent cost center", raise_exception=1)
#-------------------------------------------------------------------------
def convert_group_to_ledger(self):
if self.check_if_child_exists():
@ -78,6 +85,16 @@ class DocType:
def check_if_child_exists(self):
return sql("select name from `tabCost Center` where parent_cost_center = %s and docstatus != 2", self.doc.name)
def validate_budget_details(self):
check_acc_list = []
for d in getlist(self.doclist, 'budget_details'):
if [d.account, d.fiscal_year] in check_acc_list:
msgprint("Account " + cstr(d.account) + "has been entered more than once for fiscal year " + cstr(d.fiscal_year), raise_exception=1)
else:
check_acc_list.append([d.account, d.fiscal_year])
#-------------------------------------------------------------------------
def validate(self):
"""
@ -86,12 +103,8 @@ class DocType:
if (self.doc.__islocal or not self.doc.name) and sql("select name from `tabCost Center` where cost_center_name = %s and company_name=%s", (self.doc.cost_center_name, self.doc.company_name)):
msgprint("Cost Center Name already exists, please rename", raise_exception=1)
check_acc_list = []
for d in getlist(self.doclist, 'budget_details'):
if [d.account, d.fiscal_year] in check_acc_list:
msgprint("Account " + cstr(d.account) + "has been entered more than once for fiscal year " + cstr(d.fiscal_year), raise_exception=1)
else:
check_acc_list.append([d.account, d.fiscal_year])
self.validate_mandatory()
self.validate_budget_details()
#-------------------------------------------------------------------------
def update_nsm_model(self):

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:35:41',
'creation': '2012-07-03 13:30:47',
'docstatus': 0,
'modified': '2012-03-27 14:35:41',
'modified': '2012-07-10 18:06:51',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@ -27,7 +27,7 @@
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 109
'version': 1
},
# These values are common for all DocField
@ -55,6 +55,42 @@
'name': u'Cost Center'
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Accounts Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Accounts Manager',
'submit': 0,
'write': 1
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Accounts User',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
@ -84,40 +120,13 @@
'role': u'All'
},
# DocPerm
# DocField
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Accounts Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 0,
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Accounts Manager',
'submit': 0,
'write': 1
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'Accounts User',
'submit': 0,
'write': 0
'doctype': u'DocField',
'fieldname': u'sb0',
'fieldtype': u'Section Break',
'label': u'Cost Center Details',
'permlevel': 0
},
# DocField
@ -148,7 +157,7 @@
# DocField
{
'description': u'Select company name first.',
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'parent_cost_center',
'fieldtype': u'Link',
@ -178,15 +187,26 @@
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'company_abbr',
'fieldtype': u'Data',
'hidden': 1,
'label': u'Company Abbr',
'oldfieldname': u'company_abbr',
'oldfieldtype': u'Data',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'cb0',
'fieldtype': u'Column Break',
'permlevel': 0,
'width': u'50%'
},
# DocField
{
'colour': u'White:FFF',
@ -209,27 +229,18 @@
# DocField
{
'colour': u'White:FFF',
'description': u'Define Budget for this Cost Center',
'doctype': u'DocField',
'fieldname': u'convert_to_group',
'fieldtype': u'Button',
'label': u'Convert to Group',
'permlevel': 0,
'trigger': u'Client'
'fieldname': u'sb1',
'fieldtype': u'Section Break',
'label': u'Budget',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'convert_to_ledger',
'fieldtype': u'Button',
'label': u'Convert to Ledger',
'permlevel': 0,
'trigger': u'Client'
},
# DocField
{
'description': u'Select Budget Distribution, if you want to track based on seasonality.',
'doctype': u'DocField',
'fieldname': u'distribution_id',
'fieldtype': u'Link',
@ -242,6 +253,8 @@
# DocField
{
'colour': u'White:FFF',
'description': u'Add rows to set budgets on Accounts. To set budget actions, see the company master.',
'doctype': u'DocField',
'fieldname': u'budget_details',
'fieldtype': u'Table',

View File

@ -421,8 +421,7 @@ class DocType:
sender='notifications+email_digest@erpnext.com',
reply_to='support@erpnext.com',
subject=self.doc.frequency + ' Digest',
msg=email_body,
from_defs=1
msg=email_body
)
except Exception, e:
webnotes.msgprint('There was a problem in sending your email. Please contact support@erpnext.com')

View File

@ -167,7 +167,7 @@ def send_welcome_mail(email, args):
'Website Settings', 'subdomain') or ""
})
if not args.get('last_name'): args['last_name'] = ''
sendmail_md(pr.email, subject="Welcome to ERPNext", msg=welcome_txt % args, from_defs=1)
sendmail_md(pr.email, subject="Welcome to ERPNext", msg=welcome_txt % args)
#
# delete user

View File

@ -2059,7 +2059,7 @@ div.fix_ff_cursor { overflow: auto; }
div.comment { color: #444; }
.small {
font-size: 11px;
font-size: 12px;
}
.help {
@ -2284,23 +2284,13 @@ div.notice {
}
.help_box, .help-box {
background-color:#FFC;
font-size: 13px;
color: #864;
padding: 7px;
background-color: #ffe;
color: #874;
padding: 9px 9px 9px 9px;
border: 1px dashed #fc7;
margin: 11px 0px;
border: 1px solid #EEB;
}
.help_box_big {
background-color:#FFC;
color: #864;
padding: 7px;
margin: 7px 0px;
border: 1px solid #EEB;
text-align: center;
font-size: 14px;
}
/*
* lib/css/legacy/forms.css
@ -2319,6 +2309,11 @@ div.form-title {
margin-right: 7px;
}
div.form-intro-area {
padding: 9px 9px 0px 9px;
margin: 0px 0px 15px 0px;
}
div.form-section-head {
margin: 11px -15px 3px -15px;
border-top: 1px solid #ccc;
@ -2328,7 +2323,7 @@ div.form-section-head {
div.form-layout-row:first-child .form-section-head {
border-top: 0px solid #ccc !important;
margin-top: 0px;
padding-top: 15px;
padding-top: 0px;
}
div.form-section-head h3 {
@ -2355,18 +2350,6 @@ div.page_break {
border-top: 1px dashed #888;
}
div.grid_tbarlinks {
border-bottom: 0px;
background-color: #CCC;
padding: 4px 4px 2px 4px;
width: 190px;
float: right;
-moz-border-radius-topleft: 5px; -moz-border-radius-topright: 5px;
-webkit-border-top-left-radius: 5px; -webkit-border-top-right-radius: 5px;
}
div.dialog_frm {
position: relative;
margin: 10px;
@ -2497,6 +2480,10 @@ div.sidebar-comment-info {
.input_area input, select, textarea {
font-size: 14px;
padding: 2px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.input_area input {
@ -2514,9 +2501,16 @@ div.sidebar-comment-info {
width: 80%;
padding: 2px 0px;
font-size: 12px;
background-color: #eee;
padding: 2px;
border: 1px solid #ddd;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.disp_area_no_val {
height: 14px;
min-height: 14px;
}
.no_img {
@ -2541,48 +2535,38 @@ div.sidebar-comment-info {
* lib/css/legacy/grid.css
*/
/* Grid */
/* --- Simple --- */
.grid_wrapper_simple {
width: 100%;
margin-bottom: 8px;
border: 1px solid #AA9;
}
.grid_head_wrapper_simple {
padding: 0px;
border-bottom: 2px solid #AAA;
}
.grid_head_wrapper_simple td {
border-right: 1px solid #AA9;
}
.grid_head_wrapper_simple td div {
padding: 2px;
}
.grid_tab_wrapper_simple {
}
.grid_cell_simple {
padding: 2px;
background-color: #fff;
border-right: 1px solid #AA9;
}
/* --- Normal --- */
.grid_wrapper {
position: relative;
overflow: auto;
border: 1px solid #AAA;
width: 100%;
margin-bottom: 8px;
background-color: #fff;
background-color: #f8f8f8;
}
div.grid_tbarlinks {
border-bottom: 0px;
padding: 4px 4px 2px 4px;
width: 190px;
float: right;
margin-right: 12px;
-webkit-border-top-left-radius: 5px;
-webkit-border-top-right-radius: 5px;
-moz-border-radius-topleft: 5px;
-moz-border-radius-topright: 5px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
background: #dddddd; /* Old browsers */
background: -moz-linear-gradient(top, #dddddd 0%, #bbbbbb 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#dddddd), color-stop(100%,#bbbbbb)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #dddddd 0%,#bbbbbb 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #dddddd 0%,#bbbbbb 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #dddddd 0%,#bbbbbb 100%); /* IE10+ */
background: linear-gradient(to bottom, #dddddd 0%,#bbbbbb 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#dddddd', endColorstr='#bbbbbb',GradientType=0 ); /* IE6-9 */
}
.grid_tab_wrapper {
@ -2613,11 +2597,19 @@ div.sidebar-comment-info {
}
.grid_head_table td {
background-color: #EEE;
border-right: 1px solid #AAA;
border-bottom: 1px solid #AAA;
height: 40px;
padding: 0px;
background: #eeeeee; /* Old browsers */
background: -moz-linear-gradient(top, #eeeeee 0%, #cccccc 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#eeeeee), color-stop(100%,#cccccc)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #eeeeee 0%,#cccccc 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #eeeeee 0%,#cccccc 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #eeeeee 0%,#cccccc 100%); /* IE10+ */
background: linear-gradient(to bottom, #eeeeee 0%,#cccccc 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#cccccc',GradientType=0 ); /* IE6-9 */
}
.grid_head_table td div {

View File

@ -1920,7 +1920,7 @@ div.fix_ff_cursor { overflow: auto; }
div.comment { color: #444; }
.small {
font-size: 11px;
font-size: 12px;
}
.help {
@ -2145,23 +2145,13 @@ div.notice {
}
.help_box, .help-box {
background-color:#FFC;
font-size: 13px;
color: #864;
padding: 7px;
background-color: #ffe;
color: #874;
padding: 9px 9px 9px 9px;
border: 1px dashed #fc7;
margin: 11px 0px;
border: 1px solid #EEB;
}
.help_box_big {
background-color:#FFC;
color: #864;
padding: 7px;
margin: 7px 0px;
border: 1px solid #EEB;
text-align: center;
font-size: 14px;
}
/*
* lib/css/legacy/dialog.css

View File

@ -28,6 +28,10 @@
.input_area input, select, textarea {
font-size: 14px;
padding: 2px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.input_area input {
@ -45,9 +49,16 @@
width: 80%;
padding: 2px 0px;
font-size: 12px;
background-color: #eee;
padding: 2px;
border: 1px solid #ddd;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.disp_area_no_val {
height: 14px;
min-height: 14px;
}
.no_img {

View File

@ -855,7 +855,7 @@ wn.ui.AppFrame=Class.extend({init:function(parent,title){this.buttons={};this.$w
<span class="close">&times;</span>\
</div>').appendTo(this.$w);this.$w.find('.close').click(function(){window.history.back();})
if(title)this.title(title);},title:function(txt){this.$titlebar.find('.appframe-title').html(txt);},add_button:function(label,click,icon){if(!this.$w.find('.appframe-toolbar').length)
this.$w.append('<div class="appframe-toolbar"></div>');args={label:label,icon:''};if(icon){args.icon='<i class="'+icon+'"></i>';}
this.$w.append('<div class="appframe-toolbar"></div>');args={label:label,icon:''};if(icon){args.icon='<i class="icon '+icon+'"></i>';}
this.buttons[label]=$(repl('<button class="btn btn-small">\
%(icon)s %(label)s</button>',args)).click(click).appendTo(this.$w.find('.appframe-toolbar'));return this.buttons[label];},clear_buttons:function(){this.$w.find('.appframe-toolbar').empty();}});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('<div class="layout-wrapper layout-wrapper-appframe">\
<div class="layout-appframe"></div>\
@ -1220,14 +1220,14 @@ args.colnames=colnames.join(',');args.report_name=report_name?report_name:'';ope
* lib/js/legacy/webpage/search.js
*/
search_fields={};function setlinkvalue(name){selector.input.set_input_value(name);selector.hide();}
function makeselector(){var d=new Dialog(540,440,'Search');d.make_body([['Data','Beginning With','Tip: You can use wildcard "%"'],['Select','Search By'],['Button','Search'],['HTML','Help'],['HTML','Result']]);var inp=d.widgets['Beginning With'];var field_sel=d.widgets['Search By'];var btn=d.widgets['Search'];d.sel_type='';d.values_len=0;d.set=function(input,type,label){d.sel_type=type;d.input=input;if(d.style!='Link'){d.rows['Result'].innerHTML='';d.values_len=0;}
function makeselector(){var d=new Dialog(540,440,'Search');d.make_body([['HTML','Help'],['Data','Beginning With','Tip: You can use wildcard "%"'],['Select','Search By'],['Button','Search'],['HTML','Result']]);var inp=d.widgets['Beginning With'];var field_sel=d.widgets['Search By'];var btn=d.widgets['Search'];d.sel_type='';d.values_len=0;d.set=function(input,type,label){d.sel_type=type;d.input=input;if(d.style!='Link'){d.rows['Result'].innerHTML='';d.values_len=0;}
d.style='Link';d.set_query_description()
if(!d.sel_type)d.sel_type='Value';d.set_title('Select a "'+d.sel_type+'" for field "'+label+'"');}
if(!d.sel_type)d.sel_type='Value';d.set_title("Select");d.set_query_description('Select a "'+d.sel_type+'" for field "'+label+'"');}
d.set_search=function(dt){if(d.style!='Search'){d.rows['Result'].innerHTML='';d.values_len=0;}
d.style='Search';if(d.input){d.input=null;sel_type=null;}
d.sel_type=get_label_doctype(dt);d.set_title('Quick Search for '+dt);}
$(inp).keydown(function(e){if(e.which==13){if(!btn.disabled)btn.onclick();}})
d.set_query_description=function(){if(d.input&&d.input.query_description){d.rows['Help'].innerHTML='<div class="help_box">'+d.input.query_description+'</div>';}else{d.rows['Help'].innerHTML=''}}
d.set_query_description=function(txt){if(!txt)txt=d.input&&d.input.query_description||null;if(txt){d.rows['Help'].innerHTML='<div class="help-box" style="margin-top:0px">'+txt+'</div>';}else{d.rows['Help'].innerHTML=''}}
d.onshow=function(){if(d.set_doctype!=d.sel_type){d.rows['Result'].innerHTML='';d.values_len=0;}
inp.value='';if(d.input&&d.input.txt.value){inp.value=d.input.txt.value;}
try{inp.focus();}catch(e){}
@ -1743,11 +1743,13 @@ this.setup_print();}
_f.Frm.prototype.setup_sidebar=function(){this.sidebar=new wn.widgets.form.sidebar.Sidebar(this);}
_f.Frm.prototype.setup_footer=function(){var me=this;var f=this.page_layout.footer;f.save_area=$a(this.page_layout.footer,'div','',{display:'none',marginTop:'11px'});f.help_area=$a(this.page_layout.footer,'div');var b=$btn(f.save_area,'Save',function(){cur_frm.save('Save');},{marginLeft:'0px'},'green');f.show_save=function(){$ds(me.page_layout.footer.save_area);}
f.hide_save=function(){$dh(me.page_layout.footer.save_area);}}
_f.Frm.prototype.set_intro=function(txt){if(!this.intro_area){this.intro_area=$('<div class="help-box form-intro-area">').insertBefore(this.page_layout.body.firstChild);}
if(txt){this.intro_area.html(txt);}else{this.intro_area.remove();this.intro_area=null;}}
_f.Frm.prototype.setup_fields_std=function(){var fl=wn.meta.docfield_list[this.doctype];fl.sort(function(a,b){return a.idx-b.idx});if(fl[0]&&fl[0].fieldtype!="Section Break"||get_url_arg('embed')){this.layout.addrow();if(fl[0].fieldtype!="Column Break"){var c=this.layout.addcell();$y(c.wrapper,{padding:'8px'});}}
var sec;for(var i=0;i<fl.length;i++){var f=fl[i];if(f.fieldtype=='Section Break'&&fl[i+1]&&fl[i+1].fieldtype=='Section Break')
continue;var fn=f.fieldname?f.fieldname:f.label;var fld=make_field(f,this.doctype,this.layout.cur_cell,this);this.fields[this.fields.length]=fld;this.fields_dict[fn]=fld;if(sec&&['Section Break','Column Break'].indexOf(f.fieldtype)==-1){fld.parent_section=sec;sec.fields.push(fld);}
if(f.fieldtype=='Section Break'){sec=fld;this.sections.push(fld);}
if((f.fieldtype=='Section Break')&&(fl[i+1])&&(fl[i+1].fieldtype!='Column Break')&&!f.hidden){var c=this.layout.addcell();$y(c.wrapper,{padding:'8px'});}}}
if((f.fieldtype=='Section Break')&&(fl[i+1])&&(fl[i+1].fieldtype!='Column Break')){var c=this.layout.addcell();$y(c.wrapper,{padding:'8px'});}}}
_f.Frm.prototype.add_custom_button=function(label,fn,icon){this.frm_head.appframe.add_button(label,fn,icon);}
_f.Frm.prototype.clear_custom_buttons=function(){this.frm_head.refresh_toolbar()}
_f.Frm.prototype.add_fetch=function(link_field,src_field,tar_field){if(!this.fetch_dict[link_field]){this.fetch_dict[link_field]={'columns':[],'fields':[]}}
@ -1847,18 +1849,21 @@ doc.__unsaved=1;var frm=wn.views.formview[d.doctype]&&wn.views.formview[d.doctyp
if(frm&&frm==cur_frm&&frm.frm_head&&!prev_unsaved){frm.frm_head.refresh_labels();}}}
_f.Frm.prototype.show_comments=function(){if(!cur_frm.comments){cur_frm.comments=new Dialog(540,400,'Comments');cur_frm.comments.comment_body=$a(cur_frm.comments.body,'div','dialog_frm');$y(cur_frm.comments.body,{backgroundColor:'#EEE'});cur_frm.comments.list=new CommentList(cur_frm.comments.comment_body);}
cur_frm.comments.list.dt=cur_frm.doctype;cur_frm.comments.list.dn=cur_frm.docname;cur_frm.comments.show();cur_frm.comments.list.run();}
_f.Frm.prototype.get_doc=function(){return locals[this.doctype][this.docname];}
_f.Frm.prototype.get_doclist=function(){return make_doclist(this.doctype,this.docname);}
_f.Frm.prototype.toggle_fields=function(fields,show){if(show){unhide_field(fields)}
else{hide_field(fields)}}
/*
* lib/js/legacy/widgets/form/form_fields.js
*/
_f.ColumnBreak=function(){this.set_input=function(){};}
_f.ColumnBreak.prototype.make_body=function(){if((!this.perm[this.df.permlevel])||(!this.perm[this.df.permlevel][READ])||this.df.hidden){return;}
this.cell=this.frm.layout.addcell(this.df.width);$y(this.cell.wrapper,{padding:'8px'});_f.cur_col_break_width=this.df.width;var fn=this.df.fieldname?this.df.fieldname:this.df.label;if(this.df&&this.df.label){this.label=$a(this.cell.wrapper,'div','','',this.df.label);}}
_f.ColumnBreak.prototype.refresh=function(layout){if(!this.cell)return;if(this.set_hidden!=this.df.hidden){if(this.df.hidden)
_f.ColumnBreak.prototype.make_body=function(){this.cell=this.frm.layout.addcell(this.df.width);$y(this.cell.wrapper,{padding:'8px'});_f.cur_col_break_width=this.df.width;var fn=this.df.fieldname?this.df.fieldname:this.df.label;if(this.df&&this.df.label){this.label=$a(this.cell.wrapper,'div','','',this.df.label);}}
_f.ColumnBreak.prototype.refresh=function(layout){var hidden=0;if((!this.perm[this.df.permlevel])||(!this.perm[this.df.permlevel][READ])||this.df.hidden){hidden=1;}
if(this.set_hidden!=hidden){if(hidden)
this.cell.hide();else
this.cell.show();this.set_hidden=this.df.hidden;}}
this.cell.show();this.set_hidden=hidden;}}
_f.SectionBreak=function(){this.fields=[];this.set_input=function(){};this.make_row=function(){this.row=this.df.label?this.frm.layout.addrow():this.frm.layout.addsubrow();}}
_f.SectionBreak.prototype.make_body=function(){var me=this;if((!this.perm[this.df.permlevel])||(!this.perm[this.df.permlevel][READ])||this.df.hidden){return;}
this.make_row();if(this.df.label){if(!this.df.description)
_f.SectionBreak.prototype.make_body=function(){var me=this;this.make_row();if(this.df.label){if(!this.df.description)
this.df.description='';$(this.row.main_head).html(repl('<div class="form-section-head">\
<h3 class="head">%(label)s</h3>\
<div class="help small" \
@ -1874,7 +1879,8 @@ _f.SectionBreak.prototype.has_data=function(){var me=this;for(var i in me.fields
if(f.df.reqd&&!v){return true;}
if(f.df.fieldtype=='Table'){if(f.grid.get_children().length||f.df.reqd){return true;}}}
return false;}
_f.SectionBreak.prototype.refresh=function(from_form){if(this.df.hidden){if(this.row)this.row.hide();}else{if(this.collapsible){}}}
_f.SectionBreak.prototype.refresh=function(from_form){var hidden=0;if((!this.perm[this.df.permlevel])||(!this.perm[this.df.permlevel][READ])||this.df.hidden){hidden=1;}
if(hidden){if(this.row)this.row.hide();}else{if(this.collapsible){}}}
_f.ImageField=function(){this.images={};}
_f.ImageField.prototype=new Field();_f.ImageField.prototype.onmake=function(){this.no_img=$a(this.wrapper,'div','no_img');this.no_img.innerHTML="No Image";$dh(this.no_img);}
_f.ImageField.prototype.get_image_src=function(doc){if(doc.file_list){file=doc.file_list.split(',');extn=file[0].split('.');extn=extn[extn.length-1].toLowerCase();var img_extn_list=['gif','jpg','bmp','jpeg','jp2','cgm','ief','jpm','jpx','png','tiff','jpe','tif'];if(in_list(img_extn_list,extn)){var src=wn.request.url+"?cmd=downloadfile&file_id="+file[1];}}else{var src="";}
@ -1884,8 +1890,7 @@ for(var dn in this.images)if(dn!=this.docname)$dh(this.images[dn]);var doc=local
$w(img,allow_width+'px');}else{$ds(this.no_img);}}
_f.ImageField.prototype.set_disp=function(val){}
_f.ImageField.prototype.set=function(val){}
_f.TableField=function(){};_f.TableField.prototype=new Field();_f.TableField.prototype.with_label=0;_f.TableField.prototype.make_body=function(){if(this.perm[this.df.permlevel]&&this.perm[this.df.permlevel][READ]){if(this.df.description){this.desc_area=$a(this.parent,'div','help small','',this.df.description)}
this.grid=new _f.FormGrid(this);if(this.frm)this.frm.grids[this.frm.grids.length]=this;this.grid.make_buttons();}}
_f.TableField=function(){};_f.TableField.prototype=new Field();_f.TableField.prototype.with_label=0;_f.TableField.prototype.make_body=function(){if(this.perm[this.df.permlevel]&&this.perm[this.df.permlevel][READ]){this.grid=new _f.FormGrid(this);if(this.frm)this.frm.grids[this.frm.grids.length]=this;this.grid.make_buttons();if(this.df.description){this.desc_area=$a(this.parent,'div','help small','',this.df.description)}}}
_f.TableField.prototype.refresh=function(){if(!this.grid)return;var st=this.get_status();if(!this.df['default'])
this.df['default']='';this.grid.can_add_rows=false;this.grid.can_edit=false
if(st=='Write'){if(cur_frm.editable&&this.perm[this.df.permlevel]&&this.perm[this.df.permlevel][WRITE]){this.grid.can_edit=true;if(this.df['default'].toLowerCase()!='no toolbar')
@ -1912,7 +1917,7 @@ _f.cur_grid_cell=null;_f.Grid=function(parent){}
_f.Grid.prototype.init=function(parent,row_height){var me=this;this.col_idx_by_name={}
this.alt_row_bg='#F2F2FF';this.row_height=row_height;if(!row_height)this.row_height='26px';this.make_ui(parent);this.insert_column('','','Int','Sr','50px','',[1,0,0]);if(this.oninit)this.oninit();$(this.wrapper).bind('keydown',function(e){me.notify_keypress(e,e.which);})
$(cur_frm.wrapper).bind('render_complete',function(){me.set_ht();});}
_f.Grid.prototype.make_ui=function(parent){var ht=make_table($a(parent,'div'),1,2,'100%',['60%','40%']);this.main_title=$td(ht,0,0);this.main_title.className='columnHeading';$td(ht,0,1).style.textAlign='right';this.tbar_div=$a($td(ht,0,1),'div','grid_tbarlinks');this.tbar_tab=make_table(this.tbar_div,1,4,'100%',['25%','25%','25%','25%']);this.wrapper=$a(parent,'div','grid_wrapper');this.head_wrapper=$a(this.wrapper,'div','grid_head_wrapper');this.head_tab=$a(this.head_wrapper,'table','grid_head_table');this.head_row=this.head_tab.insertRow(0);this.tab_wrapper=$a(this.wrapper,'div','grid_tab_wrapper');this.tab=$a(this.tab_wrapper,'table','grid_table');var me=this;this.wrapper.onscroll=function(){me.head_wrapper.style.top=me.wrapper.scrollTop+'px';}}
_f.Grid.prototype.make_ui=function(parent){var ht=make_table($a(parent,'div'),1,2,'100%',['55%','45%']);this.main_title=$td(ht,0,0);this.main_title.className='columnHeading';$td(ht,0,1).style.textAlign='right';this.tbar_div=$a($td(ht,0,1),'div','grid_tbarlinks');this.tbar_tab=make_table(this.tbar_div,1,4,'100%',['25%','25%','25%','25%']);this.wrapper=$a(parent,'div','grid_wrapper round');this.head_wrapper=$a(this.wrapper,'div','grid_head_wrapper');this.head_tab=$a(this.head_wrapper,'table','grid_head_table');this.head_row=this.head_tab.insertRow(0);this.tab_wrapper=$a(this.wrapper,'div','grid_tab_wrapper');this.tab=$a(this.tab_wrapper,'table','grid_table');var me=this;this.wrapper.onscroll=function(){me.head_wrapper.style.top=me.wrapper.scrollTop+'px';}}
_f.Grid.prototype.show=function(){if(this.can_edit&&this.field.df['default'].toLowerCase()!='no toolbar'){$ds(this.tbar_div);if(this.can_add_rows){$td(this.tbar_tab,0,0).style.display='table-cell';$td(this.tbar_tab,0,1).style.display='table-cell';}else{$td(this.tbar_tab,0,0).style.display='none';$td(this.tbar_tab,0,1).style.display='none';}}else{$dh(this.tbar_div);}
$ds(this.wrapper);}
_f.Grid.prototype.hide=function(){$dh(this.wrapper);$dh(this.tbar_div);}
@ -1936,7 +1941,7 @@ var me=this;if(cell.cellIndex){var ft=hc.fieldtype;if(ft=='Link'&&cur_frm.doc.do
$(document).bind('click',function(e){var me=this;var is_target_toolbar=function(){return $(e.target).parents('.grid_tbarlinks').length;}
var is_target_input=function(){if(e.target.tagName.toLowerCase()=='option')return true;return $(e.target).parents().get().indexOf(_f.cur_grid_cell)!=-1;}
if(_f.cur_grid_cell&&!is_target_input()&&!is_target_toolbar()){if(!(text_dialog&&text_dialog.display)&&!datepicker_active&&!(selector&&selector.display)){setTimeout('_f.cur_grid_cell.grid.cell_deselect()',500);return false;}}});_f.Grid.prototype.cell_deselect=function(){if(_f.cur_grid_cell){var c=_f.cur_grid_cell;c.grid.remove_template(c);c.div.className='grid_cell_div';if(c.is_odd)c.div.style.border='2px solid '+c.grid.alt_row_bg;else c.div.style.border='2px solid #FFF';_f.cur_grid_cell=null;}}
_f.Grid.prototype.cell_select=function(cell,ri,ci){if(_f.cur_grid_cell==cell&&cell.hc)return;if(ri!=null&&ci!=null)
_f.Grid.prototype.cell_select=function(cell,ri,ci){if(cell&&_f.cur_grid_cell==cell&&cell.hc)return;if(ri!=null&&ci!=null)
cell=this.tab.rows[ri].cells[ci];var hc=this.head_row.cells[cell.cellIndex];if(!hc.template){this.make_template(hc);}
hc.template.perm=this.field?this.field.perm:hc.perm;if(hc.fieldname&&hc.template.get_status()=='Write'){this.cell_deselect();cell.div.style.border='2px solid #88F';_f.cur_grid_cell=cell;this.add_template(cell);}}
_f.Grid.prototype.add_template=function(cell){if(!cell.row.docname&&this.add_newrow){this.add_newrow();this.cell_select(cell);}else{var hc=this.head_row.cells[cell.cellIndex];cell.div.innerHTML='';cell.div.appendChild(hc.template.wrapper);hc.template.activate(cell.row.docname);hc.template.activated=1;cell.hc=hc;if(hc.template.input&&hc.template.input.set_width){hc.template.input.set_width($(cell).width());}}}
@ -1967,11 +1972,11 @@ _f.Grid.prototype.refresh_row=function(ridx,docname){var row=this.tab.rows[ridx]
_f.FormGrid=function(field){this.field=field;this.doctype=field.df.options;if(!this.doctype){show_alert('No Options for table '+field.df.label);}
this.col_break_width=cint(this.field.col_break_width);if(!this.col_break_width)this.col_break_width=100;$y(field.parent,{marginTop:'8px'});this.init(field.parent,field.df.width);this.setup();}
_f.FormGrid.prototype=new _f.Grid();_f.FormGrid.prototype.setup=function(){this.make_columns();}
_f.FormGrid.prototype.make_buttons=function(){var me=this;this.tbar_btns={};this.tbar_btns['Del']=this.make_tbar_link($td(this.tbar_tab,0,0),'Del',function(){me.delete_row();},'icon-remove-sign');this.tbar_btns['Ins']=this.make_tbar_link($td(this.tbar_tab,0,1),'Ins',function(){me.insert_row();},'icon-plus');this.tbar_btns['Up']=this.make_tbar_link($td(this.tbar_tab,0,2),'Up',function(){me.move_row(true);},'icon-arrow-up');this.tbar_btns['Dn']=this.make_tbar_link($td(this.tbar_tab,0,3),'Dn',function(){me.move_row(false);},'icon-arrow-down');for(var i in this.btns)
this.btns[i].isactive=true;}
_f.FormGrid.prototype.make_tbar_link=function(parent,label,fn,icon){var div=$a(parent,'div','',{cursor:'pointer'});var t=make_table(div,1,2,'90%',['20px',null]);var img=$a($td(t,0,0),'i',icon);$y($td(t,0,0),{textAlign:'right'});var l=$a($td(t,0,1),'span','link_type',{color:'#333'});l.style.fontSize='11px';l.innerHTML=label;div.onclick=fn;div.show=function(){$ds(this);}
div.hide=function(){$dh(this);}
$td(t,0,0).isactive=1;$td(t,0,1).isactive=1;l.isactive=1;div.isactive=1;img.isactive=1;return div;}
_f.FormGrid.prototype.make_buttons=function(){var me=this;this.tbar_btns={};this.tbar_btns['Del']=this.make_tbar_link($td(this.tbar_tab,0,0),'Del',function(){me.delete_row();},'icon-remove-sign');this.tbar_btns['Ins']=this.make_tbar_link($td(this.tbar_tab,0,1),'Ins',function(){me.insert_row();},'icon-plus');this.tbar_btns['Up']=this.make_tbar_link($td(this.tbar_tab,0,2),'Up',function(){me.move_row(true);},'icon-arrow-up');this.tbar_btns['Dn']=this.make_tbar_link($td(this.tbar_tab,0,3),'Dn',function(){me.move_row(false);},'icon-arrow-down');for(var i in this.btns)
this.btns[i].isactive=true;}
_f.FormGrid.prototype.make_columns=function(){var gl=wn.meta.docfield_list[this.field.df.options];if(!gl){alert('Table details not found "'+this.field.df.options+'"');}
gl.sort(function(a,b){return a.idx-b.idx});var p=this.field.perm;for(var i=0;i<gl.length;i++){if(p[this.field.df.permlevel]&&p[this.field.df.permlevel][READ]){this.insert_column(this.field.df.options,gl[i].fieldname,gl[i].fieldtype,gl[i].label,gl[i].width,gl[i].options,this.field.perm,gl[i].reqd);if(gl[i].hidden){this.set_column_disp(gl[i].fieldname,false);}}}}
_f.FormGrid.prototype.set_column_label=function(fieldname,label){for(var i=0;i<this.head_row.cells.length;i++){var c=this.head_row.cells[i];if(c.fieldname==fieldname){c.innerHTML='<div class="grid_head_div">'+label+'</div>';c.cur_label=label;break;}}}
@ -1992,7 +1997,7 @@ var r=this.append_row();r.cells[0].div.innerHTML='<b style="font-size: 18px;">*<
_f.FormGrid.prototype.check_selected=function(){if(!_f.cur_grid_cell){show_alert('Select a cell first');return false;}
if(_f.cur_grid_cell.grid!=this){show_alert('Select a cell first');return false;}
return true;}
_f.FormGrid.prototype.delete_row=function(dt,dn){if(dt&&dn){LocalDB.delete_record(dt,dn);this.refresh();}else{if(!this.check_selected())return;var r=_f.cur_grid_cell.row;if(r.is_newrow)return;var ci=_f.cur_grid_cell.cellIndex;var ri=_f.cur_grid_cell.row.rowIndex;LocalDB.delete_record(this.doctype,r.docname);this.refresh();if(ri<(this.tab.rows.length-2))
_f.FormGrid.prototype.delete_row=function(dt,dn){if(dt&&dn){LocalDB.delete_record(dt,dn);this.refresh();}else{if(!this.check_selected())return;var r=_f.cur_grid_cell.row;if(r.is_newrow)return;var ci=_f.cur_grid_cell.cellIndex;var ri=_f.cur_grid_cell.row.rowIndex;LocalDB.delete_record(this.doctype,r.docname);this.refresh();if(ri<(this.tab.rows.length-1))
this.cell_select(null,ri,ci);else _f.cur_grid_cell=null;}
this.set_unsaved();}
_f.FormGrid.prototype.move_row=function(up){if(!this.check_selected())return;var r=_f.cur_grid_cell.row;if(r.is_newrow)return;if(up&&r.rowIndex>0){var swap_row=this.tab.rows[r.rowIndex-1];}else if(!up){var len=this.tab.rows.length;if(this.tab.rows[len-1].is_newrow)
@ -2131,10 +2136,10 @@ set_field_options=function(n,txt){var df=get_field(cur_frm.doctype,n,cur_frm.doc
set_field_permlevel=function(n,level){var df=get_field(cur_frm.doctype,n,cur_frm.docname);if(df)df.permlevel=level;refresh_field(n);}
hide_field=function(n){function _hide_field(n,hidden){var df=get_field(cur_frm.doctype,n,cur_frm.docname);if(df){df.hidden=hidden;refresh_field(n);}
else{console.log("hide_field cannot find field "+n);}}
if(cur_frm){if(n.substr)_hide_field(n,1);else{for(var i in n)_hide_field(n[i],1)}}}
if(cur_frm){if(typeof n=='string')_hide_field(n,1);else{for(var i in n)_hide_field(n[i],1)}}}
unhide_field=function(n){function _hide_field(n,hidden){var df=get_field(cur_frm.doctype,n,cur_frm.docname);if(df){df.hidden=hidden;refresh_field(n);}
else{console.log("unhide_field cannot find field "+n);}}
if(cur_frm){if(n.substr)_hide_field(n,0);else{for(var i in n)_hide_field(n[i],0)}}}
if(cur_frm){if(typeof n=='string')_hide_field(n,0);else{for(var i in n)_hide_field(n[i],0)}}}
get_field_obj=function(fn){return cur_frm.fields_dict[fn];}
/*
* lib/js/legacy/widgets/form/form_comments.js

View File

@ -514,7 +514,7 @@ wn.ui.AppFrame=Class.extend({init:function(parent,title){this.buttons={};this.$w
<span class="close">&times;</span>\
</div>').appendTo(this.$w);this.$w.find('.close').click(function(){window.history.back();})
if(title)this.title(title);},title:function(txt){this.$titlebar.find('.appframe-title').html(txt);},add_button:function(label,click,icon){if(!this.$w.find('.appframe-toolbar').length)
this.$w.append('<div class="appframe-toolbar"></div>');args={label:label,icon:''};if(icon){args.icon='<i class="'+icon+'"></i>';}
this.$w.append('<div class="appframe-toolbar"></div>');args={label:label,icon:''};if(icon){args.icon='<i class="icon '+icon+'"></i>';}
this.buttons[label]=$(repl('<button class="btn btn-small">\
%(icon)s %(label)s</button>',args)).click(click).appendTo(this.$w.find('.appframe-toolbar'));return this.buttons[label];},clear_buttons:function(){this.$w.find('.appframe-toolbar').empty();}});wn.ui.make_app_page=function(opts){if(opts.single_column){$(opts.parent).html('<div class="layout-wrapper layout-wrapper-appframe">\
<div class="layout-appframe"></div>\