From 37eaa07192f58314fef022442845af05834be499 Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Tue, 5 Aug 2025 14:16:05 +0530 Subject: [PATCH] fix: validate if journal entry linked to schedule is in draft (cherry picked from commit d5edca202227d83b6694fcbca19d04f82189c184) --- .../asset_depreciation_schedule.py | 6 ++ .../doctype/item_price/test_records.json | 56 ------------------- 2 files changed, 6 insertions(+), 56 deletions(-) delete mode 100644 erpnext/stock/doctype/item_price/test_records.json diff --git a/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py b/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py index bdbf7322757..c6750ee99c4 100644 --- a/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py +++ b/erpnext/assets/doctype/asset_depreciation_schedule/asset_depreciation_schedule.py @@ -128,6 +128,12 @@ class AssetDepreciationSchedule(Document): def cancel_depreciation_entries(self): for d in self.get("depreciation_schedule"): if d.journal_entry: + if d.journal_entry == "Draft": + frappe.throw( + _( + "Cannot cancel Asset Depreciation Schedule {0} as it has a draft journal entry {1}." + ).format(self.name, d.journal_entry) + ) frappe.get_doc("Journal Entry", d.journal_entry).cancel() def on_cancel(self): diff --git a/erpnext/stock/doctype/item_price/test_records.json b/erpnext/stock/doctype/item_price/test_records.json deleted file mode 100644 index afe5ad65b75..00000000000 --- a/erpnext/stock/doctype/item_price/test_records.json +++ /dev/null @@ -1,56 +0,0 @@ -[ - { - "doctype": "Item Price", - "item_code": "_Test Item", - "price_list": "_Test Price List", - "price_list_rate": 100, - "valid_from": "2017-04-18", - "valid_upto": "2017-04-26" - }, - { - "doctype": "Item Price", - "item_code": "_Test Item", - "price_list": "_Test Price List Rest of the World", - "price_list_rate": 10 - }, - { - "doctype": "Item Price", - "item_code": "_Test Item 2", - "price_list": "_Test Price List Rest of the World", - "price_list_rate": 20, - "valid_from": "2017-04-18", - "valid_upto": "2017-04-26", - "customer": "_Test Customer", - "uom": "_Test UOM" - }, - { - "doctype": "Item Price", - "item_code": "_Test Item Home Desktop 100", - "price_list": "_Test Price List", - "price_list_rate": 1000, - "valid_from": "2017-04-10", - "valid_upto": "2017-04-17" - }, - { - "doctype": "Item Price", - "item_code": "_Test Item Home Desktop Manufactured", - "price_list": "_Test Price List", - "price_list_rate": 1000, - "valid_from": "2017-04-10", - "valid_upto": "2017-04-17" - }, - { - "doctype": "Item Price", - "item_code": "_Test Item", - "price_list": "_Test Buying Price List", - "price_list_rate": 100, - "supplier": "_Test Supplier" - }, - { - "doctype": "Item Price", - "item_code": "_Test Item", - "price_list": "_Test Selling Price List", - "price_list_rate": 200, - "customer": "_Test Customer" - } -]