fix(asset capitalization): update asset values using db_set

This commit is contained in:
Navin-S-R
2026-01-26 21:17:06 +05:30
parent c4b135e1a2
commit 74bf61e0c1
2 changed files with 12 additions and 8 deletions

View File

@@ -669,7 +669,10 @@ class Asset(AccountsController):
def get_status(self): def get_status(self):
"""Returns status based on whether it is draft, submitted, scrapped or depreciated""" """Returns status based on whether it is draft, submitted, scrapped or depreciated"""
if self.docstatus == 0: if self.docstatus == 0:
status = "Draft" if self.is_composite_asset:
status = "Work In Progress"
else:
status = "Draft"
elif self.docstatus == 1: elif self.docstatus == 1:
status = "Submitted" status = "Submitted"

View File

@@ -611,14 +611,15 @@ class AssetCapitalization(StockController):
asset_doc = frappe.get_doc("Asset", self.target_asset) asset_doc = frappe.get_doc("Asset", self.target_asset)
if self.docstatus == 2: if self.docstatus == 2:
asset_doc.gross_purchase_amount -= total_target_asset_value gross_purchase_amount = asset_doc.gross_purchase_amount - total_target_asset_value
asset_doc.purchase_amount -= total_target_asset_value purchase_amount = asset_doc.purchase_amount - total_target_asset_value
asset_doc.db_set("total_asset_cost", asset_doc.total_asset_cost - total_target_asset_value)
else: else:
asset_doc.gross_purchase_amount += total_target_asset_value gross_purchase_amount = asset_doc.gross_purchase_amount + total_target_asset_value
asset_doc.purchase_amount += total_target_asset_value purchase_amount = asset_doc.purchase_amount + total_target_asset_value
asset_doc.set_status("Work In Progress")
asset_doc.flags.ignore_validate = True asset_doc.db_set("gross_purchase_amount", gross_purchase_amount)
asset_doc.save() asset_doc.db_set("purchase_amount", purchase_amount)
frappe.msgprint( frappe.msgprint(
_("Asset {0} has been updated. Please set the depreciation details if any and submit it.").format( _("Asset {0} has been updated. Please set the depreciation details if any and submit it.").format(