fix: Make Customer and lead field dynamic in quotations and opportunity (#17097)

fix: Make Customer and lead field dynamic in quotations and opportunity
This commit is contained in:
Faris Ansari
2019-04-28 20:46:39 +05:30
committed by GitHub
24 changed files with 337 additions and 259 deletions

View File

@@ -90,11 +90,11 @@ class Lead(SellingController):
return frappe.db.get_value("Customer", {"lead_name": self.name}) return frappe.db.get_value("Customer", {"lead_name": self.name})
def has_opportunity(self): def has_opportunity(self):
return frappe.db.get_value("Opportunity", {"lead": self.name, "status": ["!=", "Lost"]}) return frappe.db.get_value("Opportunity", {"party_name": self.name, "status": ["!=", "Lost"]})
def has_quotation(self): def has_quotation(self):
return frappe.db.get_value("Quotation", { return frappe.db.get_value("Quotation", {
"lead": self.name, "party_name": self.name,
"docstatus": 1, "docstatus": 1,
"status": ["!=", "Lost"] "status": ["!=", "Lost"]

View File

@@ -9,15 +9,22 @@ frappe.ui.form.on("Opportunity", {
frm.custom_make_buttons = { frm.custom_make_buttons = {
'Quotation': 'Quotation', 'Quotation': 'Quotation',
'Supplier Quotation': 'Supplier Quotation' 'Supplier Quotation': 'Supplier Quotation'
} },
},
customer: function(frm) { frm.set_query("opportunity_from", function() {
frm.trigger('set_contact_link'); return{
erpnext.utils.get_party_details(frm); "filters": {
"name": ["in", ["Customer", "Lead"]],
}
}
});
}, },
lead: function(frm) { party_name: function(frm) {
frm.trigger('set_contact_link'); if (frm.doc.opportunity_from == "Customer") {
frm.trigger('set_contact_link');
erpnext.utils.get_party_details(frm);
}
}, },
with_items: function(frm) { with_items: function(frm) {
@@ -30,15 +37,14 @@ frappe.ui.form.on("Opportunity", {
contact_person: erpnext.utils.get_contact_details, contact_person: erpnext.utils.get_contact_details,
enquiry_from: function(frm) { opportunity_from: function(frm) {
frm.toggle_reqd("lead", frm.doc.enquiry_from==="Lead"); frm.toggle_reqd("party_name", frm.doc.opportunity_from);
frm.toggle_reqd("customer", frm.doc.enquiry_from==="Customer"); frm.trigger("set_dynamic_field_label");
}, },
refresh: function(frm) { refresh: function(frm) {
var doc = frm.doc; var doc = frm.doc;
frm.events.enquiry_from(frm); frm.events.opportunity_from(frm);
frm.trigger('set_contact_link');
frm.trigger('toggle_mandatory'); frm.trigger('toggle_mandatory');
erpnext.toggle_naming_series(); erpnext.toggle_naming_series();
@@ -75,13 +81,20 @@ frappe.ui.form.on("Opportunity", {
}, },
set_contact_link: function(frm) { set_contact_link: function(frm) {
if(frm.doc.customer) { if(frm.doc.opportunity_from == "Customer" && frm.doc.party_name) {
frappe.dynamic_link = {doc: frm.doc, fieldname: 'customer', doctype: 'Customer'} frappe.dynamic_link = {doc: frm.doc, fieldname: 'customer', doctype: 'Customer'}
} else if(frm.doc.lead) { } else if(frm.doc.opportunity_from == "Lead" && frm.doc.party_name) {
frappe.dynamic_link = {doc: frm.doc, fieldname: 'lead', doctype: 'Lead'} frappe.dynamic_link = {doc: frm.doc, fieldname: 'lead', doctype: 'Lead'}
} }
}, },
set_dynamic_field_label: function(frm){
if (frm.doc.opportunity_from) {
frm.set_df_property("party_name", "label", frm.doc.opportunity_from);
}
},
make_supplier_quotation: function(frm) { make_supplier_quotation: function(frm) {
frappe.model.open_mapped_doc({ frappe.model.open_mapped_doc({
method: "erpnext.crm.doctype.opportunity.opportunity.make_supplier_quotation", method: "erpnext.crm.doctype.opportunity.opportunity.make_supplier_quotation",
@@ -97,10 +110,6 @@ frappe.ui.form.on("Opportunity", {
// TODO commonify this code // TODO commonify this code
erpnext.crm.Opportunity = frappe.ui.form.Controller.extend({ erpnext.crm.Opportunity = frappe.ui.form.Controller.extend({
onload: function() { onload: function() {
if(!this.frm.doc.enquiry_from && this.frm.doc.customer)
this.frm.doc.enquiry_from = "Customer";
if(!this.frm.doc.enquiry_from && this.frm.doc.lead)
this.frm.doc.enquiry_from = "Lead";
if(!this.frm.doc.status) if(!this.frm.doc.status)
set_multiple(this.frm.doc.doctype, this.frm.doc.name, { status:'Open' }); set_multiple(this.frm.doc.doctype, this.frm.doc.name, { status:'Open' });
@@ -148,7 +157,7 @@ erpnext.crm.Opportunity = frappe.ui.form.Controller.extend({
$.extend(cur_frm.cscript, new erpnext.crm.Opportunity({frm: cur_frm})); $.extend(cur_frm.cscript, new erpnext.crm.Opportunity({frm: cur_frm}));
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.opportunity_from == 'Lead' && doc.party_name)
cur_frm.cscript.lead(doc, cdt, cdn); cur_frm.cscript.lead(doc, cdt, cdn);
} }
@@ -171,10 +180,10 @@ cur_frm.cscript.item_code = function(doc, cdt, cdn) {
} }
cur_frm.cscript.lead = function(doc, cdt, cdn) { cur_frm.cscript.lead = function(doc, cdt, cdn) {
cur_frm.toggle_display("contact_info", doc.customer || doc.lead); cur_frm.toggle_display("contact_info", doc.party_name);
erpnext.utils.map_current_doc({ erpnext.utils.map_current_doc({
method: "erpnext.crm.doctype.lead.lead.make_opportunity", method: "erpnext.crm.doctype.lead.lead.make_opportunity",
source_name: cur_frm.doc.lead, source_name: cur_frm.doc.party_name,
frm: cur_frm frm: cur_frm
}); });
} }

View File

@@ -21,6 +21,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "from_section", "fieldname": "from_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -54,6 +55,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "", "default": "",
"fetch_if_empty": 0,
"fieldname": "naming_series", "fieldname": "naming_series",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 0, "hidden": 0,
@@ -88,8 +90,9 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fieldname": "enquiry_from", "fetch_if_empty": 0,
"fieldtype": "Select", "fieldname": "opportunity_from",
"fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
@@ -102,7 +105,7 @@
"no_copy": 0, "no_copy": 0,
"oldfieldname": "enquiry_from", "oldfieldname": "enquiry_from",
"oldfieldtype": "Select", "oldfieldtype": "Select",
"options": "\nLead\nCustomer", "options": "DocType",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
@@ -122,9 +125,10 @@
"bold": 1, "bold": 1,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.enquiry_from===\"Customer\"", "depends_on": "",
"fieldname": "customer", "fetch_if_empty": 0,
"fieldtype": "Link", "fieldname": "party_name",
"fieldtype": "Dynamic Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
@@ -132,54 +136,19 @@
"in_global_search": 0, "in_global_search": 0,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 1, "in_standard_filter": 1,
"label": "Customer", "label": "Customer/Lead",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"oldfieldname": "customer", "oldfieldname": "customer",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Customer", "options": "opportunity_from",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
"read_only": 0, "read_only": 0,
"remember_last_selected_value": 0, "remember_last_selected_value": 0,
"report_hide": 0, "report_hide": 0,
"reqd": 0, "reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.enquiry_from===\"Lead\"",
"fieldname": "lead",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 1,
"label": "Lead",
"length": 0,
"no_copy": 0,
"oldfieldname": "lead",
"oldfieldtype": "Link",
"options": "Lead",
"permlevel": 0,
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0, "search_index": 0,
"set_only_once": 0, "set_only_once": 0,
"translatable": 0, "translatable": 0,
@@ -193,6 +162,8 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "", "depends_on": "",
"fetch_from": "",
"fetch_if_empty": 0,
"fieldname": "customer_name", "fieldname": "customer_name",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
@@ -224,6 +195,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break0", "fieldname": "column_break0",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -256,6 +228,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "title", "fieldname": "title",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 1, "hidden": 1,
@@ -289,6 +262,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "Sales", "default": "Sales",
"fetch_if_empty": 0,
"fieldname": "opportunity_type", "fieldname": "opportunity_type",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -324,6 +298,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "Open", "default": "Open",
"fetch_if_empty": 0,
"fieldname": "status", "fieldname": "status",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 0, "hidden": 0,
@@ -359,6 +334,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.status===\"Lost\"", "depends_on": "eval:doc.status===\"Lost\"",
"fetch_if_empty": 0,
"fieldname": "order_lost_reason", "fieldname": "order_lost_reason",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"hidden": 0, "hidden": 0,
@@ -390,6 +366,7 @@
"bold": 1, "bold": 1,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "mins_to_first_response", "fieldname": "mins_to_first_response",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
@@ -423,6 +400,7 @@
"collapsible": 1, "collapsible": 1,
"collapsible_depends_on": "contact_by", "collapsible_depends_on": "contact_by",
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "next_contact", "fieldname": "next_contact",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -456,6 +434,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "", "description": "",
"fetch_if_empty": 0,
"fieldname": "contact_by", "fieldname": "contact_by",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -492,6 +471,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "", "description": "",
"fetch_if_empty": 0,
"fieldname": "contact_date", "fieldname": "contact_date",
"fieldtype": "Datetime", "fieldtype": "Datetime",
"hidden": 0, "hidden": 0,
@@ -525,6 +505,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break2", "fieldname": "column_break2",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -557,6 +538,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "to_discuss", "fieldname": "to_discuss",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"hidden": 0, "hidden": 0,
@@ -590,6 +572,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "section_break_14", "fieldname": "section_break_14",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -622,6 +605,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "currency", "fieldname": "currency",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -655,6 +639,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "opportunity_amount", "fieldname": "opportunity_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -687,6 +672,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "with_items", "fieldname": "with_items",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -719,6 +705,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_17", "fieldname": "column_break_17",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -751,6 +738,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "Prospecting", "default": "Prospecting",
"fetch_if_empty": 0,
"fieldname": "sales_stage", "fieldname": "sales_stage",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -785,6 +773,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "100", "default": "100",
"fetch_if_empty": 0,
"fieldname": "probability", "fieldname": "probability",
"fieldtype": "Percent", "fieldtype": "Percent",
"hidden": 0, "hidden": 0,
@@ -818,6 +807,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "with_items", "depends_on": "with_items",
"fetch_if_empty": 0,
"fieldname": "items_section", "fieldname": "items_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -852,6 +842,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "", "description": "",
"fetch_if_empty": 0,
"fieldname": "items", "fieldname": "items",
"fieldtype": "Table", "fieldtype": "Table",
"hidden": 0, "hidden": 0,
@@ -888,6 +879,7 @@
"collapsible_depends_on": "next_contact_by", "collapsible_depends_on": "next_contact_by",
"columns": 0, "columns": 0,
"depends_on": "eval:doc.lead || doc.customer", "depends_on": "eval:doc.lead || doc.customer",
"fetch_if_empty": 0,
"fieldname": "contact_info", "fieldname": "contact_info",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -921,6 +913,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.customer || doc.lead", "depends_on": "eval:doc.customer || doc.lead",
"fetch_if_empty": 0,
"fieldname": "customer_address", "fieldname": "customer_address",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -953,6 +946,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "address_display", "fieldname": "address_display",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"hidden": 1, "hidden": 1,
@@ -988,6 +982,7 @@
"columns": 0, "columns": 0,
"depends_on": "customer", "depends_on": "customer",
"description": "", "description": "",
"fetch_if_empty": 0,
"fieldname": "territory", "fieldname": "territory",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -1022,6 +1017,7 @@
"columns": 0, "columns": 0,
"depends_on": "customer", "depends_on": "customer",
"description": "", "description": "",
"fetch_if_empty": 0,
"fieldname": "customer_group", "fieldname": "customer_group",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -1056,6 +1052,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break3", "fieldname": "column_break3",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -1087,6 +1084,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.lead || doc.customer", "depends_on": "eval:doc.lead || doc.customer",
"fetch_if_empty": 0,
"fieldname": "contact_person", "fieldname": "contact_person",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -1120,6 +1118,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "customer", "depends_on": "customer",
"fetch_if_empty": 0,
"fieldname": "contact_display", "fieldname": "contact_display",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"hidden": 0, "hidden": 0,
@@ -1152,6 +1151,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.lead || doc.customer", "depends_on": "eval:doc.lead || doc.customer",
"fetch_if_empty": 0,
"fieldname": "contact_email", "fieldname": "contact_email",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
@@ -1184,6 +1184,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.lead || doc.customer", "depends_on": "eval:doc.lead || doc.customer",
"fetch_if_empty": 0,
"fieldname": "contact_mobile", "fieldname": "contact_mobile",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"hidden": 0, "hidden": 0,
@@ -1216,6 +1217,7 @@
"collapsible": 1, "collapsible": 1,
"collapsible_depends_on": "", "collapsible_depends_on": "",
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "more_info", "fieldname": "more_info",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -1249,6 +1251,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "source", "fieldname": "source",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -1285,6 +1288,7 @@
"columns": 0, "columns": 0,
"depends_on": "eval: doc.source==\"Campaign\"", "depends_on": "eval: doc.source==\"Campaign\"",
"description": "Enter name of campaign if source of enquiry is campaign", "description": "Enter name of campaign if source of enquiry is campaign",
"fetch_if_empty": 0,
"fieldname": "campaign", "fieldname": "campaign",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -1319,6 +1323,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break1", "fieldname": "column_break1",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -1351,6 +1356,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "company", "fieldname": "company",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -1386,6 +1392,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "Today", "default": "Today",
"fetch_if_empty": 0,
"fieldname": "transaction_date", "fieldname": "transaction_date",
"fieldtype": "Date", "fieldtype": "Date",
"hidden": 0, "hidden": 0,
@@ -1420,6 +1427,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "amended_from", "fieldname": "amended_from",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -1460,7 +1468,7 @@
"issingle": 0, "issingle": 0,
"istable": 0, "istable": 0,
"max_attachments": 0, "max_attachments": 0,
"modified": "2018-10-01 09:28:43.990999", "modified": "2019-04-25 18:55:43.874656",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "CRM", "module": "CRM",
"name": "Opportunity", "name": "Opportunity",
@@ -1508,11 +1516,11 @@
"quick_entry": 0, "quick_entry": 0,
"read_only": 0, "read_only": 0,
"read_only_onload": 0, "read_only_onload": 0,
"search_fields": "status,transaction_date,customer,lead,opportunity_type,territory,company", "search_fields": "status,transaction_date,party_name,opportunity_type,territory,company",
"show_name_in_global_search": 1, "show_name_in_global_search": 1,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "sort_order": "DESC",
"timeline_field": "customer", "timeline_field": "party_name",
"title_field": "title", "title_field": "title",
"track_changes": 0, "track_changes": 0,
"track_seen": 1, "track_seen": 1,

View File

@@ -16,8 +16,8 @@ sender_field = "contact_email"
class Opportunity(TransactionBase): class Opportunity(TransactionBase):
def after_insert(self): def after_insert(self):
if self.lead: if self.opportunity_from == "Lead":
frappe.get_doc("Lead", self.lead).set_status(update=True) frappe.get_doc("Lead", self.party_name).set_status(update=True)
def validate(self): def validate(self):
self._prev = frappe._dict({ self._prev = frappe._dict({
@@ -29,12 +29,8 @@ class Opportunity(TransactionBase):
self.make_new_lead_if_required() self.make_new_lead_if_required()
if not self.enquiry_from:
frappe.throw(_("Opportunity From field is mandatory"))
self.validate_item_details() self.validate_item_details()
self.validate_uom_is_integer("uom", "qty") self.validate_uom_is_integer("uom", "qty")
self.validate_lead_cust()
self.validate_cust_name() self.validate_cust_name()
if not self.title: if not self.title:
@@ -45,7 +41,7 @@ class Opportunity(TransactionBase):
def make_new_lead_if_required(self): def make_new_lead_if_required(self):
"""Set lead against new opportunity""" """Set lead against new opportunity"""
if not (self.lead or self.customer) and self.contact_email: if (not self.get("party_name")) and self.contact_email:
# check if customer is already created agains the self.contact_email # check if customer is already created agains the self.contact_email
customer = frappe.db.sql("""select customer = frappe.db.sql("""select
distinct `tabDynamic Link`.link_name as customer distinct `tabDynamic Link`.link_name as customer
@@ -61,8 +57,8 @@ class Opportunity(TransactionBase):
`tabDynamic Link`.link_doctype='Customer' `tabDynamic Link`.link_doctype='Customer'
""".format(self.contact_email), as_dict=True) """.format(self.contact_email), as_dict=True)
if customer and customer[0].customer: if customer and customer[0].customer:
self.customer = customer[0].customer self.party_name = customer[0].customer
self.enquiry_from = "Customer" self.opportunity_from = "Customer"
return return
lead_name = frappe.db.get_value("Lead", {"email_id": self.contact_email}) lead_name = frappe.db.get_value("Lead", {"email_id": self.contact_email})
@@ -89,8 +85,8 @@ class Opportunity(TransactionBase):
lead.insert(ignore_permissions=True) lead.insert(ignore_permissions=True)
lead_name = lead.name lead_name = lead.name
self.enquiry_from = "Lead" self.opportunity_from = "Lead"
self.lead = lead_name self.party_name = lead_name
def declare_enquiry_lost(self,arg): def declare_enquiry_lost(self,arg):
if not self.has_active_quotation(): if not self.has_active_quotation():
@@ -137,10 +133,10 @@ class Opportunity(TransactionBase):
return True return True
def validate_cust_name(self): def validate_cust_name(self):
if self.customer: if self.party_name and self.opportunity_from == 'Customer':
self.customer_name = frappe.db.get_value("Customer", self.customer, "customer_name") self.customer_name = frappe.db.get_value("Customer", self.party_name, "customer_name")
elif self.lead: elif self.party_name and self.opportunity_from == 'Lead':
lead_name, company_name = frappe.db.get_value("Lead", self.lead, ["lead_name", "company_name"]) lead_name, company_name = frappe.db.get_value("Lead", self.party_name, ["lead_name", "company_name"])
self.customer_name = company_name or lead_name self.customer_name = company_name or lead_name
def on_update(self): def on_update(self):
@@ -153,16 +149,16 @@ class Opportunity(TransactionBase):
opts.description = "" opts.description = ""
opts.contact_date = self.contact_date opts.contact_date = self.contact_date
if self.customer: if self.party_name and self.opportunity_from == 'Customer':
if self.contact_person: if self.contact_person:
opts.description = 'Contact '+cstr(self.contact_person) opts.description = 'Contact '+cstr(self.contact_person)
else: else:
opts.description = 'Contact customer '+cstr(self.customer) opts.description = 'Contact customer '+cstr(self.party_name)
elif self.lead: elif self.party_name and self.opportunity_from == 'Lead':
if self.contact_display: if self.contact_display:
opts.description = 'Contact '+cstr(self.contact_display) opts.description = 'Contact '+cstr(self.contact_display)
else: else:
opts.description = 'Contact lead '+cstr(self.lead) opts.description = 'Contact lead '+cstr(self.party_name)
opts.subject = opts.description opts.subject = opts.description
opts.description += '. By : ' + cstr(self.contact_by) opts.description += '. By : ' + cstr(self.contact_by)
@@ -187,17 +183,6 @@ class Opportunity(TransactionBase):
for key in item_fields: for key in item_fields:
if not d.get(key): d.set(key, item.get(key)) if not d.get(key): d.set(key, item.get(key))
def validate_lead_cust(self):
if self.enquiry_from == 'Lead':
if not self.lead:
frappe.throw(_("Lead must be set if Opportunity is made from Lead"))
else:
self.customer = None
elif self.enquiry_from == 'Customer':
if not self.customer:
msgprint(_("Customer is mandatory if 'Opportunity From' is selected as Customer"), raise_exception=1)
else:
self.lead = None
@frappe.whitelist() @frappe.whitelist()
def get_item_details(item_code): def get_item_details(item_code):
@@ -219,8 +204,11 @@ def make_quotation(source_name, target_doc=None):
quotation = frappe.get_doc(target) quotation = frappe.get_doc(target)
company_currency = frappe.get_cached_value('Company', quotation.company, "default_currency") company_currency = frappe.get_cached_value('Company', quotation.company, "default_currency")
party_account_currency = get_party_account_currency("Customer", quotation.customer,
quotation.company) if quotation.customer else company_currency if quotation.quotation_to == 'Customer' and quotation.party_name:
party_account_currency = get_party_account_currency("Customer", quotation.party_name, quotation.company)
else:
party_account_currency = company_currency
quotation.currency = party_account_currency or company_currency quotation.currency = party_account_currency or company_currency
@@ -246,7 +234,7 @@ def make_quotation(source_name, target_doc=None):
"Opportunity": { "Opportunity": {
"doctype": "Quotation", "doctype": "Quotation",
"field_map": { "field_map": {
"enquiry_from": "quotation_to", "opportunity_from": "quotation_to",
"opportunity_type": "order_type", "opportunity_type": "order_type",
"name": "enq_no", "name": "enq_no",
} }

View File

@@ -1,5 +1,5 @@
frappe.listview_settings['Opportunity'] = { frappe.listview_settings['Opportunity'] = {
add_fields: ["customer_name", "opportunity_type", "enquiry_from", "status"], add_fields: ["customer_name", "opportunity_type", "opportunity_from", "status"],
get_indicator: function(doc) { get_indicator: function(doc) {
var indicator = [__(doc.status), frappe.utils.guess_colour(doc.status), "status,=," + doc.status]; var indicator = [__(doc.status), frappe.utils.guess_colour(doc.status), "status,=," + doc.status];
if(doc.status=="Quotation") { if(doc.status=="Quotation") {

View File

@@ -6,7 +6,7 @@ QUnit.test("test: opportunity", function (assert) {
() => frappe.timeout(1), () => frappe.timeout(1),
() => frappe.click_button('New'), () => frappe.click_button('New'),
() => frappe.timeout(1), () => frappe.timeout(1),
() => cur_frm.set_value('enquiry_from', 'Customer'), () => cur_frm.set_value('opportunity_from', 'Customer'),
() => cur_frm.set_value('customer', 'Test Customer 1'), () => cur_frm.set_value('customer', 'Test Customer 1'),
// check items // check items

View File

@@ -37,13 +37,13 @@ class TestOpportunity(unittest.TestCase):
# new lead should be created against the new.opportunity@example.com # new lead should be created against the new.opportunity@example.com
opp_doc = frappe.get_doc(args).insert(ignore_permissions=True) opp_doc = frappe.get_doc(args).insert(ignore_permissions=True)
self.assertTrue(opp_doc.lead) self.assertTrue(opp_doc.party_name)
self.assertEqual(opp_doc.enquiry_from, "Lead") self.assertEqual(opp_doc.opportunity_from, "Lead")
self.assertEqual(frappe.db.get_value("Lead", opp_doc.lead, "email_id"), self.assertEqual(frappe.db.get_value("Lead", opp_doc.party_name, "email_id"),
'new.opportunity@example.com') 'new.opportunity@example.com')
# create new customer and create new contact against 'new.opportunity@example.com' # create new customer and create new contact against 'new.opportunity@example.com'
customer = make_customer(opp_doc.lead).insert(ignore_permissions=True) customer = make_customer(opp_doc.party_name).insert(ignore_permissions=True)
frappe.get_doc({ frappe.get_doc({
"doctype": "Contact", "doctype": "Contact",
"email_id": "new.opportunity@example.com", "email_id": "new.opportunity@example.com",
@@ -55,9 +55,9 @@ class TestOpportunity(unittest.TestCase):
}).insert(ignore_permissions=True) }).insert(ignore_permissions=True)
opp_doc = frappe.get_doc(args).insert(ignore_permissions=True) opp_doc = frappe.get_doc(args).insert(ignore_permissions=True)
self.assertTrue(opp_doc.customer) self.assertTrue(opp_doc.party_name)
self.assertEqual(opp_doc.enquiry_from, "Customer") self.assertEqual(opp_doc.opportunity_from, "Customer")
self.assertEqual(opp_doc.customer, customer.name) self.assertEqual(opp_doc.party_name, customer.name)
def make_opportunity(**args): def make_opportunity(**args):
args = frappe._dict(args) args = frappe._dict(args)
@@ -65,17 +65,17 @@ def make_opportunity(**args):
opp_doc = frappe.get_doc({ opp_doc = frappe.get_doc({
"doctype": "Opportunity", "doctype": "Opportunity",
"company": args.company or "_Test Company", "company": args.company or "_Test Company",
"enquiry_from": args.enquiry_from or "Customer", "opportunity_from": args.opportunity_from or "Customer",
"opportunity_type": "Sales", "opportunity_type": "Sales",
"with_items": args.with_items or 0, "with_items": args.with_items or 0,
"transaction_date": today() "transaction_date": today()
}) })
if opp_doc.enquiry_from == 'Customer': if opp_doc.opportunity_from == 'Customer':
opp_doc.customer = args.customer or "_Test Customer" opp_doc.party_name= args.customer or "_Test Customer"
if opp_doc.enquiry_from == 'Lead': if opp_doc.opportunity_from == 'Lead':
opp_doc.customer = args.lead or "_T-Lead-00001" opp_doc.party_name = args.lead or "_T-Lead-00001"
if args.with_items: if args.with_items:
opp_doc.append('items', { opp_doc.append('items', {

View File

@@ -2,9 +2,9 @@
{ {
"doctype": "Opportunity", "doctype": "Opportunity",
"name": "_Test Opportunity 1", "name": "_Test Opportunity 1",
"enquiry_from": "Lead", "opportunity_from": "Lead",
"enquiry_type": "Sales", "enquiry_type": "Sales",
"lead": "_T-Lead-00001", "party_name": "_T-Lead-00001",
"transaction_date": "2013-12-12", "transaction_date": "2013-12-12",
"items": [{ "items": [{
"item_name": "Test Item", "item_name": "Test Item",

View File

@@ -66,7 +66,7 @@ def get_columns():
def get_communication_details(filters): def get_communication_details(filters):
communication_count = None communication_count = None
communication_list = [] communication_list = []
opportunities = frappe.db.get_values('Opportunity', {'enquiry_from': 'Lead'},\ opportunities = frappe.db.get_values('Opportunity', {'opportunity_from': 'Lead'},\
['name', 'customer_name', 'lead', 'contact_email'], as_dict=1) ['name', 'customer_name', 'lead', 'contact_email'], as_dict=1)
for d in opportunities: for d in opportunities:

View File

@@ -56,7 +56,7 @@ def work(domain="Manufacturing"):
def make_opportunity(domain): def make_opportunity(domain):
b = frappe.get_doc({ b = frappe.get_doc({
"doctype": "Opportunity", "doctype": "Opportunity",
"enquiry_from": "Customer", "opportunity_from": "Customer",
"customer": get_random("Customer"), "customer": get_random("Customer"),
"opportunity_type": "Sales", "opportunity_type": "Sales",
"with_items": 1, "with_items": 1,

View File

@@ -28,7 +28,7 @@ def make_opportunity(buyer_name, email_id):
lead.save(ignore_permissions=True) lead.save(ignore_permissions=True)
o = frappe.new_doc("Opportunity") o = frappe.new_doc("Opportunity")
o.enquiry_from = "Lead" o.opportunity_from = "Lead"
o.lead = frappe.get_all("Lead", filters={"email_id": email_id}, fields = ["name"])[0]["name"] o.lead = frappe.get_all("Lead", filters={"email_id": email_id}, fields = ["name"])[0]["name"]
o.save(ignore_permissions=True) o.save(ignore_permissions=True)

View File

@@ -590,6 +590,7 @@ erpnext.patches.v10_0.item_barcode_childtable_migrate # 16-02-2019
erpnext.patches.v11_0.make_italian_localization_fields # 26-03-2019 erpnext.patches.v11_0.make_italian_localization_fields # 26-03-2019
erpnext.patches.v11_1.make_job_card_time_logs erpnext.patches.v11_1.make_job_card_time_logs
erpnext.patches.v11_1.set_variant_based_on erpnext.patches.v11_1.set_variant_based_on
erpnext.patches.v11_1.move_customer_lead_to_dynamic_column
erpnext.patches.v11_1.woocommerce_set_creation_user erpnext.patches.v11_1.woocommerce_set_creation_user
erpnext.patches.v11_1.delete_bom_browser erpnext.patches.v11_1.delete_bom_browser
erpnext.patches.v11_1.set_salary_details_submittable erpnext.patches.v11_1.set_salary_details_submittable

View File

@@ -0,0 +1,14 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
def execute():
frappe.reload_doctype("Quotation")
frappe.db.sql(""" UPDATE `tabQuotation` set party_name = lead WHERE quotation_to = 'Lead' """)
frappe.db.sql(""" UPDATE `tabQuotation` set party_name = customer WHERE quotation_to = 'Customer' """)
frappe.reload_doctype("Opportunity")
frappe.db.sql(""" UPDATE `tabOpportunity` set party_name = lead WHERE opportunity_from = 'Lead' """)
frappe.db.sql(""" UPDATE `tabOpportunity` set party_name = customer WHERE opportunity_from = 'Customer' """)

View File

@@ -104,10 +104,6 @@ class Customer(TransactionBase):
if self.lead_name: if self.lead_name:
frappe.db.set_value('Lead', self.lead_name, 'status', 'Converted', update_modified=False) frappe.db.set_value('Lead', self.lead_name, 'status', 'Converted', update_modified=False)
for doctype in ('Opportunity', 'Quotation'):
for d in frappe.get_all(doctype, {'lead': self.lead_name}):
frappe.db.set_value(doctype, d.name, 'customer', self.name, update_modified=False)
def create_lead_address_contact(self): def create_lead_address_contact(self):
if self.lead_name: if self.lead_name:
# assign lead address to customer (if already not set) # assign lead address to customer (if already not set)

View File

@@ -6,6 +6,10 @@ def get_data():
'heatmap': True, 'heatmap': True,
'heatmap_message': _('This is based on transactions against this Customer. See timeline below for details'), 'heatmap_message': _('This is based on transactions against this Customer. See timeline below for details'),
'fieldname': 'customer', 'fieldname': 'customer',
'non_standard_fieldnames': {
'Quotation': 'party_name',
'Opportunity': 'party_name'
},
'transactions': [ 'transactions': [
{ {
'label': _('Pre Sales'), 'label': _('Pre Sales'),

View File

@@ -8,15 +8,27 @@ frappe.ui.form.on('Quotation', {
setup: function(frm) { setup: function(frm) {
frm.custom_make_buttons = { frm.custom_make_buttons = {
'Sales Order': 'Make Sales Order' 'Sales Order': 'Make Sales Order'
} },
frm.set_query("quotation_to", function() {
return{
"filters": {
"name": ["in", ["Customer", "Lead"]],
}
}
});
}, },
refresh: function(frm) { refresh: function(frm) {
frm.trigger("set_label"); frm.trigger("set_label");
frm.trigger("set_dynamic_field_label");
}, },
quotation_to: function(frm) { quotation_to: function(frm) {
frm.trigger("set_label"); frm.trigger("set_label");
frm.trigger("toggle_reqd_lead_customer");
frm.trigger("set_dynamic_field_label");
}, },
set_label: function(frm) { set_label: function(frm) {
@@ -28,10 +40,6 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
onload: function(doc, dt, dn) { onload: function(doc, dt, dn) {
var me = this; var me = this;
this._super(doc, dt, dn); 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";
}, },
refresh: function(doc, dt, dn) { refresh: function(doc, dt, dn) {
@@ -97,25 +105,28 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
}, },
quotation_to: function() { set_dynamic_field_label: function(){
var me = this; if (this.frm.doc.quotation_to == "Customer")
if (this.frm.doc.quotation_to == "Lead") { {
this.frm.set_value("customer", null); this.frm.set_df_property("party_name", "label", "Customer");
this.frm.set_value("contact_person", null); this.frm.fields_dict.party_name.get_query = null;
} else if (this.frm.doc.quotation_to == "Customer") {
this.frm.set_value("lead", null);
} }
this.toggle_reqd_lead_customer(); if (this.frm.doc.quotation_to == "Lead")
{
this.frm.set_df_property("party_name", "label", "Lead");
this.frm.fields_dict.party_name.get_query = function() {
return{ query: "erpnext.controllers.queries.lead_query" }
}
}
}, },
toggle_reqd_lead_customer: function() { toggle_reqd_lead_customer: 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");
// to overwrite the customer_filter trigger from queries.js // to overwrite the customer_filter trigger from queries.js
this.frm.toggle_reqd("party_name", this.frm.doc.quotation_to);
this.frm.set_query('customer_address', erpnext.queries.address_query); this.frm.set_query('customer_address', erpnext.queries.address_query);
this.frm.set_query('shipping_address_name', erpnext.queries.address_query); this.frm.set_query('shipping_address_name', erpnext.queries.address_query);
}, },
@@ -163,10 +174,6 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
cur_frm.script_manager.make(erpnext.selling.QuotationController); cur_frm.script_manager.make(erpnext.selling.QuotationController);
cur_frm.fields_dict.lead.get_query = function(doc,cdt,cdn) {
return{ query: "erpnext.controllers.queries.lead_query" }
}
cur_frm.cscript['Make Sales Order'] = function() { cur_frm.cscript['Make Sales Order'] = function() {
frappe.model.open_mapped_doc({ frappe.model.open_mapped_doc({
method: "erpnext.selling.doctype.quotation.quotation.make_sales_order", method: "erpnext.selling.doctype.quotation.quotation.make_sales_order",

View File

@@ -20,6 +20,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "customer_section", "fieldname": "customer_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -53,6 +54,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "{customer_name}", "default": "{customer_name}",
"fetch_if_empty": 0,
"fieldname": "title", "fieldname": "title",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 1, "hidden": 1,
@@ -86,6 +88,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "", "default": "",
"fetch_if_empty": 0,
"fieldname": "naming_series", "fieldname": "naming_series",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 0, "hidden": 0,
@@ -121,8 +124,9 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "Customer", "default": "Customer",
"fetch_if_empty": 0,
"fieldname": "quotation_to", "fieldname": "quotation_to",
"fieldtype": "Select", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
@@ -135,7 +139,7 @@
"no_copy": 0, "no_copy": 0,
"oldfieldname": "quotation_to", "oldfieldname": "quotation_to",
"oldfieldtype": "Select", "oldfieldtype": "Select",
"options": "\nLead\nCustomer", "options": "DocType",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
@@ -155,9 +159,10 @@
"bold": 1, "bold": 1,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.quotation_to == \"Customer\"", "depends_on": "",
"fieldname": "customer", "fetch_if_empty": 0,
"fieldtype": "Link", "fieldname": "party_name",
"fieldtype": "Dynamic Link",
"hidden": 0, "hidden": 0,
"ignore_user_permissions": 0, "ignore_user_permissions": 0,
"ignore_xss_filter": 0, "ignore_xss_filter": 0,
@@ -165,12 +170,12 @@
"in_global_search": 1, "in_global_search": 1,
"in_list_view": 0, "in_list_view": 0,
"in_standard_filter": 1, "in_standard_filter": 1,
"label": "Customer", "label": "Customer/Lead",
"length": 0, "length": 0,
"no_copy": 0, "no_copy": 0,
"oldfieldname": "customer", "oldfieldname": "customer",
"oldfieldtype": "Link", "oldfieldtype": "Link",
"options": "Customer", "options": "quotation_to",
"permlevel": 0, "permlevel": 0,
"print_hide": 1, "print_hide": 1,
"print_hide_if_no_value": 0, "print_hide_if_no_value": 0,
@@ -183,41 +188,6 @@
"translatable": 0, "translatable": 0,
"unique": 0 "unique": 0
}, },
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.quotation_to == \"Lead\"",
"fieldname": "lead",
"fieldtype": "Link",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 1,
"label": "Lead",
"length": 0,
"no_copy": 0,
"oldfieldname": "lead",
"oldfieldtype": "Link",
"options": "Lead",
"permlevel": 0,
"print_hide": 1,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{ {
"allow_bulk_edit": 0, "allow_bulk_edit": 0,
"allow_in_quick_entry": 0, "allow_in_quick_entry": 0,
@@ -226,6 +196,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_from": "customer.customer_name", "fetch_from": "customer.customer_name",
"fetch_if_empty": 0,
"fieldname": "customer_name", "fieldname": "customer_name",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 1, "hidden": 1,
@@ -258,6 +229,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break1", "fieldname": "column_break1",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -290,6 +262,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "amended_from", "fieldname": "amended_from",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -326,6 +299,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "", "description": "",
"fetch_if_empty": 0,
"fieldname": "company", "fieldname": "company",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -362,6 +336,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "Today", "default": "Today",
"fetch_if_empty": 0,
"fieldname": "transaction_date", "fieldname": "transaction_date",
"fieldtype": "Date", "fieldtype": "Date",
"hidden": 0, "hidden": 0,
@@ -396,6 +371,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "valid_till", "fieldname": "valid_till",
"fieldtype": "Date", "fieldtype": "Date",
"hidden": 0, "hidden": 0,
@@ -429,6 +405,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "Sales", "default": "Sales",
"fetch_if_empty": 0,
"fieldname": "order_type", "fieldname": "order_type",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 0, "hidden": 0,
@@ -465,6 +442,7 @@
"collapsible_depends_on": "", "collapsible_depends_on": "",
"columns": 0, "columns": 0,
"depends_on": "eval:(doc.customer || doc.lead)", "depends_on": "eval:(doc.customer || doc.lead)",
"fetch_if_empty": 0,
"fieldname": "contact_section", "fieldname": "contact_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -497,6 +475,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "customer_address", "fieldname": "customer_address",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -529,6 +508,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "address_display", "fieldname": "address_display",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"hidden": 0, "hidden": 0,
@@ -563,6 +543,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.customer", "depends_on": "eval:doc.customer",
"fetch_if_empty": 0,
"fieldname": "contact_person", "fieldname": "contact_person",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -597,6 +578,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "contact_display", "fieldname": "contact_display",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"hidden": 0, "hidden": 0,
@@ -628,6 +610,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "contact_mobile", "fieldname": "contact_mobile",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"hidden": 0, "hidden": 0,
@@ -659,6 +642,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "contact_email", "fieldname": "contact_email",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 1, "hidden": 1,
@@ -692,6 +676,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "customer", "depends_on": "customer",
"fetch_if_empty": 0,
"fieldname": "col_break98", "fieldname": "col_break98",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -723,6 +708,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "shipping_address_name", "fieldname": "shipping_address_name",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -755,6 +741,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "shipping_address", "fieldname": "shipping_address",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"hidden": 0, "hidden": 0,
@@ -788,6 +775,7 @@
"columns": 0, "columns": 0,
"depends_on": "customer", "depends_on": "customer",
"description": "", "description": "",
"fetch_if_empty": 0,
"fieldname": "customer_group", "fieldname": "customer_group",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 1, "hidden": 1,
@@ -823,6 +811,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "", "description": "",
"fetch_if_empty": 0,
"fieldname": "territory", "fieldname": "territory",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -855,6 +844,7 @@
"bold": 0, "bold": 0,
"collapsible": 1, "collapsible": 1,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "currency_and_price_list", "fieldname": "currency_and_price_list",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -887,6 +877,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "currency", "fieldname": "currency",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -923,6 +914,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "Rate at which customer's currency is converted to company's base currency", "description": "Rate at which customer's currency is converted to company's base currency",
"fetch_if_empty": 0,
"fieldname": "conversion_rate", "fieldname": "conversion_rate",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
@@ -958,6 +950,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break2", "fieldname": "column_break2",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -989,6 +982,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "selling_price_list", "fieldname": "selling_price_list",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -1024,6 +1018,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "price_list_currency", "fieldname": "price_list_currency",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -1057,6 +1052,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "Rate at which Price list currency is converted to company's base currency", "description": "Rate at which Price list currency is converted to company's base currency",
"fetch_if_empty": 0,
"fieldname": "plc_conversion_rate", "fieldname": "plc_conversion_rate",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
@@ -1089,6 +1085,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "ignore_pricing_rule", "fieldname": "ignore_pricing_rule",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -1120,6 +1117,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "items_section", "fieldname": "items_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -1153,6 +1151,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "items", "fieldname": "items",
"fieldtype": "Table", "fieldtype": "Table",
"hidden": 0, "hidden": 0,
@@ -1188,6 +1187,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "sec_break23", "fieldname": "sec_break23",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -1218,6 +1218,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "total_qty", "fieldname": "total_qty",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
@@ -1250,6 +1251,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "base_total", "fieldname": "base_total",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -1283,6 +1285,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "base_net_total", "fieldname": "base_net_total",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -1318,6 +1321,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_28", "fieldname": "column_break_28",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -1348,6 +1352,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "total", "fieldname": "total",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -1381,6 +1386,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "net_total", "fieldname": "net_total",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -1413,6 +1419,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "total_net_weight", "fieldname": "total_net_weight",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
@@ -1445,6 +1452,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "taxes_section", "fieldname": "taxes_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -1478,6 +1486,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "taxes_and_charges", "fieldname": "taxes_and_charges",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -1512,6 +1521,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_34", "fieldname": "column_break_34",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -1542,6 +1552,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "shipping_rule", "fieldname": "shipping_rule",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -1575,6 +1586,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "section_break_36", "fieldname": "section_break_36",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -1605,6 +1617,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "taxes", "fieldname": "taxes",
"fieldtype": "Table", "fieldtype": "Table",
"hidden": 0, "hidden": 0,
@@ -1639,6 +1652,7 @@
"bold": 0, "bold": 0,
"collapsible": 1, "collapsible": 1,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "sec_tax_breakup", "fieldname": "sec_tax_breakup",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -1671,6 +1685,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "other_charges_calculation", "fieldname": "other_charges_calculation",
"fieldtype": "Text", "fieldtype": "Text",
"hidden": 0, "hidden": 0,
@@ -1703,6 +1718,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "section_break_39", "fieldname": "section_break_39",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -1733,6 +1749,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "base_total_taxes_and_charges", "fieldname": "base_total_taxes_and_charges",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -1767,6 +1784,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_42", "fieldname": "column_break_42",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -1797,6 +1815,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "total_taxes_and_charges", "fieldname": "total_taxes_and_charges",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -1830,6 +1849,7 @@
"collapsible": 1, "collapsible": 1,
"collapsible_depends_on": "discount_amount", "collapsible_depends_on": "discount_amount",
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "section_break_44", "fieldname": "section_break_44",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -1863,6 +1883,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "Grand Total", "default": "Grand Total",
"fetch_if_empty": 0,
"fieldname": "apply_discount_on", "fieldname": "apply_discount_on",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 0, "hidden": 0,
@@ -1896,6 +1917,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "base_discount_amount", "fieldname": "base_discount_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -1929,6 +1951,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_46", "fieldname": "column_break_46",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -1960,6 +1983,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "additional_discount_percentage", "fieldname": "additional_discount_percentage",
"fieldtype": "Float", "fieldtype": "Float",
"hidden": 0, "hidden": 0,
@@ -1992,6 +2016,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "discount_amount", "fieldname": "discount_amount",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -2024,6 +2049,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "totals", "fieldname": "totals",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -2057,6 +2083,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "base_grand_total", "fieldname": "base_grand_total",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -2092,6 +2119,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "base_rounding_adjustment", "fieldname": "base_rounding_adjustment",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -2126,6 +2154,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"description": "In Words will be visible once you save the Quotation.", "description": "In Words will be visible once you save the Quotation.",
"fetch_if_empty": 0,
"fieldname": "base_in_words", "fieldname": "base_in_words",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
@@ -2160,6 +2189,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "base_rounded_total", "fieldname": "base_rounded_total",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -2195,6 +2225,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break3", "fieldname": "column_break3",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -2227,6 +2258,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "grand_total", "fieldname": "grand_total",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -2262,6 +2294,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "rounding_adjustment", "fieldname": "rounding_adjustment",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -2295,6 +2328,7 @@
"bold": 1, "bold": 1,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "rounded_total", "fieldname": "rounded_total",
"fieldtype": "Currency", "fieldtype": "Currency",
"hidden": 0, "hidden": 0,
@@ -2330,6 +2364,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "in_words", "fieldname": "in_words",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
@@ -2366,6 +2401,7 @@
"collapsible_depends_on": "", "collapsible_depends_on": "",
"columns": 0, "columns": 0,
"depends_on": "", "depends_on": "",
"fetch_if_empty": 0,
"fieldname": "payment_schedule_section", "fieldname": "payment_schedule_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -2398,6 +2434,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "payment_terms_template", "fieldname": "payment_terms_template",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -2431,6 +2468,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "payment_schedule", "fieldname": "payment_schedule",
"fieldtype": "Table", "fieldtype": "Table",
"hidden": 0, "hidden": 0,
@@ -2465,6 +2503,7 @@
"collapsible": 1, "collapsible": 1,
"collapsible_depends_on": "terms", "collapsible_depends_on": "terms",
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "terms_section_break", "fieldname": "terms_section_break",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -2498,6 +2537,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "tc_name", "fieldname": "tc_name",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -2532,6 +2572,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "terms", "fieldname": "terms",
"fieldtype": "Text Editor", "fieldtype": "Text Editor",
"hidden": 0, "hidden": 0,
@@ -2565,6 +2606,7 @@
"bold": 0, "bold": 0,
"collapsible": 1, "collapsible": 1,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "print_settings", "fieldname": "print_settings",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -2597,6 +2639,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "letter_head", "fieldname": "letter_head",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -2631,6 +2674,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "group_same_items", "fieldname": "group_same_items",
"fieldtype": "Check", "fieldtype": "Check",
"hidden": 0, "hidden": 0,
@@ -2663,6 +2707,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break_73", "fieldname": "column_break_73",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -2694,6 +2739,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "select_print_heading", "fieldname": "select_print_heading",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -2728,6 +2774,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "language", "fieldname": "language",
"fieldtype": "Data", "fieldtype": "Data",
"hidden": 0, "hidden": 0,
@@ -2760,6 +2807,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "subscription_section", "fieldname": "subscription_section",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -2792,6 +2840,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "auto_repeat", "fieldname": "auto_repeat",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -2826,6 +2875,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval: doc.auto_repeat", "depends_on": "eval: doc.auto_repeat",
"fetch_if_empty": 0,
"fieldname": "update_auto_repeat_reference", "fieldname": "update_auto_repeat_reference",
"fieldtype": "Button", "fieldtype": "Button",
"hidden": 0, "hidden": 0,
@@ -2858,6 +2908,7 @@
"bold": 0, "bold": 0,
"collapsible": 1, "collapsible": 1,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "more_info", "fieldname": "more_info",
"fieldtype": "Section Break", "fieldtype": "Section Break",
"hidden": 0, "hidden": 0,
@@ -2891,6 +2942,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "campaign", "fieldname": "campaign",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -2925,6 +2977,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "source", "fieldname": "source",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -2960,6 +3013,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"depends_on": "eval:doc.status===\"Lost\"", "depends_on": "eval:doc.status===\"Lost\"",
"fetch_if_empty": 0,
"fieldname": "order_lost_reason", "fieldname": "order_lost_reason",
"fieldtype": "Small Text", "fieldtype": "Small Text",
"hidden": 0, "hidden": 0,
@@ -2993,6 +3047,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "column_break4", "fieldname": "column_break4",
"fieldtype": "Column Break", "fieldtype": "Column Break",
"hidden": 0, "hidden": 0,
@@ -3026,6 +3081,7 @@
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"default": "Draft", "default": "Draft",
"fetch_if_empty": 0,
"fieldname": "status", "fieldname": "status",
"fieldtype": "Select", "fieldtype": "Select",
"hidden": 0, "hidden": 0,
@@ -3060,6 +3116,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "enq_det", "fieldname": "enq_det",
"fieldtype": "Text", "fieldtype": "Text",
"hidden": 1, "hidden": 1,
@@ -3093,6 +3150,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "supplier_quotation", "fieldname": "supplier_quotation",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -3126,6 +3184,7 @@
"bold": 0, "bold": 0,
"collapsible": 0, "collapsible": 0,
"columns": 0, "columns": 0,
"fetch_if_empty": 0,
"fieldname": "opportunity", "fieldname": "opportunity",
"fieldtype": "Link", "fieldtype": "Link",
"hidden": 0, "hidden": 0,
@@ -3165,7 +3224,7 @@
"istable": 0, "istable": 0,
"max_attachments": 1, "max_attachments": 1,
"menu_index": 0, "menu_index": 0,
"modified": "2019-01-07 16:51:55.604845", "modified": "2019-04-25 15:26:21.983298",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Selling", "module": "Selling",
"name": "Quotation", "name": "Quotation",
@@ -3331,11 +3390,11 @@
"quick_entry": 0, "quick_entry": 0,
"read_only": 0, "read_only": 0,
"read_only_onload": 1, "read_only_onload": 1,
"search_fields": "status,transaction_date,customer,lead,order_type", "search_fields": "status,transaction_date,party_name,order_type",
"show_name_in_global_search": 1, "show_name_in_global_search": 1,
"sort_field": "modified", "sort_field": "modified",
"sort_order": "DESC", "sort_order": "DESC",
"timeline_field": "customer", "timeline_field": "party_name",
"title_field": "title", "title_field": "title",
"track_changes": 0, "track_changes": 0,
"track_seen": 0, "track_seen": 0,

View File

@@ -28,11 +28,10 @@ class Quotation(SellingController):
self.update_opportunity() self.update_opportunity()
self.validate_order_type() self.validate_order_type()
self.validate_uom_is_integer("stock_uom", "qty") self.validate_uom_is_integer("stock_uom", "qty")
self.validate_quotation_to()
self.validate_valid_till() self.validate_valid_till()
if self.items: if self.items:
self.with_items = 1 self.with_items = 1
def validate_valid_till(self): def validate_valid_till(self):
if self.valid_till and self.valid_till < self.transaction_date: if self.valid_till and self.valid_till < self.transaction_date:
frappe.throw(_("Valid till date cannot be before transaction date")) frappe.throw(_("Valid till date cannot be before transaction date"))
@@ -43,16 +42,9 @@ class Quotation(SellingController):
def validate_order_type(self): def validate_order_type(self):
super(Quotation, self).validate_order_type() super(Quotation, self).validate_order_type()
def validate_quotation_to(self):
if self.customer:
self.quotation_to = "Customer"
self.lead = None
elif self.lead:
self.quotation_to = "Lead"
def update_lead(self): def update_lead(self):
if self.lead: if self.quotation_to == "Lead" and self.party_name:
frappe.get_doc("Lead", self.lead).set_status(update=True) frappe.get_doc("Lead", self.party_name).set_status(update=True)
def update_opportunity(self): def update_opportunity(self):
for opportunity in list(set([d.prevdoc_docname for d in self.get("items")])): for opportunity in list(set([d.prevdoc_docname for d in self.get("items")])):
@@ -209,12 +201,12 @@ def _make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
} }
}, target_doc, set_missing_values, ignore_permissions=ignore_permissions) }, target_doc, set_missing_values, ignore_permissions=ignore_permissions)
return doclist return doclist
def _make_customer(source_name, ignore_permissions=False): def _make_customer(source_name, ignore_permissions=False):
quotation = frappe.db.get_value("Quotation", source_name, ["lead", "order_type", "customer"]) quotation = frappe.db.get_value("Quotation", source_name, ["order_type", "party_name", "customer_name"])
if quotation and quotation[0] and not quotation[2]: if quotation and quotation[1] and not quotation[2]:
lead_name = quotation[0] lead_name = quotation[1]
customer_name = frappe.db.get_value("Customer", {"lead_name": lead_name}, customer_name = frappe.db.get_value("Customer", {"lead_name": lead_name},
["name", "customer_name"], as_dict=True) ["name", "customer_name"], as_dict=True)
if not customer_name: if not customer_name:
@@ -242,3 +234,5 @@ def _make_customer(source_name, ignore_permissions=False):
frappe.throw(_("Please create Customer from Lead {0}").format(lead_name)) frappe.throw(_("Please create Customer from Lead {0}").format(lead_name))
else: else:
return customer_name return customer_name
else:
return frappe.get_doc("Customer",quotation[2])

View File

@@ -203,15 +203,15 @@ class TestQuotation(unittest.TestCase):
test_records = frappe.get_test_records('Quotation') test_records = frappe.get_test_records('Quotation')
def get_quotation_dict(customer=None, item_code=None): def get_quotation_dict(party_name=None, item_code=None):
if not customer: if not party_name:
customer = '_Test Customer' party_name = '_Test Customer'
if not item_code: if not item_code:
item_code = '_Test Item' item_code = '_Test Item'
return { return {
'doctype': 'Quotation', 'doctype': 'Quotation',
'customer': customer, 'party_name': party_name,
'items': [ 'items': [
{ {
'item_code': item_code, 'item_code': item_code,
@@ -229,7 +229,7 @@ def make_quotation(**args):
qo.transaction_date = args.transaction_date qo.transaction_date = args.transaction_date
qo.company = args.company or "_Test Company" qo.company = args.company or "_Test Company"
qo.customer = args.customer or "_Test Customer" qo.party_name = args.party_name or "_Test Customer"
qo.currency = args.currency or "INR" qo.currency = args.currency or "INR"
if args.selling_price_list: if args.selling_price_list:
qo.selling_price_list = args.selling_price_list qo.selling_price_list = args.selling_price_list

View File

@@ -1,37 +1,37 @@
[ [
{ {
"company": "_Test Company", "company": "_Test Company",
"conversion_rate": 1.0, "conversion_rate": 1.0,
"currency": "INR", "currency": "INR",
"customer": "_Test Customer", "party_name": "_Test Customer",
"customer_group": "_Test Customer Group", "customer_group": "_Test Customer Group",
"customer_name": "_Test Customer", "customer_name": "_Test Customer",
"doctype": "Quotation", "doctype": "Quotation",
"base_grand_total": 1000.0, "base_grand_total": 1000.0,
"grand_total": 1000.0, "grand_total": 1000.0,
"order_type": "Sales", "order_type": "Sales",
"plc_conversion_rate": 1.0, "plc_conversion_rate": 1.0,
"price_list_currency": "INR", "price_list_currency": "INR",
"items": [ "items": [
{ {
"base_amount": 1000.0, "base_amount": 1000.0,
"base_rate": 100.0, "base_rate": 100.0,
"description": "CPU", "description": "CPU",
"doctype": "Quotation Item", "doctype": "Quotation Item",
"item_code": "_Test Item Home Desktop 100", "item_code": "_Test Item Home Desktop 100",
"item_name": "CPU", "item_name": "CPU",
"parentfield": "items", "parentfield": "items",
"qty": 10.0, "qty": 10.0,
"rate": 100.0, "rate": 100.0,
"uom": "_Test UOM 1", "uom": "_Test UOM 1",
"stock_uom": "_Test UOM 1", "stock_uom": "_Test UOM 1",
"conversion_factor": 1.0 "conversion_factor": 1.0
} }
], ],
"quotation_to": "Customer", "quotation_to": "Customer",
"selling_price_list": "_Test Price List", "selling_price_list": "_Test Price List",
"territory": "_Test Territory", "territory": "_Test Territory",
"transaction_date": "2013-02-21", "transaction_date": "2013-02-21",
"valid_till": "2013-03-21" "valid_till": "2013-03-21"
} }
] ]

View File

@@ -33,7 +33,7 @@ def make_sample_data(domains, make_dependent = False):
def make_opportunity(items, customer): def make_opportunity(items, customer):
b = frappe.get_doc({ b = frappe.get_doc({
"doctype": "Opportunity", "doctype": "Opportunity",
"enquiry_from": "Customer", "opportunity_from": "Customer",
"customer": customer, "customer": customer,
"opportunity_type": _("Sales"), "opportunity_type": _("Sales"),
"with_items": 1 "with_items": 1

View File

@@ -196,7 +196,7 @@ def _get_cart_quotation(party=None):
party = get_party() party = get_party()
quotation = frappe.get_all("Quotation", fields=["name"], filters= quotation = frappe.get_all("Quotation", fields=["name"], filters=
{party.doctype.lower(): party.name, "order_type": "Shopping Cart", "docstatus": 0}, {"party_name": party.name, "order_type": "Shopping Cart", "docstatus": 0},
order_by="modified desc", limit_page_length=1) order_by="modified desc", limit_page_length=1)
if quotation: if quotation:
@@ -211,7 +211,7 @@ def _get_cart_quotation(party=None):
"status": "Draft", "status": "Draft",
"docstatus": 0, "docstatus": 0,
"__islocal": 1, "__islocal": 1,
(party.doctype.lower()): party.name "party_name": party.name
}) })
qdoc.contact_person = frappe.db.get_value("Contact", {"email_id": frappe.session.user}) qdoc.contact_person = frappe.db.get_value("Contact", {"email_id": frappe.session.user})
@@ -291,9 +291,9 @@ def _set_price_list(quotation, cart_settings):
# check if customer price list exists # check if customer price list exists
selling_price_list = None selling_price_list = None
if quotation.customer: if quotation.party_name:
from erpnext.accounts.party import get_default_price_list from erpnext.accounts.party import get_default_price_list
selling_price_list = get_default_price_list(frappe.get_doc("Customer", quotation.customer)) selling_price_list = get_default_price_list(frappe.get_doc("Customer", quotation.party_name))
# else check for territory based price list # else check for territory based price list
if not selling_price_list: if not selling_price_list:
@@ -305,9 +305,9 @@ def set_taxes(quotation, cart_settings):
"""set taxes based on billing territory""" """set taxes based on billing territory"""
from erpnext.accounts.party import set_taxes from erpnext.accounts.party import set_taxes
customer_group = frappe.db.get_value("Customer", quotation.customer, "customer_group") customer_group = frappe.db.get_value("Customer", quotation.party_name, "customer_group")
quotation.taxes_and_charges = set_taxes(quotation.customer, "Customer", \ quotation.taxes_and_charges = set_taxes(quotation.party_name, "Customer", \
quotation.transaction_date, quotation.company, customer_group, None, \ quotation.transaction_date, quotation.company, customer_group, None, \
quotation.customer_address, quotation.shipping_address_name, 1) quotation.customer_address, quotation.shipping_address_name, 1)
# #

View File

@@ -33,7 +33,6 @@ class TestShoppingCart(unittest.TestCase):
self.assertEqual(quotation.quotation_to, "Customer") self.assertEqual(quotation.quotation_to, "Customer")
self.assertEqual(quotation.contact_person, self.assertEqual(quotation.contact_person,
frappe.db.get_value("Contact", dict(email_id="test_cart_user@example.com"))) frappe.db.get_value("Contact", dict(email_id="test_cart_user@example.com")))
self.assertEqual(quotation.lead, None)
self.assertEqual(quotation.contact_email, frappe.session.user) self.assertEqual(quotation.contact_email, frappe.session.user)
return quotation return quotation
@@ -44,8 +43,7 @@ class TestShoppingCart(unittest.TestCase):
# test if quotation with customer is fetched # test if quotation with customer is fetched
quotation = _get_cart_quotation() quotation = _get_cart_quotation()
self.assertEqual(quotation.quotation_to, "Customer") self.assertEqual(quotation.quotation_to, "Customer")
self.assertEqual(quotation.customer, "_Test Customer") self.assertEqual(quotation.party_name, "_Test Customer")
self.assertEqual(quotation.lead, None)
self.assertEqual(quotation.contact_email, frappe.session.user) self.assertEqual(quotation.contact_email, frappe.session.user)
return quotation return quotation
@@ -107,7 +105,7 @@ class TestShoppingCart(unittest.TestCase):
from erpnext.accounts.party import set_taxes from erpnext.accounts.party import set_taxes
tax_rule_master = set_taxes(quotation.customer, "Customer", \ tax_rule_master = set_taxes(quotation.party_name, "Customer", \
quotation.transaction_date, quotation.company, None, None, \ quotation.transaction_date, quotation.company, None, None, \
quotation.customer_address, quotation.shipping_address_name, 1) quotation.customer_address, quotation.shipping_address_name, 1)
self.assertEqual(quotation.taxes_and_charges, tax_rule_master) self.assertEqual(quotation.taxes_and_charges, tax_rule_master)
@@ -122,7 +120,7 @@ class TestShoppingCart(unittest.TestCase):
"doctype": "Quotation", "doctype": "Quotation",
"quotation_to": "Customer", "quotation_to": "Customer",
"order_type": "Shopping Cart", "order_type": "Shopping Cart",
"customer": get_party(frappe.session.user).name, "party_name": get_party(frappe.session.user).name,
"docstatus": 0, "docstatus": 0,
"contact_email": frappe.session.user, "contact_email": frappe.session.user,
"selling_price_list": "_Test Price List Rest of the World", "selling_price_list": "_Test Price List Rest of the World",

View File

@@ -28,7 +28,7 @@ def send_message(subject="Website Query", message="", sender="", status="Open"):
opportunity = frappe.get_doc(dict( opportunity = frappe.get_doc(dict(
doctype ='Opportunity', doctype ='Opportunity',
enquiry_from = 'Customer' if customer else 'Lead', opportunity_from = 'Customer' if customer else 'Lead',
status = 'Open', status = 'Open',
title = subject, title = subject,
contact_email = sender, contact_email = sender,