From 7c1976950d383b46b67c58f72235034bd9d02bf2 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Tue, 28 Jan 2014 13:03:47 +0530 Subject: [PATCH 1/4] webnotes/erpnext#912 stay updated button fixed in website --- portal/templates/includes/footer.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/portal/templates/includes/footer.html b/portal/templates/includes/footer.html index cd75fd16f6..da58ed04a5 100644 --- a/portal/templates/includes/footer.html +++ b/portal/templates/includes/footer.html @@ -16,11 +16,10 @@ {% endblock %} From f7f20f624a05d94e43ad830f98878f6259a11c48 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Wed, 29 Jan 2014 20:13:43 +0530 Subject: [PATCH 2/4] shipping address in quotation fixed for customer validation --- public/js/queries.js | 30 +++++++++------ selling/doctype/opportunity/opportunity.js | 43 ++++++++++------------ selling/doctype/quotation/quotation.js | 22 +++++++++-- selling/doctype/quotation/quotation.py | 4 -- selling/doctype/quotation/quotation.txt | 3 +- utilities/doctype/address/address.py | 6 +-- 6 files changed, 61 insertions(+), 47 deletions(-) diff --git a/public/js/queries.js b/public/js/queries.js index 3c60a9149a..6fa9ef5bc0 100644 --- a/public/js/queries.js +++ b/public/js/queries.js @@ -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" } }; }, - }); \ No newline at end of file diff --git a/selling/doctype/opportunity/opportunity.js b/selling/doctype/opportunity/opportunity.js index 05970fc350..cc093d2f35 100644 --- a/selling/doctype/opportunity/opportunity.js +++ b/selling/doctype/opportunity/opportunity.js @@ -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(); - } \ No newline at end of file diff --git a/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js index c7bf44718f..c92328e1bb 100644 --- a/selling/doctype/quotation/quotation.js +++ b/selling/doctype/quotation/quotation.js @@ -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", "contact_person"], + 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); - } } \ No newline at end of file diff --git a/selling/doctype/quotation/quotation.py b/selling/doctype/quotation/quotation.py index f2546b9cfa..7a68cce1d4 100644 --- a/selling/doctype/quotation/quotation.py +++ b/selling/doctype/quotation/quotation.py @@ -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): diff --git a/selling/doctype/quotation/quotation.txt b/selling/doctype/quotation/quotation.txt index 93346d3029..2bb1c205fe 100644 --- a/selling/doctype/quotation/quotation.txt +++ b/selling/doctype/quotation/quotation.txt @@ -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", diff --git a/utilities/doctype/address/address.py b/utilities/doctype/address/address.py index ad6e049b75..e371b515f8 100644 --- a/utilities/doctype/address/address.py +++ b/utilities/doctype/address/address.py @@ -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() From ef0a0e8209411ca614ad6f044e5be1d2f0eab07d Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Wed, 29 Jan 2014 20:18:43 +0530 Subject: [PATCH 3/4] stashed footer page --- portal/templates/includes/footer.html | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/portal/templates/includes/footer.html b/portal/templates/includes/footer.html index da58ed04a5..cd75fd16f6 100644 --- a/portal/templates/includes/footer.html +++ b/portal/templates/includes/footer.html @@ -16,10 +16,11 @@ {% endblock %} From 30aac9bbcff68c50f3b262dee5891a734b502b5b Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Thu, 30 Jan 2014 11:02:06 +0530 Subject: [PATCH 4/4] removed contact person for lead filter --- selling/doctype/quotation/quotation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selling/doctype/quotation/quotation.js b/selling/doctype/quotation/quotation.js index c92328e1bb..c8c919e86c 100644 --- a/selling/doctype/quotation/quotation.js +++ b/selling/doctype/quotation/quotation.js @@ -24,7 +24,7 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({ // to overwrite the customer_filter trigger from queries.js if (doc.lead) { - $.each(["customer_address", "shipping_address_name", "contact_person"], + $.each(["customer_address", "shipping_address_name"], function(i, opts) { me.frm.set_query(opts, erpnext.queries["lead_filter"]); }