[cleanup] move contact, address to frappe 💥

This commit is contained in:
Rushabh Mehta
2017-01-13 18:53:11 +05:30
parent 448acf6f46
commit b92087cb2d
52 changed files with 196 additions and 3168 deletions

View File

@@ -1,61 +0,0 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
cur_frm.cscript.onload = function(doc, cdt, cdn) {
cur_frm.add_fetch('customer', 'customer_name', 'customer_name');
cur_frm.add_fetch('supplier', 'supplier_name', 'supplier_name');
cur_frm.fields_dict.customer.get_query = erpnext.queries.customer;
cur_frm.fields_dict.supplier.get_query = erpnext.queries.supplier;
if(cur_frm.fields_dict.lead) {
cur_frm.fields_dict.lead.get_query = erpnext.queries.lead;
cur_frm.add_fetch('lead', 'lead_name', 'lead_name');
}
if(doc.__islocal) {
var last_route = frappe.route_history.slice(-2, -1)[0];
if(last_route && last_route[0]==="Form") {
var doctype = last_route[1],
docname = last_route.slice(2).join("/");
if(["Customer", "Quotation", "Sales Order", "Sales Invoice", "Delivery Note",
"Installation Note", "Opportunity", "Warranty Claim", "Maintenance Visit",
"Maintenance Schedule"]
.indexOf(doctype)!==-1) {
var refdoc = frappe.get_doc(doctype, docname);
if((refdoc.doctype == "Quotation" && refdoc.quotation_to=="Customer") ||
(refdoc.doctype == "Opportunity" && refdoc.enquiry_from=="Customer") ||
!in_list(["Opportunity", "Quotation"], doctype)) {
cur_frm.set_value("customer", refdoc.customer || refdoc.name);
cur_frm.set_value("customer_name", refdoc.customer_name);
if(cur_frm.doc.doctype==="Address")
cur_frm.set_value("address_title", cur_frm.doc.customer_name);
}
}
else if(["Supplier", "Supplier Quotation", "Purchase Order", "Purchase Invoice", "Purchase Receipt"]
.indexOf(doctype)!==-1) {
var refdoc = frappe.get_doc(doctype, docname);
cur_frm.set_value("supplier", refdoc.supplier || refdoc.name);
cur_frm.set_value("supplier_name", refdoc.supplier_name);
if(cur_frm.doc.doctype==="Address")
cur_frm.set_value("address_title", cur_frm.doc.supplier_name);
}
else if(["Lead", "Opportunity", "Quotation"]
.indexOf(doctype)!==-1) {
var refdoc = frappe.get_doc(doctype, docname);
if((refdoc.doctype == "Quotation" && refdoc.quotation_to=="Lead") ||
(refdoc.doctype == "Opportunity" && refdoc.enquiry_from=="Lead") || (doctype=="Lead")) {
cur_frm.set_value("lead", refdoc.lead || refdoc.name);
cur_frm.set_value("lead_name", refdoc.customer_name || refdoc.company_name || refdoc.lead_name);
if(cur_frm.doc.doctype==="Address")
cur_frm.set_value("address_title", cur_frm.doc.lead_name);
}
}
else if(doctype == "Sales Partner") {
cur_frm.set_value("sales_partner", docname);
}
}
}
}

View File

@@ -3,32 +3,9 @@
from __future__ import unicode_literals
import frappe
from frappe.desk.reportview import get_match_cond
from frappe.model.db_query import DatabaseQuery
from frappe.desk.reportview import get_match_cond, get_filters_cond
from frappe.utils import nowdate
def get_filters_cond(doctype, filters, conditions):
if filters:
flt = filters
if isinstance(filters, dict):
filters = filters.items()
flt = []
for f in filters:
if isinstance(f[1], basestring) and f[1][0] == '!':
flt.append([doctype, f[0], '!=', f[1][1:]])
else:
value = frappe.db.escape(f[1]) if isinstance(f[1], basestring) else f[1]
flt.append([doctype, f[0], '=', value])
query = DatabaseQuery(doctype)
query.filters = flt
query.conditions = conditions
query.build_filter_conditions(flt, conditions)
cond = ' and ' + ' and '.join(query.conditions)
else:
cond = ''
return cond
# searches for active employees
def employee_query(doctype, txt, searchfield, start, page_len, filters):
@@ -88,7 +65,7 @@ def customer_query(doctype, txt, searchfield, start, page_len, filters):
fields = ["name", "customer_group", "territory"]
else:
fields = ["name", "customer_name", "customer_group", "territory"]
meta = frappe.get_meta("Customer")
fields = fields + [f for f in meta.get_search_fields() if not f in fields]