refactor(desk_icon): Remove reference and patches to Desktop Icon

This commit is contained in:
Prateeksha Singh 2019-01-30 11:00:36 +05:30
parent 2c14704398
commit ce27cffaad
14 changed files with 6 additions and 231 deletions

View File

@ -8,9 +8,4 @@ from frappe.model.document import Document
class POSSettings(Document):
def validate(self):
self.set_link_for_pos()
def set_link_for_pos(self):
link = 'pos' if self.use_pos_in_offline_mode else 'point-of-sale'
frappe.db.sql(""" update `tabDesktop Icon` set link = '{0}'
where module_name like '%pos%'""".format(link))
pass

View File

@ -362,7 +362,6 @@ erpnext.patches.v7_1.set_budget_against_as_cost_center
erpnext.patches.v7_1.set_currency_exchange_date
erpnext.patches.v7_1.set_sales_person_status
erpnext.patches.v7_1.repost_stock_for_deleted_bins_for_merging_items
execute:frappe.delete_doc('Desktop Icon', {'module_name': 'Profit and Loss Statment'})
erpnext.patches.v7_2.update_website_for_variant
erpnext.patches.v7_2.update_assessment_modules
erpnext.patches.v7_2.update_doctype_status
@ -545,7 +544,6 @@ erpnext.patches.v11_0.set_update_field_and_value_in_workflow_state
erpnext.patches.v11_0.update_total_qty_field
erpnext.patches.v11_0.update_sales_partner_type
erpnext.patches.v11_0.rename_asset_adjustment_doctype
execute:frappe.db.sql("update `tabDesktop Icon` set type = 'module' where module_name = 'Restaurant'")
erpnext.patches.v11_0.set_salary_component_properties
erpnext.patches.v11_0.set_user_permissions_for_department
erpnext.patches.v11_0.hr_ux_cleanups
@ -564,7 +562,6 @@ erpnext.patches.v11_0.make_job_card
erpnext.patches.v11_0.redesign_healthcare_billing_work_flow
erpnext.patches.v10_0.delete_hub_documents # 12-08-2018
erpnext.patches.v11_0.rename_healthcare_fields
erpnext.patches.v11_0.remove_land_unit_icon
erpnext.patches.v11_0.add_default_dispatch_notification_template
erpnext.patches.v11_0.add_market_segments
erpnext.patches.v11_0.add_sales_stages
@ -574,7 +571,6 @@ execute:frappe.delete_doc_if_exists("Page", "stock-analytics")
execute:frappe.delete_doc_if_exists("Page", "production-analytics")
erpnext.patches.v11_0.ewaybill_fields_gst_india #2018-11-13 #2019-01-09
erpnext.patches.v11_0.drop_column_max_days_allowed
erpnext.patches.v11_0.change_healthcare_desktop_icons
erpnext.patches.v10_0.update_user_image_in_employee
erpnext.patches.v10_0.repost_gle_for_purchase_receipts_with_rejected_items
erpnext.patches.v10_0.allow_operators_in_supplier_scorecard
@ -585,8 +581,4 @@ erpnext.patches.v11_0.rename_additional_salary_component_additional_salary
erpnext.patches.v11_0.renamed_from_to_fields_in_project
erpnext.patches.v11_0.add_permissions_in_gst_settings
erpnext.patches.v11_1.setup_guardian_role
erpnext.patches.v12_0.change_qms_icon
erpnext.patches.v12_0.rename_learn_to_help
erpnext.patches.v12_0.rename_accounts_desktop_icon_to_accounting
erpnext.patches.v12_0.replace_project_list_desktop_icon_with_projects_module_desktop_icon # 09-01-2019
erpnext.patches.v12_0.move_item_tax_to_item_tax_template

View File

@ -1,94 +0,0 @@
from __future__ import unicode_literals
import frappe
from frappe import _
change_icons_map = [
{
"module_name": "Patient",
"color": "#6BE273",
"icon": "fa fa-user",
"doctype": "Patient",
"type": "link",
"link": "List/Patient",
"label": _("Patient")
},
{
"module_name": "Patient Encounter",
"color": "#2ecc71",
"icon": "fa fa-stethoscope",
"doctype": "Patient Encounter",
"type": "link",
"link": "List/Patient Encounter",
"label": _("Patient Encounter"),
},
{
"module_name": "Healthcare Practitioner",
"color": "#2ecc71",
"icon": "fa fa-user-md",
"doctype": "Healthcare Practitioner",
"type": "link",
"link": "List/Healthcare Practitioner",
"label": _("Healthcare Practitioner")
},
{
"module_name": "Patient Appointment",
"color": "#934F92",
"icon": "fa fa-calendar-plus-o",
"doctype": "Patient Appointment",
"type": "link",
"link": "List/Patient Appointment",
"label": _("Patient Appointment")
},
{
"module_name": "Lab Test",
"color": "#7578f6",
"icon": "octicon octicon-beaker",
"doctype": "Lab Test",
"type": "link",
"link": "List/Lab Test",
"label": _("Lab Test")
}
]
def execute():
change_healthcare_desktop_icons()
def change_healthcare_desktop_icons():
doctypes = ["patient", "patient_encounter", "healthcare_practitioner",
"patient_appointment", "lab_test"]
for doctype in doctypes:
frappe.reload_doc("healthcare", "doctype", doctype)
for spec in change_icons_map:
frappe.db.sql("""
delete from `tabDesktop Icon`
where _doctype = '{0}'
""".format(spec['doctype']))
desktop_icon = frappe.new_doc("Desktop Icon")
desktop_icon.hidden = 1
desktop_icon.standard = 1
desktop_icon.icon = spec['icon']
desktop_icon.color = spec['color']
desktop_icon.module_name = spec['module_name']
desktop_icon.label = spec['label']
desktop_icon.app = "erpnext"
desktop_icon.type = spec['type']
desktop_icon._doctype = spec['doctype']
desktop_icon.link = spec['link']
desktop_icon.save(ignore_permissions=True)
frappe.db.sql("""
delete from `tabDesktop Icon`
where module_name = 'Healthcare' and type = 'module'
""")
desktop_icon = frappe.new_doc("Desktop Icon")
desktop_icon.hidden = 1
desktop_icon.standard = 1
desktop_icon.icon = "fa fa-heartbeat"
desktop_icon.color = "#FF888B"
desktop_icon.module_name = "Healthcare"
desktop_icon.label = _("Healthcare")
desktop_icon.app = "erpnext"
desktop_icon.type = 'module'
desktop_icon.save(ignore_permissions=True)

View File

@ -29,7 +29,7 @@ def execute():
if 'land_unit' in frappe.db.get_table_columns('Linked Location'):
rename_field('Linked Location', 'land_unit', 'location')
if not frappe.db.exists("Location", "All Land Units"):
frappe.get_doc({"doctype": "Location", "is_group": True, "location_name": "All Land Units"}).insert(ignore_permissions=True)
@ -52,9 +52,6 @@ def execute():
'rgt': land_unit.get('rgt')
}).insert(ignore_permissions=True)
# frappe.db.sql("""update `tabDesktop Icon` set label='Location', module_name='Location' where label='Land Unit'""")
frappe.db.sql("""update `tabDesktop Icon` set link='List/Location' where link='List/Land Unit'""")
# Delete the Land Unit and Linked Land Unit doctypes
if frappe.db.table_exists('Land Unit'):
frappe.delete_doc('DocType', 'Land Unit', force=1)

View File

@ -11,7 +11,6 @@ def execute():
if 'erpnext_shopify' in frappe.get_installed_apps():
remove_from_installed_apps('erpnext_shopify')
frappe.db.sql('delete from `tabDesktop Icon` where app="erpnext_shopify" ')
frappe.delete_doc("Module Def", 'erpnext_shopify')
frappe.db.commit()

View File

@ -1,19 +0,0 @@
# Copyright (c) 2018, Frappe and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
# imports - module imports
import frappe
def execute():
"""
Delete the "Land Unit" doc if exists from "Desktop Icon" doctype
"""
try:
doc = frappe.get_doc('Desktop Icon', {'standard': 1, 'module_name': 'Land Unit'})
frappe.delete_doc('Desktop Icon', doc.name)
except frappe.ValidationError:
# The 'Land Unit' doc doesn't exist, nothing to do
pass

View File

@ -26,10 +26,3 @@ def execute():
frappe.rename_doc("Report", "Open Production Orders", "Open Work Orders", force=True)
frappe.rename_doc("Report", "Issued Items Against Production Order", "Issued Items Against Work Order", force=True)
frappe.rename_doc("Report", "Production Order Stock Report", "Work Order Stock Report", force=True)
frappe.db.sql("""update `tabDesktop Icon` \
set label='Work Order', module_name='Work Order' \
where label='Production Order'""")
frappe.db.sql("""update `tabDesktop Icon` \
set link='List/Work Order' \
where link='List/Production Order'""")

View File

@ -1,10 +0,0 @@
import frappe
def execute():
qms_icons = frappe.get_all("Desktop Icon", filters={
"module_name": "Quality Management"
})
for icon in qms_icons:
frappe.db.set_value('Desktop Icon', icon.name, 'color', '#1abc9c')
frappe.db.set_value('Desktop Icon', icon.name, 'icon', 'fa fa-check-square-o')

View File

@ -1,10 +0,0 @@
import frappe
from frappe import _
def execute():
accounts_module_icons = frappe.get_all('Desktop Icon', filters={
'module_name': 'Accounts'
}, fields=['name'])
for icon in accounts_module_icons:
frappe.db.set_value('Desktop Icon', icon.name, 'label', _('Accounting'))

View File

@ -1,12 +0,0 @@
import frappe
from frappe import _
def execute():
frappe.db.sql("""
UPDATE `tabDesktop Icon`
SET
`module_name`='Help', `label`=%s
WHERE
`module_name`='Learn' AND
`standard`=1
""", _('Help'))

View File

@ -1,10 +0,0 @@
import frappe
from frappe import _
def execute():
quality_management_module_icons = frappe.get_all('Desktop Icon', filters={
'module_name': 'Quality Management'
}, fields=['name'])
for icon in quality_management_module_icons:
frappe.db.set_value('Desktop Icon', icon.name, 'label', _('Quality'))

View File

@ -1,23 +0,0 @@
import frappe
def execute():
projects_icons = frappe.get_all('Desktop Icon', filters={
'module_name': ['in', ('Project', 'Projects')],
})
fields_to_update = {
'module_name': 'Projects',
'color': '#8e44ad',
'icon': 'octicon octicon-rocket',
'type': 'module',
'link': ''
}
for icon in projects_icons:
icon_doc = frappe.get_doc('Desktop Icon', icon.name)
icon_doc.update(fields_to_update)
try:
icon_doc.save()
except frappe.exceptions.UniqueValidationError:
# delete duplicate icon
icon_doc.delete()

View File

@ -10,21 +10,19 @@ def execute():
frappe.reload_doc('buying', 'doctype', 'request_for_quotation')
if 'schools' in frappe.get_installed_apps():
frappe.db.sql("""delete from `tabDesktop Icon`""")
if not frappe.db.exists('Module Def', 'Schools') and frappe.db.exists('Module Def', 'Academics'):
# 'Schools' module changed to the 'Education'
# frappe.rename_doc("Module Def", "Academics", "Schools")
frappe.rename_doc("Module Def", "Academics", "Education")
remove_from_installed_apps("schools")
def reload_doctypes_for_schools_icons():
# 'Schools' module changed to the 'Education'
# base_path = frappe.get_app_path('erpnext', 'schools', 'doctype')
base_path = frappe.get_app_path('erpnext', 'education', 'doctype')
for doctype in os.listdir(base_path):
if os.path.exists(os.path.join(base_path, doctype, doctype + '.json')) \

View File

@ -14,32 +14,11 @@ def execute():
for report in reports:
if frappe.db.exists("Report", report):
check_and_update_desktop_icon_for_report(report)
check_and_update_auto_email_report(report)
frappe.db.commit()
frappe.delete_doc("Report", report, ignore_permissions=True)
def check_and_update_desktop_icon_for_report(report):
""" delete or update desktop icon"""
desktop_icons = frappe.db.sql_list("""select name from `tabDesktop Icon`
where _report='{0}'""".format(report))
if not desktop_icons:
return
if report == "Monthly Salary Register":
for icon in desktop_icons:
frappe.delete_doc("Desktop Icon", icon)
elif report in ["Customer Addresses And Contacts", "Supplier Addresses And Contacts"]:
frappe.db.sql("""update `tabDesktop Icon` set _report='{value}'
where name in ({docnames})""".format(
value="Addresses And Contacts",
docnames=",".join(["'%s'"%icon for icon in desktop_icons])
)
)
def check_and_update_auto_email_report(report):
""" delete or update auto email report for deprecated report """