custom field included in docfield query

This commit is contained in:
Nabin Hait 2012-05-21 14:40:25 +05:30
parent d9742a6a58
commit fec3f783af
3 changed files with 229 additions and 269 deletions

View File

@ -130,16 +130,6 @@ cur_frm.fields_dict['indent_no'].get_query = function(doc) {
return 'SELECT DISTINCT `tabPurchase Request`.`name` FROM `tabPurchase Request` WHERE `tabPurchase Request`.company = "' + doc.company + '" and `tabPurchase Request`.`docstatus` = 1 and `tabPurchase Request`.`status` != "Stopped" and ifnull(`tabPurchase Request`.`per_ordered`,0) < 100 and `tabPurchase Request`.%(key)s LIKE "%s" ORDER BY `tabPurchase Request`.`name` DESC LIMIT 50';
}
/*
//*********** get approved supplier quotation ********************
cur_frm.fields_dict['supplier_qtn'].get_query = function(doc) {
var cond='';
if(doc.supplier) cond = 'ifnull(`tabSupplier Quotation`.supplier, "") = "'+doc.supplier+'" and';
return repl('SELECT DISTINCT `tabSupplier Quotation`.`name` FROM `tabSupplier Quotation` WHERE `tabSupplier Quotation`.company = "%(company)s" and`tabSupplier Quotation`.`docstatus` = 1 and `tabSupplier Quotation`.`approval_status` = "Approved" and %(cond)s `tabSupplier Quotation`.%(key)s LIKE "%s" ORDER BY `tabSupplier Quotation`.`name` DESC LIMIT 50', {company:doc.company,cond:cond});
}
*/
//========================= Get Last Purhase Rate =====================================
cur_frm.cscript.get_last_purchase_rate = function(doc, cdt, cdn){

View File

@ -39,15 +39,12 @@ class DocType:
#==========================================================================
def get_att_list(self):
lst = [['Attendance','','','Please fill columns which are Mandatory.',' Please do not modify the structure','',''],['','','','','','',''],['[Mandatory]','','[Mandatory]','[Mandatory]','[Mandatory]','[Mandatory]','[Mandatory]'],['Employee','Employee Name','Attendance Date','Status','Fiscal Year','Company','Naming Series']]
dt = self.date_diff_list() # get date list inbetween from date and to date
att_dt = self.get_att_data() # get default attendance data like fiscal yr, company, naming series
fy, comp, sr = att_dt['fy'], att_dt['comp'], att_dt['sr']
res = sql("select name, employee_name from `tabEmployee` where status = 'Active' and docstatus !=2")
for d in dt:
@ -77,19 +74,18 @@ class DocType:
#------------------------------------------------------------------------------
def get_att_data(self):
fy = get_defaults()['fiscal_year'] #get default fiscal year
comp = get_defaults()['company'] #get default company
#get naming series of attendance
#sr = sql("select series_options from `tabNaming Series Options` where doc_type='Attendance'")
sr = sql("select options from `tabDocField` where parent = 'Attendance' and fieldname = 'naming_series'")
if not sr:
msgprint("Please create naming series for Attendance.\nGo to Setup--> Manage Series.")
import webnotes.model.doctype
docfield = webnotes.model.doctype.get('Attendance')
series = [d.options for d in docfield if d.doctype == 'DocField' and d.fieldname == 'naming_series']
if not series:
msgprint("Please create naming series for Attendance.\nGo to Setup--> Numbering Series.")
raise Exception
else:
sr = sr and sr[0][0]
sr = series[0][0] or ''
return {'fy':fy,'comp':comp,'sr':sr}

View File

@ -50,10 +50,6 @@ class DocType:
chk = chk and chk[0][0] or ''
return cstr(chk)
# Gets states belonging cto country selected
# =====================================================================
#def check_state(self):
# return "\n" + "\n".join([i[0] for i in sql("select state_name from `tabState` where `tabState`.country='%s' " % self.doc.country)])
# Get item detail (will be removed later)
#=======================================
@ -71,18 +67,6 @@ class DocType:
def validate(self):
import string
# Get Address
# ======================================================================
#if (self.doc.address_line1) or (self.doc.address_line2) or (self.doc.city) or (self.doc.state) or (self.doc.country) or (self.doc.pincode):
# address =["address_line1", "address_line2", "city", "state", "country", "pincode"]
# comp_address=''
# for d in address:
# if self.doc.fields[d]:
# comp_address += self.doc.fields[d] + "\n"
# if self.doc.website:
# comp_address += "Website : "+ self.doc.website
# self.doc.address = comp_address
if self.doc.status == 'Lead Lost' and not self.doc.order_lost_reason:
msgprint("Please Enter Quotation Lost Reason")
raise Exception
@ -96,16 +80,6 @@ class DocType:
msgprint('Please enter valid email id.')
raise Exception
if not self.doc.naming_series:
if session['user'] == 'Guest':
so = sql("select options from `tabDocField` where parent = 'Lead' and fieldname = 'naming_series'")
#so = sql("select series_options from `tabNaming Series Options` where doc_type='Lead'")
if so:
sr = so[0][0].split("\n")
set(self.doc, 'naming_series', sr[0])
else:
msgprint("Please specify naming series")
raise Exception
def on_update(self):
# Add to calendar
@ -119,10 +93,11 @@ class DocType:
if not self.doc.naming_series:
if session['user'] == 'Guest':
#so = sql("select series_options from `tabNaming Series Options` where doc_type='Lead'")
so = sql("select options from `tabDocField` where parent = 'Lead' and fieldname = 'naming_series'")
if so:
sr = so[0][0].split("\n")
import webnotes.model.doctype
docfield = webnotes.model.doctype.get('Lead')
series = [d.options for d in docfield if d.doctype == 'DocField' and d.fieldname == 'naming_series']
if series:
sr = series[0].split("\n")
set(self.doc, 'naming_series', sr[0])
else:
msgprint("Please specify naming series")
@ -136,7 +111,6 @@ class DocType:
subject = 'Thank you for interest in erpnext'
sendmail([self.doc.email_id.strip(' ')], sender = sender_email[0][0], subject = subject , parts = [['text/html', self.get_notification_msg()]])
#sendmail(cc_list, sender = sender_email[0][0], subject = subject , parts = [['text/html', message]],attach=attach_list)
msgprint("Mail Sent")
def get_notification_msg(self):