From d8eddbfd03650592d7c54db99df3a501465227ad Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Thu, 23 Oct 2025 17:41:51 +0530 Subject: [PATCH 1/4] fix: set status to Draft for auto-created assets from Purchase Receipt (cherry picked from commit 20c2cb40d1acba45c9a73eb34f18a8205ad0c38c) # Conflicts: # erpnext/assets/doctype/asset/asset.py # erpnext/patches.txt --- erpnext/assets/doctype/asset/asset.py | 7 +++++++ erpnext/controllers/buying_controller.py | 1 + erpnext/patches.txt | 10 ++++++++++ .../v15_0/set_asset_status_if_not_already_set.py | 13 +++++++++++++ 4 files changed, 31 insertions(+) create mode 100644 erpnext/patches/v15_0/set_asset_status_if_not_already_set.py diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index e35ebf6ed06..0c50b4460e4 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -131,6 +131,13 @@ class Asset(AccountsController): self.set_missing_values() self.validate_gross_and_purchase_amount() self.validate_finance_books() +<<<<<<< HEAD +======= + + def before_save(self): + self.total_asset_cost = self.net_purchase_amount + self.additional_asset_cost + self.status = self.get_status() +>>>>>>> 20c2cb40d1 (fix: set status to Draft for auto-created assets from Purchase Receipt) if not self.split_from: self.prepare_depreciation_data() 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..dc083849dca 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -422,3 +422,13 @@ 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 +<<<<<<< HEAD +======= +erpnext.patches.v16_0.make_workstation_operating_components #1 +erpnext.patches.v16_0.set_reporting_currency +erpnext.patches.v16_0.set_posting_datetime_for_sabb_and_drop_indexes +erpnext.patches.v16_0.update_serial_no_reference_name +erpnext.patches.v16_0.rename_subcontracted_quantity +erpnext.patches.v16_0.add_new_stock_entry_types +erpnext.patches.v15_0.set_asset_status_if_not_already_set +>>>>>>> 20c2cb40d1 (fix: set status to Draft for auto-created assets from Purchase Receipt) 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() From 97147a484df66894e8e29b6e319be8c083eb585e Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Thu, 23 Oct 2025 19:09:30 +0530 Subject: [PATCH 2/4] fix: resolve conflicts --- erpnext/assets/doctype/asset/asset.py | 11 +++-------- erpnext/patches.txt | 9 --------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index 0c50b4460e4..c4c5aad25ad 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -131,13 +131,6 @@ class Asset(AccountsController): self.set_missing_values() self.validate_gross_and_purchase_amount() self.validate_finance_books() -<<<<<<< HEAD -======= - - def before_save(self): - self.total_asset_cost = self.net_purchase_amount + self.additional_asset_cost - self.status = self.get_status() ->>>>>>> 20c2cb40d1 (fix: set status to Draft for auto-created assets from Purchase Receipt) if not self.split_from: self.prepare_depreciation_data() @@ -159,7 +152,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.net_purchase_amount + self.additional_asset_cost self.status = self.get_status() def on_submit(self): diff --git a/erpnext/patches.txt b/erpnext/patches.txt index dc083849dca..4e05b974d16 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -422,13 +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 -<<<<<<< HEAD -======= -erpnext.patches.v16_0.make_workstation_operating_components #1 -erpnext.patches.v16_0.set_reporting_currency -erpnext.patches.v16_0.set_posting_datetime_for_sabb_and_drop_indexes -erpnext.patches.v16_0.update_serial_no_reference_name -erpnext.patches.v16_0.rename_subcontracted_quantity -erpnext.patches.v16_0.add_new_stock_entry_types erpnext.patches.v15_0.set_asset_status_if_not_already_set ->>>>>>> 20c2cb40d1 (fix: set status to Draft for auto-created assets from Purchase Receipt) From a82fa8c26b59ac49f6bf9c431679c70dde288501 Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Thu, 23 Oct 2025 20:45:08 +0530 Subject: [PATCH 3/4] fix: use correct field name --- erpnext/assets/doctype/asset/asset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index c4c5aad25ad..b87b3135944 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -154,7 +154,7 @@ class Asset(AccountsController): self.set_total_booked_depreciations() def before_save(self): - self.total_asset_cost = self.net_purchase_amount + self.additional_asset_cost + self.total_asset_cost = self.gross_purchase_amount + self.additional_asset_cost self.status = self.get_status() def on_submit(self): From ee5e4eccecef33660c037106842fa952d17217d6 Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Thu, 23 Oct 2025 22:51:30 +0530 Subject: [PATCH 4/4] fix: set default value for as zero for additional asset cost --- erpnext/assets/doctype/asset/asset.json | 5 +++-- erpnext/assets/doctype/asset/asset.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) 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 b87b3135944..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]