cleaned up fiscal_year, currency and added select-all + help in doclistview

This commit is contained in:
Rushabh Mehta 2012-07-11 16:35:39 +05:30
parent 9acf463427
commit 3a0f191658
11 changed files with 71 additions and 146 deletions

View File

@ -86,9 +86,8 @@ cur_frm.cscript.hide_unhide_group_ledger = function(doc) {
// -----------------------------------------
cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
$c_obj(cur_frm.get_doclist(),'convert_group_to_ledger','',function(r,rt) {
if(r.message == 1) {
refresh_field('group_or_ledger');
cur_frm.cscript.hide_unhide_group_ledger(cur_frm.get_doc());
if(r.message == 1) {
cur_frm.refresh();
}
});
}
@ -98,9 +97,7 @@ cur_frm.cscript.convert_to_ledger = function(doc, cdt, cdn) {
cur_frm.cscript.convert_to_group = function(doc, cdt, cdn) {
$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(cur_frm.get_doc());
cur_frm.refresh();
}
});
}

View File

@ -43,7 +43,6 @@ class DocType:
self.doc.name = self.doc.account_name.strip() + ' - ' + company_abbr
# Get customer/supplier address
# ==================================================================
def get_address(self):
add=sql("Select address from `tab%s` where name='%s'"%(self.doc.master_type,self.doc.master_name))
ret={'address':add[0][0]}
@ -51,20 +50,17 @@ class DocType:
# check whether master name entered for supplier/customer
# ==================================================================
def validate_master_name(self):
if (self.doc.master_type == 'Customer' or self.doc.master_type == 'Supplier') and not self.doc.master_name:
msgprint("Message: Please enter Master Name once the account is created.")
# Rate is mandatory for tax account
# ==================================================================
def validate_rate_for_tax(self):
if self.doc.account_type == 'Tax' and not self.doc.tax_rate:
msgprint("Please Enter Rate", raise_exception=1)
# Fetch Parent Details and validation for account not to be created under ledger
# ==================================================================
def validate_parent(self):
if self.doc.parent_account:
par = sql("select name, group_or_ledger, is_pl_account, debit_or_credit from tabAccount where name =%s",self.doc.parent_account)
@ -81,13 +77,11 @@ class DocType:
self.doc.debit_or_credit = par[0][3]
# Account name must be unique
# ==================================================================
def validate_duplicate_account(self):
if (self.doc.__islocal or (not self.doc.name)) and sql("select name from tabAccount where account_name=%s and company=%s", (self.doc.account_name, self.doc.company)):
msgprint("Account Name already exists, please rename", raise_exception=1)
# validate root details
# ==================================================================
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:
@ -106,7 +100,6 @@ class DocType:
self.doc.is_pl_account = 'No'
# Convert group to ledger
# ==================================================================
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)
@ -118,28 +111,28 @@ class DocType:
return 1
# Convert ledger to group
# ==================================================================
def convert_ledger_to_group(self):
if self.check_gle_exists():
msgprint("Account with existing transaction can not be converted to group.", raise_exception=1)
msgprint("Account with existing transaction can not be converted to group.",
raise_exception=1)
elif self.doc.master_type or self.doc.account_type:
msgprint("Cannot covert to Group because Master Type or Account Type is selected.",
raise_exception=1)
else:
self.doc.group_or_ledger = 'Group'
self.doc.save()
return 1
# Check if any previous balance exists
# ==================================================================
def check_gle_exists(self):
exists = sql("select name from `tabGL Entry` where account = '%s' and ifnull(is_cancelled, 'No') = 'No'" % (self.doc.name))
return exists and exists[0][0] or ''
# check if child exists
# ==================================================================
def check_if_child_exists(self):
return sql("select name from `tabAccount` where parent_account = %s and docstatus != 2", self.doc.name)
# Update balance
# ==================================================================
def update_balance(self, fy, period_det, flag = 1):
# update in all parents
for p in period_det:
@ -147,7 +140,6 @@ class DocType:
# change parent balance
# ==================================================================
def change_parent_bal(self):
period_det = []
fy = sql("select name from `tabFiscal Year` where if(ifnull(is_fiscal_year_closed, 'No'),ifnull(is_fiscal_year_closed, 'No'), 'No') = 'No'")
@ -177,7 +169,6 @@ class DocType:
# VALIDATE
# ==================================================================
def validate(self):
self.validate_master_name()
self.validate_rate_for_tax()
@ -195,7 +186,6 @@ class DocType:
self.change_parent_bal()
# Add current fiscal year balance
# ==================================================================
def set_year_balance(self):
p = sql("select name, start_date, end_date, fiscal_year from `tabPeriod` where docstatus != 2 and period_type in ('Month', 'Year')")
for d in p:
@ -213,14 +203,12 @@ class DocType:
ac.save(1)
# Update Node Set Model
# ==================================================================
def update_nsm_model(self):
import webnotes
import webnotes.utils.nestedset
webnotes.utils.nestedset.update_nsm(self)
# ON UPDATE
# ==================================================================
def on_update(self):
# update nsm
self.update_nsm_model()
@ -228,14 +216,12 @@ class DocType:
self.set_year_balance()
# Check user role for approval process
# ==================================================================
def get_authorized_user(self):
# Check logged-in user is authorized
if get_value('Global Defaults', None, 'credit_controller') in webnotes.user.get_roles():
return 1
# Check Credit limit for customer
# ==================================================================
def check_credit_limit(self, account, company, tot_outstanding):
# Get credit limit
credit_limit_from = 'Customer'
@ -252,7 +238,6 @@ class DocType:
% (fmt_money(tot_outstanding), account, fmt_money(credit_limit), credit_limit_from), raise_exception=1)
# Account with balance cannot be inactive
# ==================================================================
def check_balance_before_trash(self):
if self.check_gle_exists():
msgprint("Account with existing transaction (Sales Invoice / Purchase Invoice / Journal Voucher) can not be trashed", raise_exception=1)
@ -261,13 +246,11 @@ class DocType:
# get current year balance
# ==================================================================
def get_curr_bal(self):
bal = sql("select balance from `tabAccount Balance` where period = '%s' and parent = '%s'" % (get_defaults()['fiscal_year'], self.doc.name),debug=0)
return bal and flt(bal[0][0]) or 0
# On Trash
# ==================================================================
def on_trash(self):
# Check balance before trash
self.check_balance_before_trash()
@ -283,7 +266,6 @@ class DocType:
sql("delete from `tabAccount Balance` where account = %s", self.doc.name)
# On restore
# ==================================================================
def on_restore(self):
# rebuild tree
self.update_nsm_model()
@ -291,7 +273,6 @@ class DocType:
self.set_year_balance()
# on rename
# ---------
def on_rename(self,newdn,olddn):
company_abbr = sql("select tc.abbr from `tabAccount` ta, `tabCompany` tc where ta.company = tc.name and ta.name=%s", olddn)[0][0]

View File

@ -5,7 +5,7 @@
{
'creation': '2012-07-03 13:30:47',
'docstatus': 0,
'modified': '2012-07-11 14:04:33',
'modified': '2012-07-11 14:41:39',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@ -230,7 +230,7 @@
# DocField
{
'colour': u'White:FFF',
'description': u'Define Budget for this Cost Center',
'description': u'Define Budget for this Cost Center. To set budget action, see <a href="#!List/Company">Company Master</a>',
'doctype': u'DocField',
'fieldname': u'sb1',
'fieldtype': u'Section Break',
@ -255,7 +255,7 @@
# DocField
{
'colour': u'White:FFF',
'description': u'Add rows to set budgets on Accounts. To set budget actions, see the company master.',
'description': u'Add rows to set annual budgets on Accounts.',
'doctype': u'DocField',
'fieldname': u'budget_details',
'fieldtype': u'Table',

View File

@ -1,7 +1,4 @@
cur_frm.cscript.refresh = function(doc, dt, dn) {
if (doc.__islocal) {
hide_field(['repost_account_balances', 'repost_voucher_outstanding']);
set_multiple(dt, dn, {'is_fiscal_year_closed': 'No'});
}
else unhide_field(['repost_account_balances', 'repost_voucher_outstanding']);
cur_frm.toggle_fields('year', doc.__islocal);
cur_frm.enable_fields('year_start_date', doc.__islocal)
}

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-11 14:56:41',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@ -17,6 +17,7 @@
'autoname': u'field:year',
'colour': u'White:FFF',
'default_print_format': u'Standard',
'description': u'**Fiscal Year** represents a Financial Year. All accounting entries and other major transactions are tracked against **Fiscal Year**.',
'doctype': 'DocType',
'document_type': u'Master',
'module': u'Accounts',
@ -24,7 +25,7 @@
'section_style': u'Tabbed',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 57
'version': 1
},
# These values are common for all DocField
@ -59,14 +60,14 @@
# DocPerm
{
'doctype': u'DocPerm'
'amend': 0,
'doctype': u'DocPerm',
'submit': 0
},
# DocPerm
{
'amend': 0,
'doctype': u'DocPerm',
'submit': 0
'doctype': u'DocPerm'
},
# DocField
@ -74,7 +75,7 @@
'doctype': u'DocField',
'fieldname': u'year_details',
'fieldtype': u'Section Break',
'label': u'Year Details',
'label': u'Fiscal Year Details',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
@ -92,6 +93,8 @@
# DocField
{
'colour': u'White:FFF',
'description': u'For e.g. 2012, 2012-13',
'doctype': u'DocField',
'fieldname': u'year',
'fieldtype': u'Data',
@ -102,18 +105,6 @@
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'abbreviation',
'fieldtype': u'Data',
'label': u'Abbreviation',
'oldfieldname': u'abbreviation',
'oldfieldtype': u'Data',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
@ -128,6 +119,9 @@
# DocField
{
'colour': u'White:FFF',
'default': u'No',
'description': u'Entries are not allowed against this Fiscal Year if the year is closed.',
'doctype': u'DocField',
'fieldname': u'is_fiscal_year_closed',
'fieldtype': u'Select',
@ -137,65 +131,5 @@
'options': u'\nNo\nYes',
'permlevel': 0,
'reqd': 0
},
# DocField
{
'colour': u'White:FFF',
'description': u"Click on the button below to reset balances from your previous year's closing and repost your balances. You can use this if your previous year balance sheet has been changed and you wish to update your current accounts.",
'doctype': u'DocField',
'fieldname': u'repost_accounts',
'fieldtype': u'Section Break',
'label': u'Repost Accounts',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'past_year',
'fieldtype': u'Select',
'label': u'Past Year',
'oldfieldname': u'past_year',
'oldfieldtype': u'Select',
'options': u'link:Fiscal Year',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'company',
'fieldtype': u'Link',
'in_filter': 0,
'label': u'Company',
'oldfieldname': u'company',
'oldfieldtype': u'Link',
'options': u'Company',
'permlevel': 0,
'search_index': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'repost_account_balances',
'fieldtype': u'Button',
'label': u'Repost Account Balances',
'oldfieldtype': u'Button',
'options': u'repost',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'repost_voucher_outstanding',
'fieldtype': u'Button',
'label': u'Repost Voucher Outstanding',
'oldfieldtype': u'Button',
'options': u'update_voucher_outstanding',
'permlevel': 0
}
]

View File

@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:19',
'creation': '2012-07-03 13:30:55',
'docstatus': 0,
'modified': '2012-03-27 14:36:19',
'modified': '2012-07-11 14:43:55',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@ -23,7 +23,7 @@
'section_style': u'Tabbed',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 96
'version': 1
},
# These values are common for all DocField
@ -85,11 +85,11 @@
# DocField
{
'description': u'Please Enter Company Name and Abbr and save the document. Once saved Accounting Settings will be populated automatically',
'colour': u'White:FFF',
'doctype': u'DocField',
'fieldname': u'details',
'fieldtype': u'Section Break',
'label': u'Details',
'label': u'Company Details',
'oldfieldtype': u'Section Break',
'permlevel': 0
},
@ -108,6 +108,14 @@
'reqd': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'cb0',
'fieldtype': u'Column Break',
'permlevel': 0
},
# DocField
{
'colour': u'White:FFF',
@ -253,6 +261,8 @@
# DocField
{
'colour': u'White:FFF',
'description': u'For reference only.',
'doctype': u'DocField',
'fieldname': u'company_info',
'fieldtype': u'Section Break',

View File

@ -3,17 +3,19 @@
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:19',
'creation': '2012-07-03 13:30:55',
'docstatus': 0,
'modified': '2012-03-27 14:36:19',
'modified': '2012-07-11 16:11:45',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
# These values are common for all DocType
{
'allow_trash': 1,
'autoname': u'field:currency_name',
'colour': u'White:FFF',
'description': u'**Currency** Master',
'doctype': 'DocType',
'in_create': 0,
'module': u'Setup',
@ -22,7 +24,7 @@
'section_style': u'Simple',
'server_code_error': u' ',
'show_in_menu': 0,
'version': 3
'version': 1
},
# These values are common for all DocField
@ -60,10 +62,17 @@
'name': u'Currency'
},
# DocPerm
{
'cancel': 1,
'doctype': u'DocPerm',
'role': u'Accounts Manager'
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'cancel': 1,
'doctype': u'DocPerm',
'role': u'Sales Master Manager',
'submit': 0
@ -78,12 +87,6 @@
'submit': 0
},
# DocPerm
{
'doctype': u'DocPerm',
'role': u'Accounts Manager'
},
# DocField
{
'doctype': u'DocField'

View File

@ -49,7 +49,6 @@ class DocType:
master_dict = {'Fiscal Year':{
'year': curr_fiscal_year,
'year_start_date': fy_start_date,
'abbreviation': fy_abbr,
'company': args.get('company_name'),
'is_fiscal_year_closed': 'No'}}
self.create_records(master_dict)

View File

@ -651,8 +651,9 @@ Field.prototype.set_label=function(){if(this.with_label&&this.label_area&&this.l
Field.prototype.set_description=function(){if(this.df.description){var p=in_list(['Text Editor','Code','Check'],this.df.fieldtype)?this.label_area:this.wrapper;this.desc_area=$a(p,'div','help small','',this.df.description)
if(in_list(['Text Editor','Code'],this.df.fieldtype))
$(this.desc_area).addClass('help small');}}
Field.prototype.get_status=function(){if(this.in_filter)this.not_in_form=this.in_filter;if(this.not_in_form){return'Write';}
if(!this.df.permlevel)this.df.permlevel=0;var p=this.perm[this.df.permlevel];var ret;if(cur_frm.editable&&p&&p[WRITE])ret='Write';else if(p&&p[READ])ret='Read';else ret='None';if(this.df.fieldtype=='Binary')
Field.prototype.get_status=function(){if(this.in_filter)
this.not_in_form=this.in_filter;if(this.not_in_form){return'Write';}
if(!this.df.permlevel)this.df.permlevel=0;var p=this.perm[this.df.permlevel];var ret;if(cur_frm.editable&&p&&p[WRITE]&&!this.disabled)ret='Write';else if(p&&p[READ])ret='Read';else ret='None';if(this.df.fieldtype=='Binary')
ret='None';if(cint(this.df.hidden))
ret='None';if(ret=='Write'&&cint(cur_frm.doc.docstatus)>0)ret='Read';var a_o_s=cint(this.df.allow_on_submit);if(a_o_s&&(this.in_grid||(this.frm&&this.frm.not_in_container))){a_o_s=null;if(this.in_grid)a_o_s=this.grid.field.df.allow_on_submit;if(this.frm&&this.frm.not_in_container){a_o_s=cur_grid.field.df.allow_on_submit;}}
if(cur_frm.editable&&a_o_s&&cint(cur_frm.doc.docstatus)>0&&!this.df.hidden){tmp_perm=get_perm(cur_frm.doctype,cur_frm.docname,1);if(tmp_perm[this.df.permlevel]&&tmp_perm[this.df.permlevel][WRITE])ret='Write';}
@ -966,15 +967,16 @@ wn.views.DocListView=wn.ui.Listing.extend({init:function(doctype){this.doctype=d
</div>\
</div>\
<div style="clear: both"></div>\
</div>');this.appframe=new wn.ui.AppFrame(this.$page.find('.appframe-area'));wn.views.breadcrumbs(this.appframe,locals.DocType[this.doctype].module,this.doctype);},setup:function(){var me=this;me.can_delete=wn.model.can_delete(me.doctype);me.meta=locals.DocType[me.doctype];me.$page.find('.wnlist-area').empty(),me.setup_docstatus_filter();me.setup_listview();me.init_list();me.init_stats();me.make_report_button();me.add_delete_option();},make_report_button:function(){var me=this;if(wn.boot.profile.can_get_report.indexOf(this.doctype)!=-1){this.appframe.add_button('Build Report',function(){wn.set_route('Report2',me.doctype);},'icon-th')}},setup_docstatus_filter:function(){var me=this;this.can_submit=$.map(locals.DocPerm,function(d){if(d.parent==me.meta.name&&d.submit)return 1
</div>');this.appframe=new wn.ui.AppFrame(this.$page.find('.appframe-area'));wn.views.breadcrumbs(this.appframe,locals.DocType[this.doctype].module,this.doctype);},setup:function(){var me=this;me.can_delete=wn.model.can_delete(me.doctype);me.meta=locals.DocType[me.doctype];me.$page.find('.wnlist-area').empty(),me.setup_docstatus_filter();me.setup_listview();me.init_list();me.init_stats();me.make_report_button();me.add_delete_option();me.make_help();},make_report_button:function(){var me=this;if(wn.boot.profile.can_get_report.indexOf(this.doctype)!=-1){this.appframe.add_button('Build Report',function(){wn.set_route('Report2',me.doctype);},'icon-th')}},make_help:function(){if(this.meta.description){this.appframe.add_help_button(wn.markdown('## '+this.meta.name+'\n\n'
+this.meta.description));}},setup_docstatus_filter:function(){var me=this;this.can_submit=$.map(locals.DocPerm,function(d){if(d.parent==me.meta.name&&d.submit)return 1
else return null;}).length;if(this.can_submit){this.$page.find('.show-docstatus').removeClass('hide');this.$page.find('.show-docstatus input').click(function(){me.run();})}},setup_listview:function(){if(this.meta.__listjs){eval(this.meta.__listjs);this.listview=new wn.doclistviews[this.doctype](this);}else{this.listview=new wn.views.ListView(this);}
this.listview.parent=this;this.wrapper=this.$page.find('.wnlist-area');this.page_length=20;this.allow_delete=true;},init_list:function(auto_run){var me=this;this.make({method:'webnotes.widgets.doclistview.get',get_args:this.get_args,parent:this.wrapper,start:0,page_length:this.page_length,show_filters:true,show_grid:true,new_doctype:this.doctype,allow_delete:this.allow_delete,no_result_message:this.make_no_result(),columns:this.listview.fields});$(this.wrapper).find('button[list_view_doc="'+me.doctype+'"]').click(function(){me.make_new_doc(me.doctype);});if((auto_run!==false)&&(auto_run!==0))this.run();},make_no_result:function(){var no_result_message=repl('<div class="well">\
<p>No %(doctype_label)s found</p>\
%(description)s\
<hr>\
<p><button class="btn btn-info btn-small" list_view_doc="%(doctype)s">\
Make a new %(doctype_label)s</button>\
</p></div>',{doctype_label:get_doctype_label(this.doctype),doctype:this.doctype,description:wn.markdown(locals.DocType[this.doctype].description||''),});return no_result_message;},render_row:function(row,data){data.doctype=this.doctype;this.listview.render(row,data,this);},get_query_fields:function(){return this.listview.fields;},get_args:function(){return{doctype:this.doctype,fields:this.get_query_fields(),filters:this.filter_list.get_filters(),docstatus:this.can_submit?$.map(this.$page.find('.show-docstatus :checked'),function(inp){return $(inp).attr('data-docstatus')}):[],order_by:this.listview.order_by||undefined,}},add_delete_option:function(){var me=this;if(this.can_delete){this.add_button('Delete',function(){me.delete_items();},'icon-remove')}},delete_items:function(){var me=this;var dl=$.map(me.$page.find('.list-delete:checked'),function(e){return $(e).data('name');});if(!dl.length)
</p></div>',{doctype_label:get_doctype_label(this.doctype),doctype:this.doctype});return no_result_message;},render_row:function(row,data){data.doctype=this.doctype;this.listview.render(row,data,this);},get_query_fields:function(){return this.listview.fields;},get_args:function(){return{doctype:this.doctype,fields:this.get_query_fields(),filters:this.filter_list.get_filters(),docstatus:this.can_submit?$.map(this.$page.find('.show-docstatus :checked'),function(inp){return $(inp).attr('data-docstatus')}):[],order_by:this.listview.order_by||undefined,}},add_delete_option:function(){var me=this;if(this.can_delete){this.add_button('Delete',function(){me.delete_items();},'icon-remove');$('<div style="padding: 4px"><input type="checkbox" name="select-all" />\
Select all</div>').insertBefore(this.$page.find('.result-list'));this.$page.find('[name="select-all"]').click(function(){me.$page.find('.list-delete').attr('checked',$(this).attr('checked')||false);})}},delete_items:function(){var me=this;var dl=$.map(me.$page.find('.list-delete:checked'),function(e){return $(e).data('name');});if(!dl.length)
return;if(!confirm('This is PERMANENT action and you cannot undo. Continue?')){return;}
me.set_working(true);wn.call({method:'webnotes.widgets.doclistview.delete_items',args:{items:dl,doctype:me.doctype},callback:function(){me.set_working(false);me.refresh();}})},init_stats:function(){var me=this
wn.call({method:'webnotes.widgets.doclistview.get_stats',args:{stats:me.listview.stats,doctype:me.doctype},callback:function(r){$.each(me.listview.stats,function(i,v){me.render_stat(v,r.message[v]);});if(me.listview.stats.length){$('<button class="btn btn-small"><i class="refresh"></i> Refresh</button>').click(function(){me.reload_stats();}).appendTo($('<div class="stat-wrapper">').appendTo(me.$page.find('.layout-side-section')))}}});},render_stat:function(field,stat){var me=this;if(!stat||!stat.length){if(field=='_user_tags'){this.$page.find('.layout-side-section').append('<div class="stat-wrapper"><h4>Tags</h4>\
@ -1481,8 +1483,9 @@ Field.prototype.set_label=function(){if(this.with_label&&this.label_area&&this.l
Field.prototype.set_description=function(){if(this.df.description){var p=in_list(['Text Editor','Code','Check'],this.df.fieldtype)?this.label_area:this.wrapper;this.desc_area=$a(p,'div','help small','',this.df.description)
if(in_list(['Text Editor','Code'],this.df.fieldtype))
$(this.desc_area).addClass('help small');}}
Field.prototype.get_status=function(){if(this.in_filter)this.not_in_form=this.in_filter;if(this.not_in_form){return'Write';}
if(!this.df.permlevel)this.df.permlevel=0;var p=this.perm[this.df.permlevel];var ret;if(cur_frm.editable&&p&&p[WRITE])ret='Write';else if(p&&p[READ])ret='Read';else ret='None';if(this.df.fieldtype=='Binary')
Field.prototype.get_status=function(){if(this.in_filter)
this.not_in_form=this.in_filter;if(this.not_in_form){return'Write';}
if(!this.df.permlevel)this.df.permlevel=0;var p=this.perm[this.df.permlevel];var ret;if(cur_frm.editable&&p&&p[WRITE]&&!this.disabled)ret='Write';else if(p&&p[READ])ret='Read';else ret='None';if(this.df.fieldtype=='Binary')
ret='None';if(cint(this.df.hidden))
ret='None';if(ret=='Write'&&cint(cur_frm.doc.docstatus)>0)ret='Read';var a_o_s=cint(this.df.allow_on_submit);if(a_o_s&&(this.in_grid||(this.frm&&this.frm.not_in_container))){a_o_s=null;if(this.in_grid)a_o_s=this.grid.field.df.allow_on_submit;if(this.frm&&this.frm.not_in_container){a_o_s=cur_grid.field.df.allow_on_submit;}}
if(cur_frm.editable&&a_o_s&&cint(cur_frm.doc.docstatus)>0&&!this.df.hidden){tmp_perm=get_perm(cur_frm.doctype,cur_frm.docname,1);if(tmp_perm[this.df.permlevel]&&tmp_perm[this.df.permlevel][WRITE])ret='Write';}
@ -1784,7 +1787,7 @@ this.runclientscript('refresh');$(document).trigger('form_refresh');this.refresh
if(this.doc.docstatus==0){$(this.wrapper).find('.form-layout-row :input:first').focus();}}else{this.refresh_header();if(this.print_wrapper){this.refresh_print_layout();}
this.runclientscript('edit_status_changed');}
$(cur_frm.wrapper).trigger('render_complete');}}
_f.Frm.prototype.refresh_footer=function(){var f=this.page_layout.footer;if(f.save_area){if(get_url_arg('embed')||(this.editable&&(!this.meta.in_dialog||this.in_form)&&this.doc.docstatus==0&&!this.meta.istable&&this.get_doc_perms()[WRITE])){f.show_save();}else{f.hide_save();}}}
_f.Frm.prototype.refresh_footer=function(){var f=this.page_layout.footer;if(f.save_area){if(this.editable&&(!this.meta.in_dialog||this.in_form)&&this.doc.docstatus==0&&!this.meta.istable&&this.get_doc_perms()[WRITE]&&(this.fields&&this.fields.length>7)){f.show_save();}else{f.hide_save();}}}
_f.Frm.prototype.refresh_fields=function(){for(var i=0;i<this.fields.length;i++){var f=this.fields[i];f.perm=this.perm;f.docname=this.docname;var fn=f.df.fieldname||f.df.label;if(fn)
f.df=get_field(this.doctype,fn,this.docname);if(f.df.fieldtype!='Section Break'&&f.refresh){f.refresh();}}
$.each(this.sections,function(i,f){f.refresh(true);})
@ -1854,6 +1857,7 @@ _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)}}
_f.Frm.prototype.enable_fields=function(fields,enable){if(typeof fields=='string')fields=[fields];$.each(fields,function(i,f){var field=cur_frm.fields_dict[f];if(field){field.disabled=enable?false:true;field.refresh&&field.refresh();};})}
/*
* lib/js/legacy/widgets/form/form_fields.js
*/

View File

@ -18,8 +18,9 @@ Field.prototype.set_label=function(){if(this.with_label&&this.label_area&&this.l
Field.prototype.set_description=function(){if(this.df.description){var p=in_list(['Text Editor','Code','Check'],this.df.fieldtype)?this.label_area:this.wrapper;this.desc_area=$a(p,'div','help small','',this.df.description)
if(in_list(['Text Editor','Code'],this.df.fieldtype))
$(this.desc_area).addClass('help small');}}
Field.prototype.get_status=function(){if(this.in_filter)this.not_in_form=this.in_filter;if(this.not_in_form){return'Write';}
if(!this.df.permlevel)this.df.permlevel=0;var p=this.perm[this.df.permlevel];var ret;if(cur_frm.editable&&p&&p[WRITE])ret='Write';else if(p&&p[READ])ret='Read';else ret='None';if(this.df.fieldtype=='Binary')
Field.prototype.get_status=function(){if(this.in_filter)
this.not_in_form=this.in_filter;if(this.not_in_form){return'Write';}
if(!this.df.permlevel)this.df.permlevel=0;var p=this.perm[this.df.permlevel];var ret;if(cur_frm.editable&&p&&p[WRITE]&&!this.disabled)ret='Write';else if(p&&p[READ])ret='Read';else ret='None';if(this.df.fieldtype=='Binary')
ret='None';if(cint(this.df.hidden))
ret='None';if(ret=='Write'&&cint(cur_frm.doc.docstatus)>0)ret='Read';var a_o_s=cint(this.df.allow_on_submit);if(a_o_s&&(this.in_grid||(this.frm&&this.frm.not_in_container))){a_o_s=null;if(this.in_grid)a_o_s=this.grid.field.df.allow_on_submit;if(this.frm&&this.frm.not_in_container){a_o_s=cur_grid.field.df.allow_on_submit;}}
if(cur_frm.editable&&a_o_s&&cint(cur_frm.doc.docstatus)>0&&!this.df.hidden){tmp_perm=get_perm(cur_frm.doctype,cur_frm.docname,1);if(tmp_perm[this.df.permlevel]&&tmp_perm[this.df.permlevel][WRITE])ret='Write';}

View File

@ -45,8 +45,7 @@ this.set_sort_options(new_sl);if(sc&&sc.sort_by){this.dt.sort_sel.value=sc.sort_
if(sc&&sc.sort_order){sc.sort_order=='ASC'?this.dt.set_asc():this.dt.set_desc();}
if(sc&&sc.page_len){this.dt.page_len_sel.inp.value=sc.page_len;}
this.current_loaded=criteria_name;this.set_main_title(criteria_name,sc.description);}
_r.ReportBuilder.prototype.setup_filters_and_cols=function(){function can_dt_be_submitted(dt){if(locals.DocType&&locals.DocType[dt]&&locals.DocType[dt].allow_trash)return 1;var plist=getchildren('DocPerm',dt,'permissions','DocType');for(var pidx in plist){if(plist[pidx].submit)return 1;}
return 0;}
_r.ReportBuilder.prototype.setup_filters_and_cols=function(){function can_dt_be_submitted(dt){return locals.DocType[dt]&&locals.DocType[dt].is_submittable||0;}
var me=this;var dt=me.parent_dt?me.parent_dt:me.doctype;var fl=[{'fieldtype':'Data','label':'ID','fieldname':'name','in_filter':1,'parent':dt},{'fieldtype':'Data','label':'Owner','fieldname':'owner','in_filter':1,'parent':dt},{'fieldtype':'Date','label':'Created on','fieldname':'creation','in_filter':0,'parent':dt},{'fieldtype':'Date','label':'Last modified on','fieldname':'modified','in_filter':0,'parent':dt},];if(can_dt_be_submitted(dt)){fl[fl.length]={'fieldtype':'Check','label':'Saved','fieldname':'docstatus','search_index':1,'in_filter':1,'def_filter':1,'parent':dt};fl[fl.length]={'fieldtype':'Check','label':'Submitted','fieldname':'docstatus','search_index':1,'in_filter':1,'def_filter':1,'parent':dt};fl[fl.length]={'fieldtype':'Check','label':'Cancelled','fieldname':'docstatus','search_index':1,'in_filter':1,'parent':dt};}
me.make_datatable();me.orig_sort_list=[];if(me.parent_dt){me.setup_dt_filters_and_cols(fl,me.parent_dt);var fl=[];}
me.setup_dt_filters_and_cols(fl,me.doctype);if(!this.has_primary_filters)