fix: validate if journal entry linked to schedule is in draft

(cherry picked from commit d5edca2022)
This commit is contained in:
khushi8112
2025-08-05 14:16:05 +05:30
committed by Mergify
parent 9d8cb2f57c
commit 37eaa07192
2 changed files with 6 additions and 56 deletions

View File

@@ -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):

View File

@@ -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"
}
]