fix(minor): remove "Custom Link" and add patch

This commit is contained in:
Rushabh Mehta 2020-10-19 15:18:14 +05:30
parent 08fe29714d
commit 8707ed1f27
9 changed files with 19 additions and 95 deletions

View file

@ -1,20 +0,0 @@
// Copyright (c) 2020, Frappe Technologies and contributors
// For license information, please see license.txt
frappe.ui.form.on('Custom Link', {
refresh: function(frm) {
frm.set_query("document_type", function () {
return {
filters: {
custom: 0,
istable: 0,
module: ['not in', ["Email", "Core", "Custom", "Event Streaming", "Social", "Data Migration", "Geo", "Desk"]]
}
};
});
frm.add_custom_button(__('Go to {0} List', [frm.doc.document_type]), function() {
frappe.set_route('List', frm.doc.document_type);
});
}
});

View file

@ -1,52 +0,0 @@
{
"actions": [],
"autoname": "field:document_type",
"creation": "2020-04-08 15:16:44.342509",
"doctype": "DocType",
"editable_grid": 1,
"engine": "InnoDB",
"field_order": [
"document_type",
"links"
],
"fields": [
{
"fieldname": "document_type",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Document Type",
"options": "DocType",
"reqd": 1,
"unique": 1
},
{
"fieldname": "links",
"fieldtype": "Table",
"label": "Links",
"options": "DocType Link"
}
],
"links": [],
"modified": "2020-04-08 16:42:59.402671",
"modified_by": "Administrator",
"module": "Custom",
"name": "Custom Link",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1
}

View file

@ -1,10 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020, Frappe Technologies and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
# import frappe
from frappe.model.document import Document
class CustomLink(Document):
pass

View file

@ -1,10 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020, Frappe Technologies and Contributors
# See license.txt
from __future__ import unicode_literals
# import frappe
import unittest
class TestCustomLink(unittest.TestCase):
pass

View file

@ -780,6 +780,9 @@ class Database(object):
"""Returns True if table for given doctype exists."""
return ("tab" + doctype) in self.get_tables()
def has_table(self, doctype):
return self.table_exists(doctype)
def get_tables(self):
tables = frappe.cache().get_value('db_tables')
if not tables:

View file

@ -479,9 +479,6 @@ class Meta(Document):
if hasattr(self, 'links') and self.links:
dashboard_links.extend(self.links)
if frappe.get_all("Custom Link", {"document_type": self.name}):
dashboard_links.extend(frappe.get_doc("Custom Link", self.name).links)
if not data.transactions:
# init groups
data.transactions = []

View file

@ -313,3 +313,4 @@ frappe.patches.v13_0.update_newsletter_content_type
execute:frappe.db.set_value('Website Settings', 'Website Settings', {'navbar_template': 'Standard Navbar', 'footer_template': 'Standard Footer'})
frappe.patches.v13_0.delete_event_producer_and_consumer_keys
frappe.patches.v13_0.web_template_set_module #2020-10-05
frappe.patches.v13_0.remove_custom_link

View file

@ -0,0 +1,15 @@
import frappe
def execute():
'''
Remove the doctype "Custom Link" that was used to add Custom Links to the
Dashboard since this is now managed by Customize Form.
Update `parent` property to the DocType and delte the doctype
'''
if frappe.db.has_table('Custom Link'):
for custom_link in frappe.get_all('Custom Link', ['name', 'document_type']):
frappe.db.sql('update `tabDocType Link` set custom=1, parent=%s where parent=%s',
(custom_link.document_type, custom_link.name))
frappe.delete_doc('DocType', 'Custom Link')