Merge pull request #16312 from rohitwaghchaure/fix_not_able_to_delete_department
[Fix] Not able to delete department
This commit is contained in:
commit
9c69e40970
@ -1,9 +1,24 @@
|
||||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: GNU General Public License v3. See license.txt
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import unittest
|
||||
|
||||
test_ignore = ["Leave Block List"]
|
||||
class TestDepartment(unittest.TestCase):
|
||||
def test_remove_department_data(self):
|
||||
doc = create_department("Test Department")
|
||||
frappe.delete_doc('Department', doc.name)
|
||||
|
||||
def create_department(department_name, parent_department=None):
|
||||
doc = frappe.get_doc({
|
||||
'doctype': 'Department',
|
||||
'is_group': 0,
|
||||
'parent_department': parent_department,
|
||||
'department_name': department_name,
|
||||
'company': frappe.defaults.get_defaults().company
|
||||
}).insert()
|
||||
|
||||
return doc
|
||||
|
||||
import frappe
|
||||
test_records = frappe.get_test_records('Department')
|
@ -146,8 +146,18 @@ class TransactionBase(StatusUpdater):
|
||||
return ret
|
||||
|
||||
def delete_events(ref_type, ref_name):
|
||||
frappe.delete_doc("Event", frappe.db.sql_list("""select name from `tabEvent`
|
||||
where ref_type=%s and ref_name=%s""", (ref_type, ref_name)), for_reload=True)
|
||||
events = frappe.db.sql_list(""" SELECT
|
||||
distinct `tabEvent`.name
|
||||
from
|
||||
`tabEvent`, `tabEvent Participants`
|
||||
where
|
||||
`tabEvent`.name = `tabEvent Participants`.parent
|
||||
and `tabEvent Participants`.reference_doctype = %s
|
||||
and `tabEvent Participants`.reference_docname = %s
|
||||
""", (ref_type, ref_name)) or []
|
||||
|
||||
if events:
|
||||
frappe.delete_doc("Event", events, for_reload=True)
|
||||
|
||||
def validate_uom_is_integer(doc, uom_field, qty_fields, child_dt=None):
|
||||
if isinstance(qty_fields, string_types):
|
||||
|
Loading…
x
Reference in New Issue
Block a user