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(frm.doc.customer) {
args = {
args = {
party: frm.doc.customer,
party_type: "Customer",
price_list: frm.doc.selling_price_list
};
} else {
args = {
} else if(frm.doc.supplier) {
args = {
party: frm.doc.supplier,
party_type: "Supplier",
price_list: frm.doc.buying_price_list
};
}
}
if(!args) return;
args.currency = frm.doc.currency;
args.company = frm.doc.company;
frappe.call({
@ -44,7 +46,7 @@ erpnext.utils.get_address_display = function(frm, address_field, display_field)
} else if(frm.doc.supplier) {
address_field = "supplier_address";
} else return;
}
}
if(!display_field) display_field = "address_display";
if(frm.doc[address_field]) {
frappe.call({
@ -60,7 +62,7 @@ erpnext.utils.get_address_display = function(frm, address_field, display_field)
erpnext.utils.get_contact_details = function(frm) {
if(frm.updating_party_details) return;
if(frm.doc["contact_person"]) {
frappe.call({
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()
def make_opportunity(source_name, target_doc=None):
doclist = get_mapped_doc("Lead", source_name,
target_doc = get_mapped_doc("Lead", source_name,
{"Lead": {
"doctype": "Opportunity",
"field_map": {
@ -115,7 +115,7 @@ def make_opportunity(source_name, target_doc=None):
}
}}, target_doc)
return doclist
return target_doc
@frappe.whitelist()
def get_lead_details(lead):

View File

@ -1,7 +1,7 @@
{
"allow_import": 1,
"autoname": "naming_series:",
"creation": "2013-03-07 18:50:30.000000",
"creation": "2013-03-07 18:50:30",
"description": "Potential Sales Deal",
"docstatus": 0,
"doctype": "DocType",
@ -71,6 +71,15 @@
"print_hide": 1,
"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",
"fieldtype": "Column Break",
@ -79,6 +88,17 @@
"read_only": 0,
"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",
"fieldname": "status",
@ -93,17 +113,6 @@
"read_only": 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",
"fieldtype": "Section Break",
@ -211,15 +220,6 @@
"permlevel": 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",
"fieldname": "contact_person",
@ -409,7 +409,7 @@
"icon": "icon-info-sign",
"idx": 1,
"is_submittable": 1,
"modified": "2014-01-20 17:48:59.000000",
"modified": "2014-04-23 06:38:48.858871",
"modified_by": "Administrator",
"module": "Selling",
"name": "Opportunity",

View File

@ -24,19 +24,19 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
},
refresh: function(doc, dt, dn) {
this._super(doc, dt, dn);
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']);
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.appframe.add_button(__('Send SMS'), cur_frm.cscript.send_sms, "icon-mobile-phone");
}
if (this.frm.doc.docstatus===0) {
cur_frm.add_custom_button(__('From Opportunity'),
cur_frm.add_custom_button(__('From Opportunity'),
function() {
frappe.model.map_current_doc({
method: "erpnext.selling.doctype.opportunity.opportunity.make_quotation",
@ -61,33 +61,41 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
recipients: doc.contact_email
});
}
this.quotation_to();
this.toggle_reqd_lead_customer();
},
quotation_to: 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");
if (this.frm.doc.quotation_to == "Lead") {
this.frm.set_value("customer", null);
this.frm.set_value("contact_person", null);
// 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")
} else if (this.frm.doc.quotation_to == "Customer") {
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() {
this.get_terms();
},
validate_company_and_party: function(party_field) {
if(!this.frm.doc.quotation_to) {
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);
}
},
lead: function() {
var me = this;
frappe.call({
@ -110,7 +118,7 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
me.frm.set_value(r.message);
me.frm.refresh();
me.frm.updating_party_details = false;
}
}
})
@ -159,7 +167,7 @@ cur_frm.cscript['Declare Order Lost'] = function(){
})
});
dialog.show();
}
cur_frm.cscript.on_submit = function(doc, cdt, cdn) {

View File

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

View File

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