Merge pull request #1370 from akhileshdarjee/hotfix

Shipping address in quotation fixed for customer validation
This commit is contained in:
Nabin Hait 2014-01-29 21:50:49 -08:00
commit 7e676f3aae
6 changed files with 61 additions and 47 deletions

View File

@ -54,8 +54,16 @@ $.extend(erpnext.queries, {
return { filters: { supplier: doc.supplier } }; return { filters: { supplier: doc.supplier } };
}, },
lead_filter: function(doc) {
if(!doc.lead) {
wn.throw(wn._("Please specify a") + " " +
wn._(wn.meta.get_label(doc.doctype, "lead", doc.name)));
}
return { filters: { lead: doc.lead } };
},
not_a_group_filter: function() { not_a_group_filter: function() {
return { filters: { is_group: "No" } }; return { filters: { is_group: "No" } };
}, },
}); });

View File

@ -105,9 +105,9 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn){
if(doc.docstatus === 1 && doc.status!=="Lost") { if(doc.docstatus === 1 && doc.status!=="Lost") {
cur_frm.add_custom_button(wn._('Create Quotation'), cur_frm.cscript.create_quotation); cur_frm.add_custom_button(wn._('Create Quotation'), cur_frm.cscript.create_quotation);
if(doc.status!=="Quotation") { if(doc.status!=="Quotation")
cur_frm.add_custom_button(wn._('Opportunity Lost'), cur_frm.cscript['Declare Opportunity Lost']); cur_frm.add_custom_button(wn._('Opportunity Lost'), cur_frm.cscript['Declare Opportunity Lost']);
}
cur_frm.add_custom_button(wn._('Send SMS'), cur_frm.cscript.send_sms, "icon-mobile-phone"); cur_frm.add_custom_button(wn._('Send SMS'), cur_frm.cscript.send_sms, "icon-mobile-phone");
} }
@ -116,17 +116,15 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn){
} }
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) { cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
if(doc.enquiry_from == 'Lead' && doc.lead) { if(doc.enquiry_from == 'Lead' && doc.lead)
cur_frm.cscript.lead(doc, cdt, cdn); cur_frm.cscript.lead(doc, cdt, cdn);
} }
}
cur_frm.cscript.item_code = function(doc, cdt, cdn) { cur_frm.cscript.item_code = function(doc, cdt, cdn) {
var d = locals[cdt][cdn]; var d = locals[cdt][cdn];
if (d.item_code) { if (d.item_code)
return get_server_fields('get_item_details', d.item_code, 'enquiry_details', doc, cdt, cdn, 1); return get_server_fields('get_item_details', d.item_code, 'enquiry_details', doc, cdt, cdn, 1);
} }
}
// hide - unhide fields on basis of enquiry_from lead or customer // hide - unhide fields on basis of enquiry_from lead or customer
cur_frm.cscript.enquiry_from = function(doc, cdt, cdn) { cur_frm.cscript.enquiry_from = function(doc, cdt, cdn) {
@ -164,14 +162,12 @@ cur_frm.cscript.lead = function(doc, cdt, cdn) {
wn.model.map_current_doc({ wn.model.map_current_doc({
method: "selling.doctype.lead.lead.make_opportunity", method: "selling.doctype.lead.lead.make_opportunity",
source_name: cur_frm.doc.lead source_name: cur_frm.doc.lead
}) });
unhide_field(['customer_name', 'address_display','contact_mobile', 'customer_address', unhide_field(['customer_name', 'address_display','contact_mobile', 'customer_address',
'contact_email', 'territory']); 'contact_email', 'territory']);
} }
cur_frm.cscript['Declare Opportunity Lost'] = function() { cur_frm.cscript['Declare Opportunity Lost'] = function() {
var dialog = new wn.ui.Dialog({ var dialog = new wn.ui.Dialog({
title: wn._("Set as Lost"), title: wn._("Set as Lost"),
@ -200,5 +196,4 @@ cur_frm.cscript['Declare Opportunity Lost'] = function(){
}) })
}); });
dialog.show(); dialog.show();
} }

View File

@ -15,12 +15,21 @@ wn.require('app/accounts/doctype/sales_invoice/pos.js');
erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
onload: function(doc, dt, dn) { onload: function(doc, dt, dn) {
var me = this;
this._super(doc, dt, dn); this._super(doc, dt, dn);
if(doc.customer && !doc.quotation_to) if(doc.customer && !doc.quotation_to)
doc.quotation_to = "Customer"; doc.quotation_to = "Customer";
else if(doc.lead && !doc.quotation_to) else if(doc.lead && !doc.quotation_to)
doc.quotation_to = "Lead"; doc.quotation_to = "Lead";
// to overwrite the customer_filter trigger from queries.js
if (doc.lead) {
$.each(["customer_address", "shipping_address_name"],
function(i, opts) {
me.frm.set_query(opts, erpnext.queries["lead_filter"]);
}
);
}
}, },
refresh: function(doc, dt, dn) { refresh: function(doc, dt, dn) {
this._super(doc, dt, dn); this._super(doc, dt, dn);
@ -68,6 +77,12 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
quotation_to: function() { quotation_to: function() {
this.frm.toggle_reqd("lead", this.frm.doc.quotation_to == "Lead"); this.frm.toggle_reqd("lead", this.frm.doc.quotation_to == "Lead");
this.frm.toggle_reqd("customer", this.frm.doc.quotation_to == "Customer"); this.frm.toggle_reqd("customer", this.frm.doc.quotation_to == "Customer");
if (this.frm.doc.quotation_to == "Lead") {
this.frm.set_value("customer", null);
this.frm.set_value("contact_person", null);
}
else if (this.frm.doc.quotation_to == "Customer")
this.frm.set_value("lead", null);
}, },
tc_name: function() { tc_name: function() {
@ -152,7 +167,6 @@ cur_frm.cscript['Declare Order Lost'] = function(){
} }
cur_frm.cscript.on_submit = function(doc, cdt, cdn) { cur_frm.cscript.on_submit = function(doc, cdt, cdn) {
if(cint(wn.boot.notification_settings.quotation)) { if(cint(wn.boot.notification_settings.quotation))
cur_frm.email_doc(wn.boot.notification_settings.quotation_message); cur_frm.email_doc(wn.boot.notification_settings.quotation_message);
} }
}

View File

@ -3,14 +3,10 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes import webnotes
from webnotes.utils import cstr from webnotes.utils import cstr
from webnotes.model.bean import getlist from webnotes.model.bean import getlist
from webnotes.model.code import get_obj from webnotes.model.code import get_obj
from webnotes import _, msgprint from webnotes import _, msgprint
from controllers.selling_controller import SellingController from controllers.selling_controller import SellingController
class DocType(SellingController): class DocType(SellingController):

View File

@ -2,7 +2,7 @@
{ {
"creation": "2013-05-24 19:29:08", "creation": "2013-05-24 19:29:08",
"docstatus": 0, "docstatus": 0,
"modified": "2013-12-14 17:25:46", "modified": "2014-01-29 19:42:32",
"modified_by": "Administrator", "modified_by": "Administrator",
"owner": "Administrator" "owner": "Administrator"
}, },
@ -665,6 +665,7 @@
"read_only": 0 "read_only": 0
}, },
{ {
"depends_on": "eval:doc.customer",
"doctype": "DocField", "doctype": "DocField",
"fieldname": "contact_person", "fieldname": "contact_person",
"fieldtype": "Link", "fieldtype": "Link",

View File

@ -4,7 +4,7 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import webnotes import webnotes
from webnotes import msgprint from webnotes import msgprint, throw, _
from webnotes.utils import cstr, cint from webnotes.utils import cstr, cint
class DocType: class DocType:
@ -20,7 +20,7 @@ class DocType:
if self.doc.address_title: if self.doc.address_title:
self.doc.name = cstr(self.doc.address_title).strip() + "-" + cstr(self.doc.address_type).strip() self.doc.name = cstr(self.doc.address_title).strip() + "-" + cstr(self.doc.address_type).strip()
else: else:
webnotes.msgprint("""Address Title is mandatory.""" + self.doc.customer, raise_exception=True) throw(_("Address Title is mandatory."))
def validate(self): def validate(self):
self.validate_primary_address() self.validate_primary_address()