mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-27 00:44:45 +00:00
Delivery Note changes 1.Net Wt, Gross Wt at packing slip level
This commit is contained in:
@@ -11,7 +11,7 @@ $import(SMS Control)
|
||||
|
||||
// ONLOAD
|
||||
// ===================================================================================
|
||||
cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
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'});
|
||||
@@ -21,7 +21,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
//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']);
|
||||
@@ -34,7 +34,7 @@ cur_frm.cscript.onload = function(doc, cdt, cdn) {
|
||||
|
||||
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)
|
||||
if(doc.__islocal && !getchildren('RV Tax Detail', doc.name, 'other_charges', doc.doctype).length)
|
||||
cur_frm.cscript.load_taxes(doc, cdt, cdn);
|
||||
}
|
||||
|
||||
@@ -46,9 +46,9 @@ cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
|
||||
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'){
|
||||
else if(doc.quotation_to == 'Customer'){
|
||||
unhide_field(['customer']);
|
||||
hide_field(['lead','lead_name','address_display','contact_display','contact_mobile','contact_email','territory']);
|
||||
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']);
|
||||
@@ -56,7 +56,7 @@ cur_frm.cscript.lead_cust_show = function(doc,cdt,cdn){
|
||||
|
||||
|
||||
|
||||
//================ hide - unhide fields on basis of quotation to either lead or 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 = "";
|
||||
@@ -77,7 +77,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
||||
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);
|
||||
@@ -111,7 +111,7 @@ 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']);
|
||||
@@ -123,12 +123,12 @@ cur_frm.cscript.customer_address = cur_frm.cscript.contact_person = function(doc
|
||||
|
||||
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;
|
||||
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;
|
||||
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) {
|
||||
@@ -146,7 +146,7 @@ cur_frm.fields_dict['lead'].get_query = function(doc,cdt,cdn){
|
||||
|
||||
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']);
|
||||
if(doc.lead) unhide_field(['lead_name','address_display','contact_mobile','contact_email','territory']);
|
||||
}
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ cur_frm.fields_dict['enq_no'].get_query = function(doc,cdt,cdn){
|
||||
cur_frm.cscript['Make Sales Order'] = function() {
|
||||
var doc = cur_frm.doc;
|
||||
|
||||
if (doc.docstatus == 1) {
|
||||
if (doc.docstatus == 1) {
|
||||
var n = createLocal("Sales Order");
|
||||
$c('dt_map', args={
|
||||
'docs':compress_doclist([locals["Sales Order"][n]]),
|
||||
@@ -186,17 +186,17 @@ 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']);
|
||||
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);
|
||||
|
||||
}
|
||||
@@ -217,7 +217,7 @@ cur_frm.cscript['Update Follow up'] = function(doc){
|
||||
//-------------------------
|
||||
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([
|
||||
@@ -226,26 +226,26 @@ cur_frm.cscript['Declare Order Lost'] = function(){
|
||||
['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) {
|
||||
var call_back = function(r,rt) {
|
||||
if(r.message == 'true'){
|
||||
$i('update_quotation_dialog_response').innerHTML = 'Done';
|
||||
qtn_lost_dialog.hide();
|
||||
@@ -254,11 +254,11 @@ cur_frm.cscript['Declare Order Lost'] = function(){
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -284,23 +284,23 @@ cur_frm.fields_dict['territory'].get_query = function(doc,cdt,cdn) {
|
||||
|
||||
//===================== 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;
|
||||
alert("Lead is mandatory.");
|
||||
validated = false;
|
||||
}
|
||||
}
|
||||
else if(doc.quotation_to == 'Customer'){
|
||||
|
||||
|
||||
if(!doc.customer){
|
||||
alert("Customer is mandatory.");
|
||||
validated = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//===================validation function =================================
|
||||
@@ -308,3 +308,35 @@ cur_frm.cscript.quot_to_validate = function(doc,cdt,cdn){
|
||||
cur_frm.cscript.validate = function(doc,cdt,cdn){
|
||||
cur_frm.cscript.quot_to_validate(doc,cdt,cdn);
|
||||
}
|
||||
|
||||
//================ Last Quoted Price and Last Sold Price suggestion ======================
|
||||
cur_frm.fields_dict['quotation_details'].grid.get_field('item_code').get_query= function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
if(doc.customer)
|
||||
return repl("SELECT i.name,i.item_code,concat('Last quoted at - ',cast(quote_rate as char)) as quote_rate,concat('Last sold at - ',cast(sales_rate as char)) as sales_rate FROM\
|
||||
(\
|
||||
select item_code,name from tabItem where tabItem.%(key)s like '%s'\
|
||||
)i\
|
||||
left join\
|
||||
(\
|
||||
select q.item_code,q.quote_rate from\
|
||||
(\
|
||||
select q.transaction_date,qd.item_code,basic_rate as quote_rate from `tabQuotation Detail` qd, `tabQuotation` q where q.name=qd.parent and q.docstatus=1 and customer='%(cust)s'\
|
||||
)q,\
|
||||
(\
|
||||
select qd.item_code,max(transaction_date) as transaction_date from `tabQuotation Detail` qd, `tabQuotation` q where q.name=qd.parent and q.docstatus=1 and customer='%(cust)s' group by qd.item_code\
|
||||
)m where q.item_code=m.item_code and q.transaction_date=m.transaction_date\
|
||||
)q on i.item_code=q.item_code\
|
||||
left join\
|
||||
(\
|
||||
select r.item_code,r.sales_rate from\
|
||||
(\
|
||||
select r.voucher_date,rd.item_code,basic_rate as sales_rate from `tabRV Detail` rd, `tabReceivable Voucher` r where r.name=rd.parent and r.docstatus=1 and customer='%(cust)s'\
|
||||
)r,\
|
||||
(\
|
||||
select rd.item_code,max(voucher_date) as voucher_date from `tabRV Detail` rd, `tabReceivable Voucher` r where r.name=rd.parent and r.docstatus=1 and customer='%(cust)s' group by rd.item_code\
|
||||
)m where r.item_code=m.item_code and r.voucher_date=m.voucher_date\
|
||||
)s on i.item_code=s.item_code ORDER BY item_code LIMIT 50",{cust:doc.customer});
|
||||
else
|
||||
return "SELECT name, item_code FROM tabItem WHERE `tabItem`.%(key)s LIKE '%s' ORDER BY tabItem.item_code DESC LIMIT 50";
|
||||
}
|
||||
Reference in New Issue
Block a user