fix: Cascade deletion for Company (#26923) (#27053)

* fix: Cascade deletion for Company

(cherry picked from commit 2b2572b9b9)

Co-authored-by: Deepesh Garg <42651287+deepeshgarg007@users.noreply.github.com>
This commit is contained in:
Frappe PR Bot
2021-08-20 15:20:50 +05:30
committed by GitHub
parent 52570cc1f9
commit 2fd823ffb6
3 changed files with 24 additions and 0 deletions

View File

@@ -871,3 +871,20 @@ def set_item_tax_from_hsn_code(item):
'tax_category': tax.tax_category,
'valid_from': tax.valid_from
})
def delete_gst_settings_for_company(doc, method):
if doc.country != 'India':
return
gst_settings = frappe.get_doc("GST Settings")
records_to_delete = []
for d in reversed(gst_settings.get('gst_accounts')):
if d.company == doc.name:
records_to_delete.append(d)
for d in records_to_delete:
gst_settings.remove(d)
gst_settings.save()