restructured erpnext and deleted unwanted

This commit is contained in:
nabinhait
2011-07-01 13:34:41 +05:30
parent c1c54c9400
commit ec097975d0
1280 changed files with 54494 additions and 88652 deletions

View File

View File

@@ -0,0 +1,335 @@
$import(SMS Control)
cur_frm.cscript.refresh = function(doc, cdt, cdn){
//cur_frm.cscript.get_tips(doc, cdt, cdn);
if(!doc.docstatus){
hide_field(['Update Follow up']);
hide_field(['email_id1','cc_to','subject','message','Attachment Html', 'Create New File', 'enquiry_attachment_detail','Send Email']);
}
else{
unhide_field(['Update Follow up']);
unhide_field(['email_id1','cc_to','subject','message','Attachment Html', 'Create New File', 'enquiry_attachment_detail','Send Email']);
}
cur_frm.clear_custom_buttons();
if(doc.docstatus == 1) {
cur_frm.add_custom_button('Create Quotation', cur_frm.cscript['Create Quotation']);
cur_frm.add_custom_button('Enquiry Lost', cur_frm.cscript['Declare Enquiry Lost']);
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
}
//cur_frm.cscript.clear_values(doc,cdt,cdn);
}
// ONLOAD
// ===============================================================
cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(!doc.enquiry_from) hide_field(['customer', 'customer_address', 'contact_person', 'customer_name','lead', 'lead_name', 'address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']);
if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
if(!doc.date) doc.transaction_date = date.obj_to_str(new Date());
if(!doc.company && sys_defaults.company) set_multiple(cdt,cdn,{company:sys_defaults.company});
if(!doc.fiscal_year && sys_defaults.fiscal_year) set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});
if(doc.enquiry_from) {
if(doc.enquiry_from == 'Customer') {
hide_field(['lead', 'lead_name']);
}
else if (doc.enquiry_from == 'Lead') {
hide_field(['customer', 'customer_address', 'contact_person', 'customer_name', 'contact_display', 'customer_group']);
}
}
// setup fetch
cur_frm.cscript.set_fetch();
}
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
if(doc.enquiry_from == 'Lead' && doc.lead) {
cur_frm.cscript.lead(doc,cdt,cdn);
}
}
// fetch
// ===============================================================
cur_frm.cscript.set_fetch = function() {
// item
cur_frm.add_fetch('item_code', 'item_name', 'item_name');
cur_frm.add_fetch('item_code', 'stock_uom', 'uom');
cur_frm.add_fetch('item_code', 'description', 'description');
cur_frm.add_fetch('item_code', 'item_group', 'item_group');
cur_frm.add_fetch('item_code', 'brand', 'brand');
// customer
}
// hide - unhide fields on basis of enquiry_from lead or customer
cur_frm.cscript.enquiry_from = function(doc,cdt,cdn){
cur_frm.cscript.lead_cust_show(doc,cdt,cdn);
}
// hide - unhide fields based on lead or customer
cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
if(doc.enquiry_from == 'Lead'){
unhide_field(['lead']);
hide_field(['lead_name','customer','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
doc.lead = doc.lead_name = doc.customer = doc.customer_address = doc.contact_person = doc.address_display = doc.contact_display = doc.contact_mobile = doc.contact_email = doc.territory = doc.customer_group = "";
}
else if(doc.enquiry_from == 'Customer'){
unhide_field(['customer']);
hide_field(['lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory']);
doc.lead = doc.lead_name = doc.customer = doc.customer_address = doc.contact_person = doc.address_display = doc.contact_display = doc.contact_mobile = doc.contact_email = doc.territory = doc.customer_group = "";
}
}
// customer
cur_frm.cscript.customer = function(doc,dt,dn) {
if(doc.customer) get_server_fields('get_default_customer_address', JSON.stringify({customer: doc.customer}),'', doc, dt, dn, 1);
if(doc.customer) unhide_field(['customer_name','customer_address','contact_person','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
}
cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc,dt,dn) {
if(doc.customer) get_server_fields('get_customer_address', JSON.stringify({customer: doc.customer, address: doc.customer_address, contact: doc.contact_person}),'', doc, dt, dn, 1);
}
cur_frm.fields_dict.customer_address.on_new = function(dn) {
locals['Address'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
locals['Address'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict.contact_person.on_new = function(dn) {
locals['Contact'][dn].customer = locals[cur_frm.doctype][cur_frm.docname].customer;
locals['Contact'][dn].customer_name = locals[cur_frm.doctype][cur_frm.docname].customer_name;
}
cur_frm.fields_dict['customer_address'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,address_line1,city FROM tabAddress WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
}
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return 'SELECT name,CONCAT(first_name," ",ifnull(last_name,"")) As FullName,department,designation FROM tabContact WHERE customer = "'+ doc.customer +'" AND docstatus != 2 AND name LIKE "%s" ORDER BY name ASC LIMIT 50';
}
// lead
cur_frm.fields_dict['lead'].get_query = function(doc,cdt,cdn){
return 'SELECT `tabLead`.name, `tabLead`.lead_name FROM `tabLead` WHERE `tabLead`.%(key)s LIKE "%s" ORDER BY `tabLead`.`name` ASC LIMIT 50';
}
cur_frm.cscript.lead = function(doc, cdt, cdn) {
if(doc.lead) get_server_fields('get_lead_details', doc.lead,'', doc, cdt, cdn, 1);
if(doc.lead) unhide_field(['lead_name','address_display','contact_mobile','contact_email','territory']);
}
//item getquery
//=======================================
cur_frm.fields_dict['enquiry_details'].grid.get_field('item_code').get_query = function(doc, cdt, cdn) {
if (doc.enquiry_type == 'Maintenance')
return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_service_item="Yes" AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';
else
return 'SELECT tabItem.name,tabItem.item_name,tabItem.description FROM tabItem WHERE tabItem.is_sales_item="Yes" AND (ifnull(`tabItem`.`end_of_life`,"") = "" OR `tabItem`.`end_of_life` > NOW() OR `tabItem`.`end_of_life`="0000-00-00") AND tabItem.%(key)s LIKE "%s" LIMIT 50';
}
//Fetch Item Details
//====================================================================================================================
cur_frm.cscript.item_code = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if (d.item_code) {
get_server_fields('get_item_details',d.item_code,'enquiry_details',doc,cdt,cdn,1);
}
}
/*
//Fetch Customer Details
//======================================================================================================================
cur_frm.cscript.customer = function(doc, cdt, cdn){
if (doc.customer) {
get_server_fields('get_cust_address',doc.customer,'',doc,cdt,cdn,1);
}
}
*/
/*
//=======================================================================================================================
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return 'SELECT `tabContact`.contact_name FROM `tabContact` WHERE `tabContact`.is_customer = 1 AND `tabContact`.customer = "'+ doc.customer+'" AND `tabContact`.docstatus != 2 AND `tabContact`.contact_name LIKE "%s" ORDER BY `tabContact`.contact_name ASC LIMIT 50';
}
*/
/*
//=======================================================================================================================
cur_frm.cscript.contact_person = function(doc, cdt, cdn){
if (doc.contact_person) {
arg = {};
arg.contact_person = doc.contact_person;
arg.customer = doc.customer;
get_server_fields('get_contact_details',docstring(arg),'',doc,cdt,cdn,1);
}
}
*/
/*
// hide - unhide fields based on lead or customer..
//=======================================================================================================================
cur_frm.cscript.clear_values = function(doc,cdt,cdn) {
if(doc.enquiry_from == 'Lead') {
doc.customer = doc.customer_name = doc.contact_person = doc.customer_group = "";
}
else if(doc.enquiry_from == 'Customer') {
doc.lead = doc.lead_name = "";
}
refresh_many(['lead','lead_name','customer','customer_name','contact_person','customer_group']);
}
*/
/*
//================ hide - unhide fields on basis of enquiry from either lead or customer ===============================
cur_frm.cscript.enquiry_from = function(doc,cdt,cdn){
cur_frm.cscript.clear_values(doc,cdt,cdn);
doc.address = doc.territory = doc.contact_no = doc.email_id = "";
refresh_many(['territory','address','contact_no','email_id']);
}
*/
/*
//================ create new contact ============================================================================
cur_frm.cscript.new_contact = function(){
tn = createLocal('Contact');
locals['Contact'][tn].is_customer = 1;
if(doc.customer) locals['Contact'][tn].customer = doc.customer;
loaddoc('Contact', tn);
}
*/
//=======================================================================================================================
cur_frm.cscript['Create New File'] = function(doc){
var fl = LocalDB.create('File');
fl = locals['File'][fl];
loaddoc('File', fl.name);
}
//update follow up
//=================================================================================
cur_frm.cscript['Update Follow up'] = function(doc,cdt,cdn){
$c_obj(make_doclist(doc.doctype, doc.name),'update_follow_up','',function(r, rt){
refresh_field('follow_up');
doc.__unsaved = 0;
cur_frm.refresh_header();
});
}
// Create New Quotation
// =======================================================================================================================
cur_frm.cscript['Create Quotation'] = function(){
n = createLocal("Quotation");
$c('dt_map', args={
'docs':compress_doclist([locals["Quotation"][n]]),
'from_doctype':'Enquiry',
'to_doctype':'Quotation',
'from_docname':cur_frm.docname,
'from_to_list':"[['Enquiry', 'Quotation'],['Enquiry Detail','Quotation Detail']]"
}
, function(r,rt) {
loaddoc("Quotation", n);
}
);
}
// declare enquiry lost
//-------------------------
cur_frm.cscript['Declare Enquiry Lost'] = function(){
var e_lost_dialog;
set_e_lost_dialog = function(){
e_lost_dialog = new Dialog(400,150,'Add Enquiry Lost Reason');
e_lost_dialog.make_body([
['HTML', 'Message', '<div class="comment">Please add enquiry lost reason</div>'],
['Text', 'Enquiry Lost Reason'],
['HTML', 'Response', '<div class = "comment" id="update_enquiry_dialog_response"></div>'],
['HTML', 'Add Reason', '<div></div>']
]);
var add_reason_btn1 = $a($i(e_lost_dialog.widgets['Add Reason']), 'button', 'button');
add_reason_btn1.innerHTML = 'Add';
add_reason_btn1.onclick = function(){ e_lost_dialog.add(); }
var add_reason_btn2 = $a($i(e_lost_dialog.widgets['Add Reason']), 'button', 'button');
add_reason_btn2.innerHTML = 'Cancel';
$y(add_reason_btn2,{marginLeft:'4px'});
add_reason_btn2.onclick = function(){ e_lost_dialog.hide();}
e_lost_dialog.onshow = function() {
e_lost_dialog.widgets['Enquiry Lost Reason'].value = '';
$i('update_enquiry_dialog_response').innerHTML = '';
}
e_lost_dialog.add = function() {
// sending...
$i('update_enquiry_dialog_response').innerHTML = 'Processing...';
var arg = strip(e_lost_dialog.widgets['Enquiry Lost Reason'].value);
var call_back = function(r,rt) {
if(r.message == 'true'){
$i('update_enquiry_dialog_response').innerHTML = 'Done';
e_lost_dialog.hide();
}
}
if(arg) {
$c_obj(make_doclist(cur_frm.doc.doctype, cur_frm.doc.name),'declare_enquiry_lost',arg,call_back);
}
else{
msgprint("Please add enquiry lost reason");
}
}
}
if(!e_lost_dialog){
set_e_lost_dialog();
}
e_lost_dialog.show();
}
//get query select Territory
//=======================================================================================================================
cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
return 'SELECT `tabTerritory`.`name`,`tabTerritory`.`parent_territory` FROM `tabTerritory` WHERE `tabTerritory`.`is_group` = "No" AND `tabTerritory`.`docstatus`!= 2 AND `tabTerritory`.%(key)s LIKE "%s" ORDER BY `tabTerritory`.`name` ASC LIMIT 50';}
/*
//===================== Enquiry From validation - either customer or lead is mandatory =====================================
cur_frm.cscript.enq_frm_validate = function(doc,cdt,cdn){
if(doc.enquiry_from == 'Lead'){
if(!doc.lead){
alert("Lead is mandatory.");
validated = false;
}
}
else if(doc.enquiry_from == 'Customer'){
if(!doc.customer){
alert("Customer is mandatory.");
validated = false;
}
else if(!doc.contact_person){
alert("Contact Person is mandatory.");
validated = false;
}
else if(!doc.customer_group){
alert("Customer Group is mandatory.");
validated = false;
}
}
}
*/
//===================validation function ==============================================================================
cur_frm.cscript.validate = function(doc,cdt,cdn){
//cur_frm.cscript.enq_frm_validate(doc,cdt,cdn);
}

View File

@@ -0,0 +1,335 @@
# Please edit this list and import only required elements
import webnotes
from webnotes.utils import add_days, add_months, add_years, cint, cstr, date_diff, default_fields, flt, fmt_money, formatdate, generate_hash, getTraceback, get_defaults, get_first_day, get_last_day, getdate, has_common, month_name, now, nowdate, replace_newlines, sendmail, set_default, str_esc_quote, user_format, validate_email_add
from webnotes.model import db_exists
from webnotes.model.doc import Document, addchild, removechild, getchildren, make_autoname, SuperDocType
from webnotes.model.doclist import getlist, copy_doclist
from webnotes.model.code import get_obj, get_server_obj, run_server_obj, updatedb, check_syntax
from webnotes import session, form, is_testing, msgprint, errprint
set = webnotes.conn.set
sql = webnotes.conn.sql
get_value = webnotes.conn.get_value
in_transaction = webnotes.conn.in_transaction
convert_to_lists = webnotes.conn.convert_to_lists
# -----------------------------------------------------------------------------------------
from utilities.transaction_base import TransactionBase
class DocType(TransactionBase):
def __init__(self,doc,doclist=[]):
self.doc = doc
self.doclist = doclist
self.fname = 'enq_details'
self.tname = 'Enquiry Detail'
# Autoname
# ====================================================================================================================
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.####')
#--------Get customer address-------
# ====================================================================================================================
def get_cust_address(self,name):
details = sql("select customer_name, address, territory, customer_group from `tabCustomer` where name = '%s' and docstatus != 2" %(name), as_dict = 1)
if details:
ret = {
'customer_name': details and details[0]['customer_name'] or '',
'address' : details and details[0]['address'] or '',
'territory' : details and details[0]['territory'] or '',
'customer_group' : details and details[0]['customer_group'] or ''
}
# ********** get primary contact details (this is done separately coz. , in case there is no primary contact thn it would not be able to fetch customer details in case of join query)
contact_det = sql("select contact_name, contact_no, email_id from `tabContact` where customer = '%s' and is_customer = 1 and is_primary_contact = 'Yes' and docstatus != 2" %(name), as_dict = 1)
ret['contact_person'] = contact_det and contact_det[0]['contact_name'] or ''
ret['contact_no'] = contact_det and contact_det[0]['contact_no'] or ''
ret['email_id'] = contact_det and contact_det[0]['email_id'] or ''
return cstr(ret)
else:
msgprint("Customer : %s does not exist in system." % (name))
raise Exception
# ====================================================================================================================
def get_contact_details(self, arg):
arg = eval(arg)
contact = sql("select contact_no, email_id from `tabContact` where contact_name = '%s' and customer_name = '%s'" %(arg['contact_person'],arg['customer']), as_dict = 1)
ret = {
'contact_no' : contact and contact[0]['contact_no'] or '',
'email_id' : contact and contact[0]['email_id'] or ''
}
return str(ret)
# ====================================================================================================================
def on_update(self):
# Add to calendar
#if self.doc.contact_date and self.doc.last_contact_date != self.doc.contact_date:
if self.doc.contact_date and self.doc.contact_date_ref != self.doc.contact_date:
if self.doc.contact_by:
self.add_calendar_event()
set(self.doc, 'contact_date_ref',self.doc.contact_date)
set(self.doc, 'status', 'Draft')
# Add to Calendar
# ====================================================================================================================
def add_calendar_event(self):
desc=''
user_lst =[]
if self.doc.customer:
if self.doc.contact_person:
desc = 'Contact '+cstr(self.doc.contact_person)
else:
desc = 'Contact customer '+cstr(self.doc.customer)
elif self.doc.lead:
if self.doc.lead_name:
desc = 'Contact '+cstr(self.doc.lead_name)
else:
desc = 'Contact lead '+cstr(self.doc.lead)
desc = desc+ '. By : ' + cstr(self.doc.contact_by)
if self.doc.to_discuss:
desc = desc+' To Discuss : ' + cstr(self.doc.to_discuss)
ev = Document('Event')
ev.description = desc
ev.event_date = self.doc.contact_date
ev.event_hour = '10:00'
ev.event_type = 'Private'
ev.ref_type = 'Enquiry'
ev.ref_name = self.doc.name
ev.save(1)
user_lst.append(self.doc.owner)
chk = sql("select t1.name from `tabProfile` t1, `tabSales Person` t2 where t2.email_id = t1.name and t2.name=%s",self.doc.contact_by)
if chk:
user_lst.append(chk[0][0])
for d in user_lst:
ch = addchild(ev, 'event_individuals', 'Event User', 0)
ch.person = d
ch.save(1)
#user_list = ['Sales Manager', 'Sales User']
#for d in user_list:
# ch = addchild(ev, 'event_individuals', 'Event User', 0)
# ch.person = d
# ch.save()
#--------------Validation For Last Contact Date-----------------
# ====================================================================================================================
def set_last_contact_date(self):
#if not self.doc.contact_date_ref:
#self.doc.contact_date_ref=self.doc.contact_date
#self.doc.last_contact_date=self.doc.contact_date_ref
if self.doc.contact_date_ref and self.doc.contact_date_ref != self.doc.contact_date:
if getdate(self.doc.contact_date_ref) < getdate(self.doc.contact_date):
self.doc.last_contact_date=self.doc.contact_date_ref
else:
msgprint("Contact Date Cannot be before Last Contact Date")
raise Exception
#set(self.doc, 'contact_date_ref',self.doc.contact_date)
# check if item present in item table
# ====================================================================================================================
def validate_item_details(self):
if not getlist(self.doclist, 'enquiry_details'):
msgprint("Please select items for which enquiry needs to be made")
raise Exception
#check if enquiry date in the range of fiscal year selected
#=====================================================
def validate_fiscal_year(self):
fy=sql("select year_start_date from `tabFiscal Year` where name='%s'"%self.doc.fiscal_year)
ysd=fy and fy[0][0] or ""
yed=add_days(str(ysd),365)
if str(self.doc.transaction_date) < str(ysd) or str(self.doc.transaction_date) > str(yed):
msgprint("Enquiry Date is not within the Fiscal Year selected")
raise Exception
def validate(self):
self.validate_fiscal_year()
self.set_last_contact_date()
self.validate_item_details()
# On Submit Functions
# ====================================================================================================================
def on_submit(self):
set(self.doc, 'status', 'Submitted')
# ====================================================================================================================
def on_cancel(self):
chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Detail` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name)
if chk:
msgprint("Quotation No. "+cstr(chk[0][0])+" is submitted against this Enquiry. Thus can not be cancelled.")
raise Exception
else:
set(self.doc, 'status', 'Cancelled')
get_obj('Feed Control').make_feed(self.doc, 'cancelled')
# declare as enquiry lost
#---------------------------
def declare_enquiry_lost(self,arg):
chk = sql("select t1.name from `tabQuotation` t1, `tabQuotation Detail` t2 where t2.parent = t1.name and t1.docstatus=1 and (t1.status!='Order Lost' and t1.status!='Cancelled') and t2.prevdoc_docname = %s",self.doc.name)
if chk:
msgprint("Quotation No. "+cstr(chk[0][0])+" is submitted against this Enquiry. Thus 'Enquiry Lost' can not be declared against it.")
raise Exception
else:
set(self.doc, 'status', 'Enquiry Lost')
set(self.doc, 'order_lost_reason', arg)
return cstr('true')
# ====================================================================================================================
def update_follow_up(self):
sql("delete from `tabFollow up` where parent = '%s'"%self.doc.name);
for d in getlist(self.doclist, 'follow_up'):
d.save()
self.doc.save()
# On Send Email
# ====================================================================================================================
#def send_emails(self,email,sender,subject,message):
# if email:
# sendmail(email,sender,subject=subject or 'Enquiry',parts=[['text/plain',message or self.get_enq_summary()]])
# Prepare HTML Table and Enter Enquiry Details in it, which will be added in enq summary
# ====================================================================================================================
def quote_table(self):
if getlist(self.doclist,'enq_details'):
header_lbl = ['Item Code','Item Name','Description','Reqd Qty','UOM']
item_tbl = '''<table style="width:90%%; border:1px solid #AAA; border-collapse:collapse"><tr>'''
for i in header_lbl:
item_header = '''<td style="width=20%%; border:1px solid #AAA; border-collapse:collapse;"><b>%s</b></td>''' % i
item_tbl += item_header
item_tbl += '''</tr>'''
for d in getlist(self.doclist,'enq_details'):
item_det = '''
<tr><td style="width:20%%; border:1px solid #AAA; border-collpase:collapse">%s</td>
<td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
<td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
<td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td>
<td style="width:20%%; border:1px solid #AAA; border-collapse:collpase">%s</td></tr>
''' % (d.item_code,d.item_name,d.description,d.reqd_qty,d.uom)
item_tbl += item_det
item_tbl += '''</table>'''
return item_tbl
# Prepare HTML Page containing summary of Enquiry, which will be sent as message in E-mail
# ====================================================================================================================
def get_enq_summary(self):
t = """
<html><head></head>
<body>
<div style="border:1px solid #AAA; padding:20px; width:100%%">
<div style="text-align:center;font-size:14px"><b>Request For Quotation</b><br></div>
<div style="text-align:center;font-size:12px"> %(from_company)s</div>
<div style="text-align:center; font-size:10px"> %(company_address)s</div>
<div style="border-bottom:1px solid #AAA; padding:10px"></div>
<div style="padding-top:10px"><b>Quotation Details</b></div>
<div><table style="width:100%%">
<tr><td style="width:40%%">Enquiry No:</td> <td style="width:60%%"> %(name)s</td></tr>
<tr><td style="width:40%%">Opening Date:</td> <td style="width:60%%"> %(transaction_date)s</td></tr>
<tr><td style="width:40%%">Expected By Date:</td> <td style="width:60%%"> %(expected_date)s</td></tr>
</table>
</div>
<div style="padding-top:10px"><b>Terms and Conditions</b></div>
<div> %(terms_and_conditions)s</div>
<div style="padding-top:10px"><b>Contact Details</b></div>
<div><table style="width:100%%">
<tr><td style="width=40%%">Contact Person:</td><td style="width:60%%"> %(contact_person)s</td></tr>
<tr><td style="width=40%%">Contact No:</td><td style="width:60%%"> %(contact_no)s</td></tr>
<tr><td style="width=40%%">Email:</td><td style="width:60%%"> %(email)s</td></tr>
</table></div>
""" % (self.doc.fields)
t += """<br><div><b>Quotation Items</b><br></div><div style="width:100%%">%s</div>
<br>
To login into the system, use link : <div><a href='http://67.205.111.118/v160/login.html' target='_blank'>http://67.205.111.118/v160/login.html</a></div><br><br>
</div>
</body>
</html>
""" % (self.quote_table())
return t
#-----------------Email--------------------------------------------
# ====================================================================================================================
def send_emails(self, email=[], subject='', message=''):
if email:
sender_email= sql("Select email from `tabProfile` where name='%s'"%session['user'])
if sender_email and sender_email[0][0]:
attach_list=[]
for at in getlist(self.doclist,'enquiry_attachment_detail'):
if at.select_file:
attach_list.append(at.select_file)
cc_list=[]
if self.doc.cc_to:
for cl in (self.doc.cc_to.split(',')):
if not validate_email_add(cl.strip(' ')):
msgprint('error:%s is not a valid email id' % cl.strip(' '))
raise Exception
cc_list.append(cl.strip(' '))
sendmail(cc_list, sender=sender_email[0][0], subject=subject, parts=[['text/html', message]], attach=attach_list)
sendmail(email, sender=sender_email[0][0], subject=subject, parts=[['text/html', message]], cc=cc_list, attach=attach_list)
#sendmail(cc_list, sender = sender_email[0][0], subject = subject , parts = [['text/html', message]],attach=attach_list)
msgprint("Mail has been sent")
self.add_in_follow_up(message,'Email')
else:
msgprint("Please enter your mail id in Profile")
raise Exception
#-------------------------Checking Sent Mails Details----------------------------------------------
# ====================================================================================================================
def sent_mail(self):
if not self.doc.subject or not self.doc.message:
msgprint("Please enter subject & message in their respective fields.")
elif not self.doc.email_id1:
msgprint("Recipient not specified. Please add email id in 'Send To'.")
raise Exception
else :
if not validate_email_add(self.doc.email_id1.strip(' ')):
msgprint('error:%s is not a valid email id' % self.doc.email_id1)
else:
self.send_emails([self.doc.email_id1.strip(' ')], subject = self.doc.subject ,message = self.doc.message)
#---------------------- Add details in follow up table----------------
# ====================================================================================================================
def add_in_follow_up(self,message,type):
import datetime
child = addchild( self.doc, 'follow_up', 'Follow up', 1, self.doclist)
child.date = datetime.datetime.now().date().strftime('%Y-%m-%d')
child.notes = message
child.follow_up_type = type
child.save()
#-------------------SMS----------------------------------------------
# ====================================================================================================================
def send_sms(self):
if not self.doc.sms_message:
msgprint("Please enter message in SMS Section ")
raise Exception
elif not getlist(self.doclist, 'enquiry_sms_detail'):
msgprint("Please mention mobile no. to which sms needs to be sent")
raise Exception
else:
receiver_list = []
for d in getlist(self.doclist,'enquiry_sms_detail'):
if d.other_mobile_no:
receiver_list.append(d.other_mobile_no)
if receiver_list:
msgprint(get_obj('SMS Control', 'SMS Control').send_sms(receiver_list, self.doc.sms_message))
self.add_in_follow_up(self.doc.sms_message,'SMS')

View File

@@ -0,0 +1,657 @@
# DocType, Enquiry
[
# These values are common in all dictionaries
{
'creation': '2010-08-08 17:09:00',
'docstatus': 0,
'modified': '2011-05-12 18:27:46',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1305205067',
'colour': 'White:FFF',
'doctype': 'DocType',
'document_type': 'Transaction',
'module': 'Selling',
'name': '__common__',
'search_fields': 'status,transaction_date,customer,lead,enquiry_type,territory,company',
'section_style': 'Tabbed',
'server_code_error': ' ',
'show_in_menu': 0,
'subject': 'To %(customer_name)s%(lead_name)s on %(transaction_date)s',
'version': 586
},
# These values are common for all DocField
{
'doctype': 'DocField',
'name': '__common__',
'parent': 'Enquiry',
'parentfield': 'fields',
'parenttype': 'DocType'
},
# These values are common for all DocPerm
{
'doctype': 'DocPerm',
'name': '__common__',
'parent': 'Enquiry',
'parentfield': 'permissions',
'parenttype': 'DocType',
'read': 1
},
# DocType, Enquiry
{
'doctype': 'DocType',
'name': 'Enquiry'
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 1,
'permlevel': 1,
'role': 'Sales Manager',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 2,
'permlevel': 0,
'role': 'System Manager',
'submit': 1,
'write': 1
},
# DocPerm
{
'doctype': 'DocPerm',
'idx': 3,
'permlevel': 1,
'role': 'System Manager'
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 4,
'permlevel': 0,
'role': 'Sales User',
'submit': 1,
'write': 1
},
# DocPerm
{
'amend': 0,
'cancel': 0,
'create': 0,
'doctype': 'DocPerm',
'idx': 5,
'permlevel': 1,
'role': 'Sales User',
'submit': 0,
'write': 0
},
# DocPerm
{
'amend': 1,
'cancel': 1,
'create': 1,
'doctype': 'DocPerm',
'idx': 6,
'permlevel': 0,
'role': 'Sales Manager',
'submit': 1,
'write': 1
},
# DocField
{
'colour': 'White:FFF',
'description': 'Enter customer enquiry for which you might raise a quotation in future',
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 1,
'label': 'Basic Info',
'oldfieldtype': 'Section Break',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'description': 'To manage multiple series please go to Setup > Manage Series',
'doctype': 'DocField',
'fieldname': 'naming_series',
'fieldtype': 'Select',
'idx': 2,
'label': 'Series',
'no_copy': 1,
'oldfieldname': 'naming_series',
'oldfieldtype': 'Select',
'options': 'ENQUIRY\nENQ',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'enquiry_from',
'fieldtype': 'Select',
'idx': 3,
'label': 'Enquiry From',
'oldfieldname': 'enquiry_from',
'oldfieldtype': 'Select',
'options': '\nLead\nCustomer',
'permlevel': 0,
'print_hide': 1,
'report_hide': 0,
'reqd': 1,
'trigger': 'Client'
},
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'customer',
'fieldtype': 'Link',
'hidden': 0,
'idx': 4,
'in_filter': 1,
'label': 'Customer',
'oldfieldname': 'customer',
'oldfieldtype': 'Link',
'options': 'Customer',
'permlevel': 0,
'print_hide': 1,
'reqd': 0,
'search_index': 0,
'trigger': 'Client'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'customer_address',
'fieldtype': 'Link',
'idx': 5,
'in_filter': 1,
'label': 'Customer Address',
'options': 'Address',
'permlevel': 0,
'print_hide': 1,
'trigger': 'Client'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'contact_person',
'fieldtype': 'Link',
'idx': 6,
'in_filter': 1,
'label': 'Contact Person',
'options': 'Contact',
'permlevel': 0,
'print_hide': 1,
'trigger': 'Client'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'customer_name',
'fieldtype': 'Data',
'idx': 7,
'label': 'Customer Name',
'permlevel': 1,
'print_hide': 0
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'lead',
'fieldtype': 'Link',
'hidden': 0,
'idx': 8,
'in_filter': 1,
'label': 'Lead',
'oldfieldname': 'lead',
'oldfieldtype': 'Link',
'options': 'Lead',
'permlevel': 0,
'print_hide': 1,
'trigger': 'Client'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'lead_name',
'fieldtype': 'Data',
'hidden': 0,
'idx': 9,
'label': 'Name',
'oldfieldname': 'lead_name',
'oldfieldtype': 'Data',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'address_display',
'fieldtype': 'Small Text',
'hidden': 0,
'idx': 10,
'label': 'Address',
'oldfieldname': 'address',
'oldfieldtype': 'Small Text',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'contact_display',
'fieldtype': 'Small Text',
'idx': 11,
'label': 'Contact',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'contact_mobile',
'fieldtype': 'Text',
'idx': 12,
'label': 'Contact Mobile No',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'contact_email',
'fieldtype': 'Text',
'idx': 13,
'label': 'Contact Email',
'permlevel': 1
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 14,
'oldfieldtype': 'Column Break',
'permlevel': 0,
'width': '50%'
},
# DocField
{
'default': 'Today',
'description': 'The date at which current entry is made in system.',
'doctype': 'DocField',
'fieldname': 'transaction_date',
'fieldtype': 'Date',
'idx': 15,
'label': 'Enquiry Date',
'oldfieldname': 'transaction_date',
'oldfieldtype': 'Date',
'permlevel': 0,
'reqd': 1,
'width': '50px'
},
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'enquiry_type',
'fieldtype': 'Select',
'idx': 16,
'label': 'Enquiry Type',
'oldfieldname': 'enquiry_type',
'oldfieldtype': 'Select',
'options': '\nSales\nMaintenance',
'permlevel': 0,
'reqd': 1
},
# DocField
{
'colour': 'White:FFF',
'default': 'Draft',
'doctype': 'DocField',
'fieldname': 'status',
'fieldtype': 'Select',
'idx': 17,
'label': 'Status',
'no_copy': 1,
'oldfieldname': 'status',
'oldfieldtype': 'Select',
'options': '\nDraft\nSubmitted\nQuotation Sent\nOrder Confirmed\nEnquiry Lost\nCancelled',
'permlevel': 1,
'reqd': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'amended_from',
'fieldtype': 'Data',
'idx': 18,
'label': 'Amended From',
'no_copy': 1,
'oldfieldname': 'amended_from',
'oldfieldtype': 'Data',
'permlevel': 1,
'print_hide': 1,
'width': '150px'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'amendment_date',
'fieldtype': 'Date',
'idx': 19,
'label': 'Amendment Date',
'no_copy': 1,
'oldfieldname': 'amendment_date',
'oldfieldtype': 'Date',
'permlevel': 1,
'print_hide': 1,
'width': '150px'
},
# DocField
{
'colour': 'White:FFF',
'description': '<a href="javascript:cur_frm.cscript.TerritoryHelp();">To Manage Territory, click here</a>',
'doctype': 'DocField',
'fieldname': 'territory',
'fieldtype': 'Link',
'idx': 20,
'in_filter': 1,
'label': 'Territory',
'options': 'Territory',
'permlevel': 0,
'print_hide': 1,
'reqd': 1,
'search_index': 1,
'trigger': 'Client'
},
# DocField
{
'colour': 'White:FFF',
'description': '<a href="javascript:cur_frm.cscript.CGHelp();">To Manage Customer Groups, click here</a>',
'doctype': 'DocField',
'fieldname': 'customer_group',
'fieldtype': 'Link',
'hidden': 0,
'idx': 21,
'in_filter': 1,
'label': 'Customer Group',
'oldfieldname': 'customer_group',
'oldfieldtype': 'Link',
'options': 'Customer Group',
'permlevel': 0,
'print_hide': 1,
'reqd': 0,
'search_index': 1,
'trigger': 'Client'
},
# DocField
{
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 22,
'label': 'Items',
'oldfieldtype': 'Section Break',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'description': "Items which do not exist in Item master can also be entered on customer's request",
'doctype': 'DocField',
'fieldname': 'enquiry_details',
'fieldtype': 'Table',
'idx': 23,
'label': 'Enquiry Details',
'oldfieldname': 'enquiry_details',
'oldfieldtype': 'Table',
'options': 'Enquiry Detail',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'description': 'Filing in Additional Information about the Enquiry will help you analyze your data better.',
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 24,
'label': 'More Info',
'oldfieldtype': 'Section Break',
'permlevel': 0
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 25,
'oldfieldtype': 'Column Break',
'permlevel': 0,
'width': '50%'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'company',
'fieldtype': 'Link',
'idx': 26,
'in_filter': 1,
'label': 'Company',
'oldfieldname': 'company',
'oldfieldtype': 'Link',
'options': 'Company',
'permlevel': 0,
'print_hide': 1,
'reqd': 1,
'search_index': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'fiscal_year',
'fieldtype': 'Select',
'idx': 27,
'in_filter': 1,
'label': 'Fiscal Year',
'oldfieldname': 'fiscal_year',
'oldfieldtype': 'Select',
'options': 'link:Fiscal Year',
'permlevel': 0,
'print_hide': 1,
'reqd': 1,
'search_index': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'source',
'fieldtype': 'Select',
'idx': 28,
'label': 'Source',
'oldfieldname': 'source',
'oldfieldtype': 'Select',
'options': "\nExisting Customer\nReference\nAdvertisement\nCold Calling\nExhibition\nSupplier Reference\nMass Mailing\nCustomer's Vendor\nCampaign\nWalk In",
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'description': 'Enter name of campaign if source of enquiry is campaign',
'doctype': 'DocField',
'fieldname': 'campaign',
'fieldtype': 'Link',
'idx': 29,
'label': 'Campaign',
'oldfieldname': 'campaign',
'oldfieldtype': 'Link',
'options': 'Campaign',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'depends_on': 'eval:!doc.__islocal',
'doctype': 'DocField',
'fieldname': 'order_lost_reason',
'fieldtype': 'Small Text',
'idx': 30,
'label': 'Order Lost Reason',
'no_copy': 1,
'oldfieldname': 'order_lost_reason',
'oldfieldtype': 'Small Text',
'permlevel': 1,
'report_hide': 0
},
# DocField
{
'doctype': 'DocField',
'fieldtype': 'Column Break',
'idx': 31,
'oldfieldtype': 'Column Break',
'permlevel': 0,
'width': '50%'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Your sales person who will contact the customer in future',
'doctype': 'DocField',
'fieldname': 'contact_by',
'fieldtype': 'Link',
'idx': 32,
'in_filter': 1,
'label': 'Next Contact By',
'oldfieldname': 'contact_by',
'oldfieldtype': 'Link',
'options': 'Profile',
'permlevel': 0,
'width': '75px'
},
# DocField
{
'colour': 'White:FFF',
'description': 'Your sales person will get a reminder on this date to contact the customer',
'doctype': 'DocField',
'fieldname': 'contact_date',
'fieldtype': 'Date',
'idx': 33,
'label': 'Next Contact Date',
'oldfieldname': 'contact_date',
'oldfieldtype': 'Date',
'permlevel': 0
},
# DocField
{
'allow_on_submit': 0,
'colour': 'White:FFF',
'depends_on': 'eval:!doc.__islocal',
'description': 'Date on which the lead was last contacted',
'doctype': 'DocField',
'fieldname': 'last_contact_date',
'fieldtype': 'Date',
'idx': 34,
'label': 'Last Contact Date',
'no_copy': 1,
'oldfieldname': 'last_contact_date',
'oldfieldtype': 'Date',
'permlevel': 1,
'print_hide': 1
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'to_discuss',
'fieldtype': 'Small Text',
'idx': 35,
'label': 'To Discuss',
'no_copy': 1,
'oldfieldname': 'to_discuss',
'oldfieldtype': 'Small Text',
'permlevel': 0
},
# DocField
{
'colour': 'White:FFF',
'description': 'Keep a track of communication related to this enquiry which will help for future reference.',
'doctype': 'DocField',
'fieldtype': 'Section Break',
'idx': 36,
'label': 'Communication History',
'oldfieldtype': 'Section Break',
'permlevel': 0
},
# DocField
{
'allow_on_submit': 1,
'colour': 'White:FFF',
'doctype': 'DocField',
'fieldname': 'follow_up',
'fieldtype': 'Table',
'idx': 37,
'label': 'Follow Up',
'oldfieldname': 'follow_up',
'oldfieldtype': 'Table',
'options': 'Follow up',
'permlevel': 0
}
]