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

@ -7,35 +7,35 @@ $.extend(erpnext.queries, {
profile: function() {
return { query: "core.doctype.profile.profile.profile_query" };
},
lead: function() {
return { query: "controllers.queries.lead_query" };
},
customer: function() {
return { query: "controllers.queries.customer_query" };
},
supplier: function() {
return { query: "controllers.queries.supplier_query" };
},
account: function() {
return { query: "controllers.queries.account_query" };
},
item: function() {
return { query: "controllers.queries.item_query" };
},
bom: function() {
return { query: "controllers.queries.bom" };
},
task: function() {
return { query: "projects.utils.query_task" };
},
customer_filter: function(doc) {
if(!doc.customer) {
wn.throw(wn._("Please specify a") + " " +
@ -44,7 +44,7 @@ $.extend(erpnext.queries, {
return { filters: { customer: doc.customer } };
},
supplier_filter: function(doc) {
if(!doc.supplier) {
wn.throw(wn._("Please specify a") + " " +
@ -53,9 +53,17 @@ $.extend(erpnext.queries, {
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() {
return { filters: { is_group: "No" } };
},
});

View File

@ -15,13 +15,13 @@ erpnext.selling.Opportunity = wn.ui.form.Controller.extend({
if(!this.frm.doc.enquiry_from)
hide_field(['customer', 'customer_address', 'contact_person', 'customer_name','lead', 'address_display', 'contact_display', 'contact_mobile', 'contact_email', 'territory', 'customer_group']);
if(!this.frm.doc.status)
set_multiple(cdt,cdn,{status:'Draft'});
set_multiple(cdt, cdn, { status:'Draft' });
if(!this.frm.doc.date)
this.frm.doc.transaction_date = date.obj_to_str(new Date());
if(!this.frm.doc.company && wn.defaults.get_default("company"))
set_multiple(cdt,cdn,{company:wn.defaults.get_default("company")});
if(!this.frm.doc.fiscal_year && sys_defaults.fiscal_year)
set_multiple(cdt,cdn,{fiscal_year:sys_defaults.fiscal_year});
set_multiple(cdt, cdn, { company:wn.defaults.get_default("company") });
if(!this.frm.doc.fiscal_year && sys_defaults.fiscal_year)
set_multiple(cdt, cdn, { fiscal_year:sys_defaults.fiscal_year });
if(this.frm.doc.enquiry_from) {
if(this.frm.doc.enquiry_from == 'Customer') {
@ -99,15 +99,15 @@ erpnext.selling.Opportunity = wn.ui.form.Controller.extend({
$.extend(cur_frm.cscript, new erpnext.selling.Opportunity({frm: cur_frm}));
cur_frm.cscript.refresh = function(doc, cdt, cdn){
cur_frm.cscript.refresh = function(doc, cdt, cdn) {
erpnext.hide_naming_series();
cur_frm.clear_custom_buttons();
if(doc.docstatus === 1 && doc.status!=="Lost") {
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._('Send SMS'), cur_frm.cscript.send_sms, "icon-mobile-phone");
}
@ -116,31 +116,29 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn){
}
cur_frm.cscript.onload_post_render = function(doc, cdt, cdn) {
if(doc.enquiry_from == 'Lead' && doc.lead) {
cur_frm.cscript.lead(doc,cdt,cdn);
}
if(doc.enquiry_from == 'Lead' && doc.lead)
cur_frm.cscript.lead(doc, cdt, cdn);
}
cur_frm.cscript.item_code = function(doc, cdt, cdn) {
var d = locals[cdt][cdn];
if (d.item_code) {
return get_server_fields('get_item_details',d.item_code, 'enquiry_details',doc, cdt,cdn,1);
}
if (d.item_code)
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
cur_frm.cscript.enquiry_from = function(doc,cdt,cdn){
cur_frm.cscript.lead_cust_show(doc,cdt,cdn);
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'){
cur_frm.cscript.lead_cust_show = function(doc, cdt, cdn) {
if(doc.enquiry_from == 'Lead') {
unhide_field(['lead']);
hide_field(['customer','customer_address','contact_person','customer_name','address_display','contact_display','contact_mobile','contact_email','territory','customer_group']);
doc.lead = 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'){
else if(doc.enquiry_from == 'Customer') {
unhide_field(['customer']);
hide_field(['lead', 'address_display', 'contact_display', 'contact_mobile',
'contact_email', 'territory', 'customer_group']);
@ -164,15 +162,13 @@ cur_frm.cscript.lead = function(doc, cdt, cdn) {
wn.model.map_current_doc({
method: "selling.doctype.lead.lead.make_opportunity",
source_name: cur_frm.doc.lead
})
});
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({
title: wn._("Set as Lost"),
fields: [
@ -200,5 +196,4 @@ cur_frm.cscript['Declare Opportunity Lost'] = function(){
})
});
dialog.show();
}

View File

@ -15,12 +15,21 @@ wn.require('app/accounts/doctype/sales_invoice/pos.js');
erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
onload: function(doc, dt, dn) {
var me = this;
this._super(doc, dt, dn);
if(doc.customer && !doc.quotation_to)
doc.quotation_to = "Customer";
else if(doc.lead && !doc.quotation_to)
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) {
this._super(doc, dt, dn);
@ -68,6 +77,12 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
quotation_to: function() {
this.frm.toggle_reqd("lead", this.frm.doc.quotation_to == "Lead");
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() {
@ -89,7 +104,7 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
cur_frm.script_manager.make(erpnext.selling.QuotationController);
cur_frm.fields_dict.lead.get_query = function(doc,cdt,cdn) {
cur_frm.fields_dict.lead.get_query = function(doc, cdt, cdn) {
return{ query:"controllers.queries.lead_query" } }
cur_frm.cscript.lead = function(doc, cdt, cdn) {
@ -152,7 +167,6 @@ cur_frm.cscript['Declare Order Lost'] = function(){
}
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);
}
}

View File

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

View File

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

View File

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