mirror of
https://github.com/frappe/erpnext.git
synced 2026-04-01 03:12:39 +02:00
fix: Cancel asset capitalisation record on cancellation of asset and vice-versa
(cherry picked from commit efe9f6656f)
# Conflicts:
# erpnext/assets/doctype/asset_capitalization/asset_capitalization.py
This commit is contained in:
@@ -202,8 +202,7 @@
|
|||||||
"fieldname": "purchase_date",
|
"fieldname": "purchase_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"label": "Purchase Date",
|
"label": "Purchase Date",
|
||||||
"mandatory_depends_on": "eval:!doc.is_existing_asset",
|
"mandatory_depends_on": "eval:!doc.is_existing_asset && !doc.is_composite_asset",
|
||||||
"read_only": 1,
|
|
||||||
"read_only_depends_on": "eval:!doc.is_existing_asset && !doc.is_composite_asset"
|
"read_only_depends_on": "eval:!doc.is_existing_asset && !doc.is_composite_asset"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -583,7 +582,7 @@
|
|||||||
"link_fieldname": "target_asset"
|
"link_fieldname": "target_asset"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"modified": "2024-01-05 17:36:53.131512",
|
"modified": "2024-01-15 17:35:49.226603",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Assets",
|
"module": "Assets",
|
||||||
"name": "Asset",
|
"name": "Asset",
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class Asset(AccountsController):
|
|||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
self.validate_cancellation()
|
self.validate_cancellation()
|
||||||
self.cancel_movement_entries()
|
self.cancel_movement_entries()
|
||||||
|
self.cancel_capitalization()
|
||||||
self.delete_depreciation_entries()
|
self.delete_depreciation_entries()
|
||||||
self.set_status()
|
self.set_status()
|
||||||
self.ignore_linked_doctypes = ("GL Entry", "Stock Ledger Entry")
|
self.ignore_linked_doctypes = ("GL Entry", "Stock Ledger Entry")
|
||||||
@@ -831,6 +832,16 @@ class Asset(AccountsController):
|
|||||||
movement = frappe.get_doc("Asset Movement", movement.get("name"))
|
movement = frappe.get_doc("Asset Movement", movement.get("name"))
|
||||||
movement.cancel()
|
movement.cancel()
|
||||||
|
|
||||||
|
def cancel_capitalization(self):
|
||||||
|
asset_capitalization = frappe.db.get_value(
|
||||||
|
"Asset Capitalization",
|
||||||
|
{"target_asset": self.name, "docstatus": 1, "entry_type": "Capitalization"},
|
||||||
|
)
|
||||||
|
|
||||||
|
if asset_capitalization:
|
||||||
|
asset_capitalization = frappe.get_doc("Asset Capitalization", asset_capitalization)
|
||||||
|
asset_capitalization.cancel()
|
||||||
|
|
||||||
def delete_depreciation_entries(self):
|
def delete_depreciation_entries(self):
|
||||||
if self.calculate_depreciation:
|
if self.calculate_depreciation:
|
||||||
for d in self.get("schedules"):
|
for d in self.get("schedules"):
|
||||||
|
|||||||
@@ -72,11 +72,28 @@ class AssetCapitalization(StockController):
|
|||||||
self.update_target_asset()
|
self.update_target_asset()
|
||||||
|
|
||||||
def on_cancel(self):
|
def on_cancel(self):
|
||||||
|
<<<<<<< HEAD
|
||||||
self.ignore_linked_doctypes = ("GL Entry", "Stock Ledger Entry", "Repost Item Valuation")
|
self.ignore_linked_doctypes = ("GL Entry", "Stock Ledger Entry", "Repost Item Valuation")
|
||||||
|
=======
|
||||||
|
self.ignore_linked_doctypes = (
|
||||||
|
"GL Entry",
|
||||||
|
"Stock Ledger Entry",
|
||||||
|
"Repost Item Valuation",
|
||||||
|
"Serial and Batch Bundle",
|
||||||
|
"Asset",
|
||||||
|
)
|
||||||
|
self.cancel_target_asset()
|
||||||
|
>>>>>>> efe9f6656f (fix: Cancel asset capitalisation record on cancellation of asset and vice-versa)
|
||||||
self.update_stock_ledger()
|
self.update_stock_ledger()
|
||||||
self.make_gl_entries()
|
self.make_gl_entries()
|
||||||
self.restore_consumed_asset_items()
|
self.restore_consumed_asset_items()
|
||||||
|
|
||||||
|
def cancel_target_asset(self):
|
||||||
|
if self.entry_type == "Capitalization" and self.target_asset:
|
||||||
|
asset_doc = frappe.get_doc("Asset", self.target_asset)
|
||||||
|
if asset_doc.docstatus == 1:
|
||||||
|
asset_doc.cancel()
|
||||||
|
|
||||||
def set_title(self):
|
def set_title(self):
|
||||||
self.title = self.target_asset_name or self.target_item_name or self.target_item_code
|
self.title = self.target_asset_name or self.target_item_name or self.target_item_code
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user