diff --git a/erpnext/assets/doctype/asset/asset.py b/erpnext/assets/doctype/asset/asset.py index 50e2fa997ce412dd902281c10539357a971fd79c..89f21bdd4436f70d0573a2c0ae6f7afd4e072120 100644 --- a/erpnext/assets/doctype/asset/asset.py +++ b/erpnext/assets/doctype/asset/asset.py @@ -129,6 +129,8 @@ class Asset(AccountsController): self.set_missing_values() self.validate_gross_and_purchase_amount() self.validate_finance_books() + + def before_save(self): self.total_asset_cost = self.net_purchase_amount + self.additional_asset_cost self.status = self.get_status() diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py index f17f4af959aea70d27dc03c7b587c764455b7e5f..b13bca3ca362791d70f5be179734f86ad21d6dac 100644 --- a/erpnext/controllers/buying_controller.py +++ b/erpnext/controllers/buying_controller.py @@ -1047,6 +1047,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 2b6af394dbe650f6fed150a7f5d1f9f966486299..0ef51ed474099e4a869cfc4ffd1441ce65089400 100644 --- a/erpnext/patches.txt +++ b/erpnext/patches.txt @@ -479,4 +479,5 @@ 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 \ No newline at end of file +erpnext.patches.v16_0.add_new_stock_entry_types +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 0000000000000000000000000000000000000000..ac0af708de48fb201f65ce054c8624f3e316b6ac --- /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()