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,310 @@
// Module CRM
cur_frm.cscript.tname = "Quotation Detail";
cur_frm.cscript.fname = "quotation_details";
cur_frm.cscript.other_fname = "other_charges";
cur_frm.cscript.sales_team_fname = "sales_team";
// =====================================================================================
$import(Sales Common)
$import(Other Charges)
$import(SMS Control)
// ONLOAD
// ===================================================================================
cur_frm.cscript.onload = function(doc, cdt, cdn) {
if(!doc.quotation_to) 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.price_list_name) set_multiple(cdt,cdn,{price_list_name:sys_defaults.price_list_name});
if(!doc.status) set_multiple(cdt,cdn,{status:'Draft'});
if(!doc.transaction_date) set_multiple(cdt,cdn,{transaction_date:get_today()});
if(!doc.conversion_rate) set_multiple(cdt,cdn,{conversion_rate:'1.00'});
if(!doc.currency && sys_defaults.currency) set_multiple(cdt,cdn,{currency:sys_defaults.currency});
//if(!doc.price_list_name && sys_defaults.price_list_name) set_multiple(cdt,cdn,{price_list_name:sys_defaults.price_list_name});
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.quotation_to) {
if(doc.quotation_to == 'Customer') {
hide_field(['lead', 'lead_name']);
}
else if (doc.quotation_to == 'Lead') {
hide_field(['customer','customer_address','contact_person', 'customer_name','contact_display', 'customer_group']);
}
}
}
cur_frm.cscript.onload_post_render = function(doc, dt, dn) {
// load default charges
if(doc.__islocal && !getchildren('RV Tax Detail', doc.name, 'other_charges', doc.doctype).length)
cur_frm.cscript.load_taxes(doc, cdt, cdn);
}
// hide - unhide fields based on lead or customer..
// =======================================================================================================================
cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
if(doc.quotation_to == '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.quotation_to == '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 = "";
}
//refresh_many(['lead','customer']);
}
//================ hide - unhide fields on basis of quotation to either lead or customer ===============================
cur_frm.cscript.quotation_to = function(doc,cdt,cdn){
cur_frm.cscript.lead_cust_show(doc,cdt,cdn);
//doc.customer_address = doc.territory = doc.contact_no = doc.email_id = "";
//refresh_many(['territory','customer_address','contact_no','email_id']);
//doc.address_display = doc.contact_display = "";
//refresh_many(['address_display','contact_display']);
}
// REFRESH
// ===================================================================================
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
cur_frm.clear_custom_buttons();
if(doc.docstatus == 1 && doc.status!='Order Lost') {
cur_frm.add_custom_button('Make Sales Order', cur_frm.cscript['Make Sales Order']);
cur_frm.add_custom_button('Set as Lost', cur_frm.cscript['Declare Order Lost']);
cur_frm.add_custom_button('Send SMS', cur_frm.cscript['Send SMS']);
}
if (!doc.docstatus) hide_field(['Update Follow up']);
else unhide_field(['Update Follow up']);
//cur_frm.cscript.lead_cust_show(doc,cdt,cdn);
}
// ============== Lead and its Details ============================
/*
//================ 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);
}
*/
// DOCTYPE TRIGGERS
// ====================================================================================
/*
// ***************** Get Contact Person based on customer selected *****************
cur_frm.fields_dict['contact_person'].get_query = function(doc, cdt, cdn) {
return 'SELECT `tabContact`.contact_name, `tabContact`.email_id FROM `tabContact` WHERE `tabContact`.is_customer = 1 AND `tabContact`.docstatus != 2 AND `tabContact`.customer = "'+ doc.customer +'" AND `tabContact`.docstatus != 2 AND `tabContact`.contact_name LIKE "%s" ORDER BY `tabContact`.contact_name ASC LIMIT 50';
}
*/
//customer
cur_frm.cscript.customer = function(doc,dt,dn) {
var callback = function(r,rt) {
var doc = locals[cur_frm.doctype][cur_frm.docname];
cur_frm.refresh();
}
if(doc.customer) $c_obj(make_doclist(doc.doctype, doc.name), 'get_default_customer_address', '', callback);
if(doc.customer) unhide_field(['customer_address','contact_person','customer_name','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']);
}
// =====================================================================================
cur_frm.fields_dict['enq_no'].get_query = function(doc,cdt,cdn){
var cond='';
var cond1='';
if(doc.order_type) cond = 'ifnull(`tabEnquiry`.enquiry_type, "") = "'+doc.order_type+'" AND';
if(doc.customer) cond1 = '`tabEnquiry`.customer = "'+doc.customer+'" AND';
else if(doc.lead) cond1 = '`tabEnquiry`.lead = "'+doc.lead+'" AND';
return repl('SELECT `tabEnquiry`.`name` FROM `tabEnquiry` WHERE `tabEnquiry`.`docstatus` = 1 AND `tabEnquiry`.status = "Submitted" AND %(cond)s %(cond1)s `tabEnquiry`.`name` LIKE "%s" ORDER BY `tabEnquiry`.`name` ASC LIMIT 50', {cond:cond, cond1:cond1});
}
// Make Sales Order
// =====================================================================================
cur_frm.cscript['Make Sales Order'] = function() {
var doc = cur_frm.doc;
if (doc.docstatus == 1) {
var n = createLocal("Sales Order");
$c('dt_map', args={
'docs':compress_doclist([locals["Sales Order"][n]]),
'from_doctype':'Quotation',
'to_doctype':'Sales Order',
'from_docname':doc.name,
'from_to_list':"[['Quotation', 'Sales Order'], ['Quotation Detail', 'Sales Order Detail'],['RV Tax Detail','RV Tax Detail'], ['Sales Team', 'Sales Team'], ['TC Detail', 'TC Detail']]"
}, function(r,rt) {
loaddoc("Sales Order", n);
});
}
}
//pull enquiry details
cur_frm.cscript['Pull Enquiry Detail'] = function(doc,cdt,cdn){
var callback = function(r,rt){
if(r.message){
doc.quotation_to = r.message;
if(doc.quotation_to == 'Lead') {
unhide_field(['lead','lead_name','address_display','contact_mobile','contact_email','territory']);
}
else if(doc.quotation_to == 'Customer') {
unhide_field(['customer','customer_address','contact_person','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
}
refresh_many(['quotation_details','quotation_to','customer','customer_address','contact_person','lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group','order_type']);
}
}
$c_obj(make_doclist(doc.doctype, doc.name),'pull_enq_details','',callback);
}
//update follow up
//=================================================================================
cur_frm.cscript['Update Follow up'] = function(doc){
$c_obj(make_doclist(doc.doctype, doc.name),'update_followup_details','',function(r, rt){
refresh_field('follow_up');
doc.__unsaved = 0;
cur_frm.refresh_header();
});
}
// declare order lost
//-------------------------
cur_frm.cscript['Declare Order Lost'] = function(){
var qtn_lost_dialog;
set_qtn_lost_dialog = function(doc,cdt,cdn){
qtn_lost_dialog = new Dialog(400,400,'Add Quotation Lost Reason');
qtn_lost_dialog.make_body([
['HTML', 'Message', '<div class="comment">Please add quotation lost reason</div>'],
['Text', 'Quotation Lost Reason'],
['HTML', 'Response', '<div class = "comment" id="update_quotation_dialog_response"></div>'],
['HTML', 'Add Reason', '<div></div>']
]);
var add_reason_btn1 = $a($i(qtn_lost_dialog.widgets['Add Reason']), 'button', 'button');
add_reason_btn1.innerHTML = 'Add';
add_reason_btn1.onclick = function(){ qtn_lost_dialog.add(); }
var add_reason_btn2 = $a($i(qtn_lost_dialog.widgets['Add Reason']), 'button', 'button');
add_reason_btn2.innerHTML = 'Cancel';
$y(add_reason_btn2,{marginLeft:'4px'});
add_reason_btn2.onclick = function(){ qtn_lost_dialog.hide();}
qtn_lost_dialog.onshow = function() {
qtn_lost_dialog.widgets['Quotation Lost Reason'].value = '';
$i('update_quotation_dialog_response').innerHTML = '';
}
qtn_lost_dialog.add = function() {
// sending...
$i('update_quotation_dialog_response').innerHTML = 'Processing...';
var arg = strip(qtn_lost_dialog.widgets['Quotation Lost Reason'].value);
var call_back = function(r,rt) {
if(r.message == 'true'){
$i('update_quotation_dialog_response').innerHTML = 'Done';
qtn_lost_dialog.hide();
}
}
if(arg) $c_obj(make_doclist(cur_frm.doc.doctype, cur_frm.doc.name),'declare_order_lost',arg,call_back);
else msgprint("Please add Quotation lost reason");
}
}
if(!qtn_lost_dialog){
set_qtn_lost_dialog(doc,cdt,cdn);
}
qtn_lost_dialog.show();
}
// GET REPORT
// ========================================================================================
cur_frm.cscript['Get Report'] = function(doc,cdt,cdn) {
var callback = function(report){
report.set_filter('Sales Order Detail', 'Quotation No.',doc.name)
report.dt.run();
}
loadreport('Sales Order Detail','Itemwise Sales Details', callback);
}
/*
//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';}
*/
//===================== Quotation to validation - either customer or lead mandatory ====================
cur_frm.cscript.quot_to_validate = function(doc,cdt,cdn){
if(doc.quotation_to == 'Lead'){
if(!doc.lead){
alert("Lead is mandatory.");
validated = false;
}
}
else if(doc.quotation_to == 'Customer'){
if(!doc.customer){
alert("Customer is mandatory.");
validated = false;
}
}
}
//===================validation function =================================
cur_frm.cscript.validate = function(doc,cdt,cdn){
cur_frm.cscript.quot_to_validate(doc,cdt,cdn);
}

View File

@@ -0,0 +1,363 @@
# 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, load_json
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.tname = 'Quotation Detail'
self.fname = 'quotation_details'
# Notification objects
self.notify_obj = get_obj('Notification Control')
# Autoname
# ---------
def autoname(self):
self.doc.name = make_autoname(self.doc.naming_series+'.#####')
# DOCTYPE TRIGGER FUNCTIONS
# ==============================================================================
# Pull Enquiry Details
# --------------------
def pull_enq_details(self):
self.doc.clear_table(self.doclist, 'quotation_details')
get_obj('DocType Mapper', 'Enquiry-Quotation').dt_map('Enquiry', 'Quotation', self.doc.enq_no, self.doc, self.doclist, "[['Enquiry', 'Quotation'],['Enquiry Detail', 'Quotation Detail']]")
self.get_adj_percent()
return cstr(self.doc.quotation_to)
# Get Customer Details
# --------------------
#def get_customer_details(self):
# return cstr(get_obj('Sales Common').get_customer_details(self))
# Get contact person details based on customer selected
# ------------------------------------------------------
def get_contact_details(self):
return cstr(get_obj('Sales Common').get_contact_details(self,0))
# Clear Quotation Details
# -----------------------
def clear_quotation_details(self):
self.doc.clear_table(self.doclist, 'quotation_details')
# QUOTATION DETAILS TRIGGER FUNCTIONS
# ================================================================================
# Get Item Details
# -----------------
def get_item_details(self, item_code):
return get_obj('Sales Common').get_item_details(item_code, self)
# Re-calculates Basic Rate & amount based on Price List Selected
# --------------------------------------------------------------
def get_adj_percent(self, arg=''):
get_obj('Sales Common').get_adj_percent(self)
# OTHER CHARGES TRIGGER FUNCTIONS
# ====================================================================================
# Get Tax rate if account type is TAX
# -----------------------------------
def get_rate(self,arg):
return get_obj('Sales Common').get_rate(arg)
# Load Default Charges
# ----------------------------------------------------------
def load_default_taxes(self):
return get_obj('Sales Common').load_default_taxes(self)
# Pull details from other charges master (Get Other Charges)
# ----------------------------------------------------------
def get_other_charges(self):
return get_obj('Sales Common').get_other_charges(self)
# Get Lead Details along with its details
# ==============================================================
def get_lead_details1(self, name):
details = sql("select name, lead_name, address_line1, address_line2, city, country, state, pincode, territory, contact_no, mobile_no, email_id from `tabLead` where name = '%s'" %(name), as_dict = 1)
ret = {
'lead_name' : details and details[0]['lead_name'] or '',
'address_display' : (details and details[0]['address_line1']
+ (details[0]['address_line2'] and '\n' + details[0]['address_line2'] or '') + '\n'
+ details[0]['city']
+ (details[0]['pincode'] and ', ' + details[0]['pincode'] or '') + '\n'
+ (details[0]['state'] and details[0]['state']+', ' or '')
+ details[0]['country'] + '\nTel: ' + details[0]['contact_no'] + '\n' or '-'),
'territory' : details and details[0]['territory'] or '',
'contact_mobile' : details and details[0]['mobile_no'] or '-',
'contact_email' : details and details[0]['email_id'] or '-'
}
return cstr(ret)
# GET TERMS AND CONDITIONS
# ====================================================================================
def get_tc_details(self):
return get_obj('Sales Common').get_tc_details(self)
# VALIDATE
# ==============================================================================================
# Amendment date is necessary if document is amended
# --------------------------------------------------
def validate_mandatory(self):
if self.doc.amended_from and not self.doc.amendment_date:
msgprint("Please Enter Amendment Date")
raise Exception
# Fiscal Year Validation
# ----------------------
def validate_fiscal_year(self):
get_obj('Sales Common').validate_fiscal_year(self.doc.fiscal_year,self.doc.transaction_date,'Quotation Date')
# Does not allow same item code to be entered twice
# -------------------------------------------------
def validate_for_items(self):
check_list=[]
chk_dupl_itm = []
for d in getlist(self.doclist,'quotation_details'):
ch = sql("select is_stock_item from `tabItem` where name = '%s'"%d.item_code)
if ch and ch[0][0]=='Yes':
if cstr(d.item_code) in check_list:
msgprint("Item %s has been entered twice." % d.item_code)
raise Exception
else:
check_list.append(cstr(d.item_code))
if ch and ch[0][0]=='No':
f = [cstr(d.item_code),cstr(d.description)]
if f in chk_dupl_itm:
msgprint("Item %s has been entered twice." % d.item_code)
raise Exception
else:
chk_dupl_itm.append(f)
#do not allow sales item in maintenance quotation and service item in sales quotation
#-----------------------------------------------------------------------------------------------
def validate_order_type(self):
if self.doc.order_type == 'Maintenance':
for d in getlist(self.doclist, 'quotation_details'):
is_service_item = sql("select is_service_item from `tabItem` where name=%s", d.item_code)
is_service_item = is_service_item and is_service_item[0][0] or 'No'
if is_service_item == 'No':
msgprint("You can not select non service item "+d.item_code+" in Maintenance Quotation")
raise Exception
else:
for d in getlist(self.doclist, 'quotation_details'):
is_sales_item = sql("select is_sales_item from `tabItem` where name=%s", d.item_code)
is_sales_item = is_sales_item and is_sales_item[0][0] or 'No'
if is_sales_item == 'No':
msgprint("You can not select non sales item "+d.item_code+" in Sales Quotation")
raise Exception
#--------------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)
# Validate
# --------
def validate(self):
self.validate_fiscal_year()
self.validate_mandatory()
self.set_last_contact_date()
self.validate_order_type()
self.validate_for_items()
sales_com_obj = get_obj('Sales Common')
sales_com_obj.check_active_sales_items(self)
sales_com_obj.validate_max_discount(self,'quotation_details') #verify whether rate is not greater than max_discount
sales_com_obj.check_conversion_rate(self)
# Get total in words
dcc = TransactionBase().get_company_currency(self.doc.company)
self.doc.in_words = sales_com_obj.get_total_in_words(dcc, self.doc.rounded_total)
self.doc.in_words_export = sales_com_obj.get_total_in_words(self.doc.currency, self.doc.rounded_total_export)
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 Quotation Status
set(self.doc, 'status', 'Draft')
# subject for follow
self.doc.subject = '[%(status)s] To %(customer)s worth %(currency)s %(grand_total)s' % self.doc.fields
# 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)
#update enquiry
#------------------
def update_enquiry(self, flag):
prevdoc=''
for d in getlist(self.doclist, 'quotation_details'):
if d.prevdoc_docname:
prevdoc = d.prevdoc_docname
if prevdoc:
if flag == 'submit': #on submit
sql("update `tabEnquiry` set status = 'Quotation Sent' where name = %s", prevdoc)
elif flag == 'cancel': #on cancel
sql("update `tabEnquiry` set status = 'Open' where name = %s", prevdoc)
elif flag == 'order lost': #order lost
sql("update `tabEnquiry` set status = 'Enquiry Lost' where name=%s", prevdoc)
elif flag == 'order confirm': #order confirm
sql("update `tabEnquiry` set status='Order Confirmed' where name=%s", prevdoc)
# declare as order lost
#-------------------------
def declare_order_lost(self,arg):
chk = sql("select t1.name from `tabSales Order` t1, `tabSales Order Detail` t2 where t2.parent = t1.name and t1.docstatus=1 and t2.prevdoc_docname = %s",self.doc.name)
if chk:
msgprint("Sales Order No. "+cstr(chk[0][0])+" is submitted against this Quotation. Thus 'Order Lost' can not be declared against it.")
raise Exception
else:
set(self.doc, 'status', 'Order Lost')
set(self.doc, 'order_lost_reason', arg)
self.update_enquiry('order lost')
return cstr('true')
#check if value entered in item table
#--------------------------------------
def check_item_table(self):
if not getlist(self.doclist, 'quotation_details'):
msgprint("Please enter item details")
raise Exception
# ON SUBMIT
# =========================================================================
def on_submit(self):
self.check_item_table()
if not self.doc.amended_from:
set(self.doc, 'message', 'Quotation: '+self.doc.name+' has been sent')
else:
set(self.doc, 'message', 'Quotation has been amended. New Quotation no:'+self.doc.name)
# Check for Approving Authority
get_obj('Authorization Control').validate_approving_authority(self.doc.doctype, self.doc.company, self.doc.grand_total, self)
# Set Quotation Status
set(self.doc, 'status', 'Submitted')
#update enquiry status
self.update_enquiry('submit')
# on submit notification
self.notify_obj.notify_contact('Quotation', self.doc.doctype, self.doc.name, self.doc.email_id, self.doc.contact_person)
# ON CANCEL
# ==========================================================================
def on_cancel(self):
set(self.doc, 'message', 'Quotation: '+self.doc.name+' has been cancelled')
#update enquiry status
self.update_enquiry('cancel')
set(self.doc,'status','Cancelled')
# SEND SMS
# =============================================================================
def send_sms(self):
if not self.doc.customer_mobile_no:
msgprint("Please enter customer mobile no")
elif not self.doc.message:
msgprint("Please enter the message you want to send")
else:
msgprint(get_obj("SMS Control", "SMS Control").send_sms([self.doc.contact_mobile,], self.doc.message))
# Print other charges
# ===========================================================================
def print_other_charges(self,docname):
print_lst = []
for d in getlist(self.doclist,'other_charges'):
lst1 = []
lst1.append(d.description)
lst1.append(d.total)
print_lst.append(lst1)
return print_lst
def update_followup_details(self):
sql("delete from `tabFollow up` where parent = '%s'"%self.doc.name)
for d in getlist(self.doclist, 'follow_up'):
d.save()

File diff suppressed because it is too large Load Diff