Fixes in Lead, Opportunity, Quotation, Setup Wizard

This commit is contained in:
Anand Doshi 2014-04-23 19:15:15 +05:30
parent f50a65294f
commit 78eeacb53c
6 changed files with 66 additions and 59 deletions

View File

@ -8,19 +8,21 @@ erpnext.utils.get_party_details = function(frm, method, args) {
} }
if(!args) { if(!args) {
if(frm.doc.customer) { if(frm.doc.customer) {
args = { args = {
party: frm.doc.customer, party: frm.doc.customer,
party_type: "Customer", party_type: "Customer",
price_list: frm.doc.selling_price_list price_list: frm.doc.selling_price_list
}; };
} else { } else if(frm.doc.supplier) {
args = { args = {
party: frm.doc.supplier, party: frm.doc.supplier,
party_type: "Supplier", party_type: "Supplier",
price_list: frm.doc.buying_price_list price_list: frm.doc.buying_price_list
}; };
} }
} }
if(!args) return;
args.currency = frm.doc.currency; args.currency = frm.doc.currency;
args.company = frm.doc.company; args.company = frm.doc.company;
frappe.call({ frappe.call({
@ -44,7 +46,7 @@ erpnext.utils.get_address_display = function(frm, address_field, display_field)
} else if(frm.doc.supplier) { } else if(frm.doc.supplier) {
address_field = "supplier_address"; address_field = "supplier_address";
} else return; } else return;
} }
if(!display_field) display_field = "address_display"; if(!display_field) display_field = "address_display";
if(frm.doc[address_field]) { if(frm.doc[address_field]) {
frappe.call({ frappe.call({
@ -60,7 +62,7 @@ erpnext.utils.get_address_display = function(frm, address_field, display_field)
erpnext.utils.get_contact_details = function(frm) { erpnext.utils.get_contact_details = function(frm) {
if(frm.updating_party_details) return; if(frm.updating_party_details) return;
if(frm.doc["contact_person"]) { if(frm.doc["contact_person"]) {
frappe.call({ frappe.call({
method: "erpnext.utilities.doctype.contact.contact.get_contact_details", method: "erpnext.utilities.doctype.contact.contact.get_contact_details",
@ -71,4 +73,4 @@ erpnext.utils.get_contact_details = function(frm) {
} }
}) })
} }
} }

View File

@ -101,7 +101,7 @@ def _make_customer(source_name, target_doc=None, ignore_permissions=False):
@frappe.whitelist() @frappe.whitelist()
def make_opportunity(source_name, target_doc=None): def make_opportunity(source_name, target_doc=None):
doclist = get_mapped_doc("Lead", source_name, target_doc = get_mapped_doc("Lead", source_name,
{"Lead": { {"Lead": {
"doctype": "Opportunity", "doctype": "Opportunity",
"field_map": { "field_map": {
@ -115,7 +115,7 @@ def make_opportunity(source_name, target_doc=None):
} }
}}, target_doc) }}, target_doc)
return doclist return target_doc
@frappe.whitelist() @frappe.whitelist()
def get_lead_details(lead): def get_lead_details(lead):

View File

@ -1,7 +1,7 @@
{ {
"allow_import": 1, "allow_import": 1,
"autoname": "naming_series:", "autoname": "naming_series:",
"creation": "2013-03-07 18:50:30.000000", "creation": "2013-03-07 18:50:30",
"description": "Potential Sales Deal", "description": "Potential Sales Deal",
"docstatus": 0, "docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
@ -71,6 +71,15 @@
"print_hide": 1, "print_hide": 1,
"read_only": 0 "read_only": 0
}, },
{
"depends_on": "eval:doc.customer || doc.lead",
"fieldname": "customer_name",
"fieldtype": "Data",
"label": "Customer / Lead Name",
"permlevel": 0,
"print_hide": 0,
"read_only": 1
},
{ {
"fieldname": "column_break0", "fieldname": "column_break0",
"fieldtype": "Column Break", "fieldtype": "Column Break",
@ -79,6 +88,17 @@
"read_only": 0, "read_only": 0,
"width": "50%" "width": "50%"
}, },
{
"fieldname": "enquiry_type",
"fieldtype": "Select",
"label": "Opportunity Type",
"oldfieldname": "enquiry_type",
"oldfieldtype": "Select",
"options": "\nSales\nMaintenance",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{ {
"default": "Draft", "default": "Draft",
"fieldname": "status", "fieldname": "status",
@ -93,17 +113,6 @@
"read_only": 1, "read_only": 1,
"reqd": 1 "reqd": 1
}, },
{
"fieldname": "enquiry_type",
"fieldtype": "Select",
"label": "Opportunity Type",
"oldfieldname": "enquiry_type",
"oldfieldtype": "Select",
"options": "\nSales\nMaintenance",
"permlevel": 0,
"read_only": 0,
"reqd": 1
},
{ {
"fieldname": "items", "fieldname": "items",
"fieldtype": "Section Break", "fieldtype": "Section Break",
@ -211,15 +220,6 @@
"permlevel": 0, "permlevel": 0,
"read_only": 0 "read_only": 0
}, },
{
"depends_on": "customer",
"fieldname": "customer_name",
"fieldtype": "Data",
"label": "Customer Name",
"permlevel": 0,
"print_hide": 0,
"read_only": 1
},
{ {
"depends_on": "eval:doc.lead || doc.customer", "depends_on": "eval:doc.lead || doc.customer",
"fieldname": "contact_person", "fieldname": "contact_person",
@ -409,7 +409,7 @@
"icon": "icon-info-sign", "icon": "icon-info-sign",
"idx": 1, "idx": 1,
"is_submittable": 1, "is_submittable": 1,
"modified": "2014-01-20 17:48:59.000000", "modified": "2014-04-23 06:38:48.858871",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Selling", "module": "Selling",
"name": "Opportunity", "name": "Opportunity",

View File

@ -24,19 +24,19 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
}, },
refresh: function(doc, dt, dn) { refresh: function(doc, dt, dn) {
this._super(doc, dt, dn); this._super(doc, dt, dn);
if(doc.docstatus == 1 && doc.status!=='Lost') { if(doc.docstatus == 1 && doc.status!=='Lost') {
cur_frm.add_custom_button(__('Make Sales Order'), cur_frm.add_custom_button(__('Make Sales Order'),
cur_frm.cscript['Make Sales Order']); cur_frm.cscript['Make Sales Order']);
if(doc.status!=="Ordered") { if(doc.status!=="Ordered") {
cur_frm.add_custom_button(__('Set as Lost'), cur_frm.add_custom_button(__('Set as Lost'),
cur_frm.cscript['Declare Order Lost'], "icon-exclamation"); cur_frm.cscript['Declare Order Lost'], "icon-exclamation");
} }
cur_frm.appframe.add_button(__('Send SMS'), cur_frm.cscript.send_sms, "icon-mobile-phone"); cur_frm.appframe.add_button(__('Send SMS'), cur_frm.cscript.send_sms, "icon-mobile-phone");
} }
if (this.frm.doc.docstatus===0) { if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(__('From Opportunity'), cur_frm.add_custom_button(__('From Opportunity'),
function() { function() {
frappe.model.map_current_doc({ frappe.model.map_current_doc({
method: "erpnext.selling.doctype.opportunity.opportunity.make_quotation", method: "erpnext.selling.doctype.opportunity.opportunity.make_quotation",
@ -61,33 +61,41 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
recipients: doc.contact_email recipients: doc.contact_email
}); });
} }
this.quotation_to(); this.toggle_reqd_lead_customer();
}, },
quotation_to: function() { quotation_to: function() {
var me = this; var me = this;
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") { if (this.frm.doc.quotation_to == "Lead") {
this.frm.set_value("customer", null); this.frm.set_value("customer", null);
this.frm.set_value("contact_person", null); this.frm.set_value("contact_person", null);
} else if (this.frm.doc.quotation_to == "Customer") {
// to overwrite the customer_filter trigger from queries.js
$.each(["customer_address", "shipping_address_name"],
function(i, opts) {
me.frm.set_query(opts, erpnext.queries["lead_filter"]);
}
);
}
else if (this.frm.doc.quotation_to == "Customer")
this.frm.set_value("lead", null); this.frm.set_value("lead", null);
}
this.toggle_reqd_lead_customer();
},
toggle_reqd_lead_customer: function() {
var me = this;
this.frm.toggle_reqd("lead", this.frm.doc.quotation_to == "Lead");
this.frm.toggle_reqd("customer", this.frm.doc.quotation_to == "Customer");
// to overwrite the customer_filter trigger from queries.js
$.each(["customer_address", "shipping_address_name"],
function(i, opts) {
me.frm.set_query(opts, me.frm.doc.quotation_to==="Lead"
? erpnext.queries["lead_filter"] : erpnext.queries["customer_filter"]);
}
);
}, },
tc_name: function() { tc_name: function() {
this.get_terms(); this.get_terms();
}, },
validate_company_and_party: function(party_field) { validate_company_and_party: function(party_field) {
if(!this.frm.doc.quotation_to) { if(!this.frm.doc.quotation_to) {
msgprint(__("Please select a value for {0} quotation_to {1}", [this.frm.doc.doctype, this.frm.doc.name])); msgprint(__("Please select a value for {0} quotation_to {1}", [this.frm.doc.doctype, this.frm.doc.name]));
@ -98,7 +106,7 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
return this._super(party_field); return this._super(party_field);
} }
}, },
lead: function() { lead: function() {
var me = this; var me = this;
frappe.call({ frappe.call({
@ -110,7 +118,7 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
me.frm.set_value(r.message); me.frm.set_value(r.message);
me.frm.refresh(); me.frm.refresh();
me.frm.updating_party_details = false; me.frm.updating_party_details = false;
} }
} }
}) })
@ -159,7 +167,7 @@ cur_frm.cscript['Declare Order Lost'] = function(){
}) })
}); });
dialog.show(); dialog.show();
} }
cur_frm.cscript.on_submit = function(doc, cdt, cdn) { cur_frm.cscript.on_submit = function(doc, cdt, cdn) {

View File

@ -2,7 +2,7 @@
"allow_attach": 1, "allow_attach": 1,
"allow_import": 1, "allow_import": 1,
"autoname": "naming_series:", "autoname": "naming_series:",
"creation": "2013-05-24 19:29:08.000000", "creation": "2013-05-24 19:29:08",
"docstatus": 0, "docstatus": 0,
"doctype": "DocType", "doctype": "DocType",
"document_type": "Transaction", "document_type": "Transaction",
@ -83,7 +83,7 @@
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 1, "hidden": 1,
"in_list_view": 1, "in_list_view": 1,
"label": "Customer Name", "label": "Customer / Lead Name",
"permlevel": 0, "permlevel": 0,
"read_only": 1 "read_only": 1
}, },
@ -818,7 +818,7 @@
"idx": 1, "idx": 1,
"is_submittable": 1, "is_submittable": 1,
"max_attachments": 1, "max_attachments": 1,
"modified": "2014-01-31 19:43:00.000000", "modified": "2014-04-23 06:16:59.176080",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Selling", "module": "Selling",
"name": "Quotation", "name": "Quotation",

View File

@ -204,9 +204,6 @@ def set_defaults(args):
email_settings.send_print_in_body_and_attachment = 1 email_settings.send_print_in_body_and_attachment = 1
email_settings.save() email_settings.save()
# default
frappe.db.set_default("company_name", args["company_name"])
def create_feed_and_todo(): def create_feed_and_todo():
"""update activty feed and create todo for creation of item, customer, vendor""" """update activty feed and create todo for creation of item, customer, vendor"""
from erpnext.home import make_feed from erpnext.home import make_feed