* chore: patch fixes (cherry picked from commit 8b5b146f6d2720587a16f78a8d47840be8dca2b7) # Conflicts: # erpnext/patches/v13_0/make_homepage_products_website_items.py * fix: remove desktop icons while deleting sales reports (cherry picked from commit 5f72026cb932d01fc827c382747e996a94b441fd) * refactor: dont ignore dangerous exceptions in patches (cherry picked from commit 0aa1ea8aeb7757592616bd491de98c69fef08854) * fix: make patch kinda idempotent with previous query rerunning would've caused all values to become 0. * chore: conflicts * fix: check type before patching Co-authored-by: Saurabh <saurabh6790@gmail.com> Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
parent
b8fbfed096
commit
f469ec87d9
@ -2,14 +2,28 @@ import frappe
|
|||||||
|
|
||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
try:
|
#handle type casting for is_cancelled field
|
||||||
frappe.db.sql("UPDATE `tabStock Ledger Entry` SET is_cancelled = 0 where is_cancelled in ('', NULL, 'No')")
|
module_doctypes = (
|
||||||
frappe.db.sql("UPDATE `tabSerial No` SET is_cancelled = 0 where is_cancelled in ('', NULL, 'No')")
|
('stock', 'Stock Ledger Entry'),
|
||||||
|
('stock', 'Serial No'),
|
||||||
|
('accounts', 'GL Entry')
|
||||||
|
)
|
||||||
|
|
||||||
frappe.db.sql("UPDATE `tabStock Ledger Entry` SET is_cancelled = 1 where is_cancelled = 'Yes'")
|
for module, doctype in module_doctypes:
|
||||||
frappe.db.sql("UPDATE `tabSerial No` SET is_cancelled = 1 where is_cancelled = 'Yes'")
|
if (not frappe.db.has_column(doctype, "is_cancelled")
|
||||||
|
or frappe.db.get_column_type(doctype, "is_cancelled").lower() == "int(1)"
|
||||||
|
):
|
||||||
|
continue
|
||||||
|
|
||||||
frappe.reload_doc("stock", "doctype", "stock_ledger_entry")
|
frappe.db.sql("""
|
||||||
frappe.reload_doc("stock", "doctype", "serial_no")
|
UPDATE `tab{doctype}`
|
||||||
except Exception:
|
SET is_cancelled = 0
|
||||||
pass
|
where is_cancelled in ('', NULL, 'No')"""
|
||||||
|
.format(doctype=doctype))
|
||||||
|
frappe.db.sql("""
|
||||||
|
UPDATE `tab{doctype}`
|
||||||
|
SET is_cancelled = 1
|
||||||
|
where is_cancelled = 'Yes'"""
|
||||||
|
.format(doctype=doctype))
|
||||||
|
|
||||||
|
frappe.reload_doc(module, "doctype", frappe.scrub(doctype))
|
||||||
|
@ -12,6 +12,7 @@ def execute():
|
|||||||
|
|
||||||
for report in reports_to_delete:
|
for report in reports_to_delete:
|
||||||
if frappe.db.exists("Report", report):
|
if frappe.db.exists("Report", report):
|
||||||
|
delete_links_from_desktop_icons(report)
|
||||||
delete_auto_email_reports(report)
|
delete_auto_email_reports(report)
|
||||||
check_and_delete_linked_reports(report)
|
check_and_delete_linked_reports(report)
|
||||||
|
|
||||||
@ -22,3 +23,9 @@ def delete_auto_email_reports(report):
|
|||||||
auto_email_reports = frappe.db.get_values("Auto Email Report", {"report": report}, ["name"])
|
auto_email_reports = frappe.db.get_values("Auto Email Report", {"report": report}, ["name"])
|
||||||
for auto_email_report in auto_email_reports:
|
for auto_email_report in auto_email_reports:
|
||||||
frappe.delete_doc("Auto Email Report", auto_email_report[0])
|
frappe.delete_doc("Auto Email Report", auto_email_report[0])
|
||||||
|
|
||||||
|
def delete_links_from_desktop_icons(report):
|
||||||
|
""" Check for one or multiple Desktop Icons and delete """
|
||||||
|
desktop_icons = frappe.db.get_values("Desktop Icon", {"_report": report}, ["name"])
|
||||||
|
for desktop_icon in desktop_icons:
|
||||||
|
frappe.delete_doc("Desktop Icon", desktop_icon[0])
|
@ -5,6 +5,9 @@ from erpnext.regional.india.setup import make_custom_fields
|
|||||||
|
|
||||||
def execute():
|
def execute():
|
||||||
if frappe.get_all('Company', filters = {'country': 'India'}):
|
if frappe.get_all('Company', filters = {'country': 'India'}):
|
||||||
|
frappe.reload_doc('accounts', 'doctype', 'POS Invoice')
|
||||||
|
frappe.reload_doc('accounts', 'doctype', 'POS Invoice Item')
|
||||||
|
|
||||||
make_custom_fields()
|
make_custom_fields()
|
||||||
|
|
||||||
if not frappe.db.exists('Party Type', 'Donor'):
|
if not frappe.db.exists('Party Type', 'Donor'):
|
||||||
|
@ -37,4 +37,4 @@ def execute():
|
|||||||
jc.production_item = wo.production_item, jc.item_name = wo.item_name
|
jc.production_item = wo.production_item, jc.item_name = wo.item_name
|
||||||
WHERE
|
WHERE
|
||||||
jc.work_order = wo.name and IFNULL(jc.production_item, "") = ""
|
jc.work_order = wo.name and IFNULL(jc.production_item, "") = ""
|
||||||
""")
|
""")
|
Loading…
x
Reference in New Issue
Block a user