[hotfix] filter doctype if the doctype has subscription field (#11038)

This commit is contained in:
Makarand Bauskar 2017-10-04 14:34:45 +05:30 committed by Nabin Hait
parent 5049edb494
commit eaec4695f7
2 changed files with 23 additions and 1 deletions

View File

@ -3,6 +3,12 @@
frappe.ui.form.on('Subscription', { frappe.ui.form.on('Subscription', {
setup: function(frm) { setup: function(frm) {
frm.fields_dict['reference_doctype'].get_query = function(doc) {
return {
query: "erpnext.accounts.doctype.subscription.subscription.subscription_doctype_query"
};
};
frm.fields_dict['reference_document'].get_query = function() { frm.fields_dict['reference_document'].get_query = function() {
return { return {
filters: { filters: {

View File

@ -277,3 +277,19 @@ def stop_resume_subscription(subscription, status):
doc.save() doc.save()
return doc.status return doc.status
def subscription_doctype_query(doctype, txt, searchfield, start, page_len, filters):
return frappe.db.sql("""select parent from `tabDocField`
where fieldname = 'subscription'
and parent like %(txt)s
order by
if(locate(%(_txt)s, parent), locate(%(_txt)s, parent), 99999),
parent
limit %(start)s, %(page_len)s""".format(**{
'key': searchfield,
}), {
'txt': "%%%s%%" % txt,
'_txt': txt.replace("%", ""),
'start': start,
'page_len': page_len
})