diff --git a/erpnext/assets/doctype/asset/asset.json b/erpnext/assets/doctype/asset/asset.json index 8e75762a92d..487f67669ff 100644 --- a/erpnext/assets/doctype/asset/asset.json +++ b/erpnext/assets/doctype/asset/asset.json @@ -518,6 +518,7 @@ "read_only": 1 }, { + "default": "0", "depends_on": "eval:doc.docstatus > 0", "fieldname": "additional_asset_cost", "fieldtype": "Currency", @@ -596,7 +597,7 @@ "link_fieldname": "target_asset" } ], - "modified": "2025-05-20 00:44:06.229177", + "modified": "2025-10-23 22:43:33.634452", "modified_by": "Administrator", "module": "Assets", "name": "Asset", @@ -641,4 +642,4 @@ "states": [], "title_field": "asset_name", "track_changes": 1 -} +} \ No newline at end of file diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index e35ebf6ed06..929a60d0e6d 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -69,6 +69,7 @@ class Asset(AccountsController): default_finance_book: DF.Link | None department: DF.Link | None depr_entry_posting_status: DF.Literal["", "Successful", "Failed"] + depreciation_completed: DF.Check depreciation_method: DF.Literal["", "Straight Line", "Double Declining Balance", "Manual"] disposal_date: DF.Date | None finance_books: DF.Table[AssetFinanceBook] @@ -152,7 +153,9 @@ class Asset(AccountsController): ) self.validate_expected_value_after_useful_life() self.set_total_booked_depreciations() - self.total_asset_cost = self.gross_purchase_amount + + def before_save(self): + self.total_asset_cost = self.gross_purchase_amount + self.additional_asset_cost self.status = self.get_status() def on_submit(self): diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index fb5cc130f0b..643fafb74ab 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -878,6 +878,7 @@ class BuyingController(SubcontractingController): "asset_category": item_data.get("asset_category"), "location": row.asset_location, "company": self.company, + "status": "Draft", "supplier": self.supplier, "purchase_date": self.posting_date, "calculate_depreciation": 0, diff --git a/erpnext/patches.txt b/erpnext/patches.txt index 0abf1b42ee4..4e05b974d16 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -422,3 +422,4 @@ execute:frappe.db.set_single_value("Accounts Settings", "fetch_valuation_rate_fo erpnext.patches.v15_0.add_company_payment_gateway_account erpnext.patches.v15_0.update_uae_zero_rated_fetch erpnext.patches.v15_0.update_fieldname_in_accounting_dimension_filter +erpnext.patches.v15_0.set_asset_status_if_not_already_set diff --git a/erpnext/patches/v15_0/set_asset_status_if_not_already_set.py b/erpnext/patches/v15_0/set_asset_status_if_not_already_set.py new file mode 100644 index 00000000000..ac0af708de4 --- /dev/null +++ b/erpnext/patches/v15_0/set_asset_status_if_not_already_set.py @@ -0,0 +1,13 @@ +import frappe +from frappe.query_builder import DocType + + +def execute(): + Asset = DocType("Asset") + + query = ( + frappe.qb.update(Asset) + .set(Asset.status, "Draft") + .where((Asset.docstatus == 0) & ((Asset.status.isnull()) | (Asset.status == ""))) + ) + query.run()