Merge pull request #2820 from mbauskar/develop
contact only available on doctypes with contact_html
This commit is contained in:
commit
54b56b1ff5
4 changed files with 88 additions and 3 deletions
|
|
@ -68,6 +68,34 @@
|
|||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "link_title",
|
||||
"fieldtype": "Read Only",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Link Title",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"unique": 0
|
||||
}
|
||||
],
|
||||
"hide_heading": 0,
|
||||
|
|
@ -80,7 +108,7 @@
|
|||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"modified": "2017-01-13 04:55:18.835023",
|
||||
"modified": "2017-01-17 14:25:49.140730",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Core",
|
||||
"name": "Dynamic Link",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,15 @@ frappe.ui.form.on("Contact", {
|
|||
});
|
||||
});
|
||||
}
|
||||
frm.set_query('link_doctype', "links", function() {
|
||||
return {
|
||||
query: "frappe.geo.address_and_contact.filter_dynamic_link_doctypes",
|
||||
filters: {
|
||||
fieldtype: "Link",
|
||||
options: frm.doc.doctype,
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
validate: function(frm) {
|
||||
// clear linked customer / supplier / sales partner on saving...
|
||||
|
|
@ -38,4 +47,18 @@ frappe.ui.form.on("Contact", {
|
|||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
frappe.ui.form.on("Dynamic Link", {
|
||||
link_name:function(frm, cdt, cdn){
|
||||
var child = locals[cdt][cdn];
|
||||
if(child.link_name) {
|
||||
frappe.model.with_doctype(child.link_doctype, function () {
|
||||
var title_field = frappe.get_meta(child.link_doctype).title_field || "name"
|
||||
frappe.model.get_value(child.link_doctype, child.link_name, title_field, function (r) {
|
||||
frappe.model.set_value(cdt, cdn, "link_title", r[title_field])
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -138,4 +138,29 @@ def delete_contact_and_address(doctype, docname):
|
|||
for name in items:
|
||||
doc = frappe.get_doc(parenttype, name)
|
||||
if len(doc.links)==1:
|
||||
doc.delete()
|
||||
doc.delete()
|
||||
|
||||
def filter_dynamic_link_doctypes(doctype, txt, searchfield, start, page_len, filters):
|
||||
if not txt: txt = ""
|
||||
|
||||
txt = txt.lower()
|
||||
txt = "%%%s%%" % (txt)
|
||||
|
||||
filters.update({
|
||||
"parent": ("like", txt)
|
||||
})
|
||||
|
||||
doctypes = frappe.db.get_all("DocField", filters=filters, fields=["parent"],
|
||||
order_by="parent asc", distinct=True, as_list=True)
|
||||
|
||||
filters.pop("parent")
|
||||
filters.update({
|
||||
"dt": ("not in", [doctype[0] for doctype in doctypes]),
|
||||
"dt": ("like", txt),
|
||||
})
|
||||
|
||||
_doctypes = frappe.db.get_all("Custom Field", filters=filters, fields=["dt"],
|
||||
order_by="dt asc", as_list=True)
|
||||
|
||||
all_doctypes = doctypes + _doctypes
|
||||
return sorted(all_doctypes, key=lambda item: item[0])
|
||||
|
|
@ -13,6 +13,15 @@ frappe.ui.form.on("Address", {
|
|||
});
|
||||
}
|
||||
}
|
||||
frm.set_query('link_doctype', "links", function() {
|
||||
return {
|
||||
query: "frappe.geo.address_and_contact.filter_dynamic_link_doctypes",
|
||||
filters: {
|
||||
fieldtype: "Link",
|
||||
options: frm.doc.doctype,
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
validate: function(frm) {
|
||||
// clear linked customer / supplier / sales partner on saving...
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue