fix: avoid duplicate asset activity entries on asset capitalization (#36756)

This commit is contained in:
Anand Baburajan 2023-08-22 15:30:04 +05:30 committed by GitHub
parent 9d29ec8eac
commit 87e2309e8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -96,11 +96,14 @@ class Asset(AccountsController):
"Asset Depreciation Schedules created:<br>{0}<br><br>Please check, edit if needed, and submit the Asset."
).format(asset_depr_schedules_links)
)
if not frappe.db.exists(
{
"doctype": "Asset Activity",
"asset": self.name,
}
if (
not frappe.db.exists(
{
"doctype": "Asset Activity",
"asset": self.name,
}
)
and not self.flags.asset_created_via_asset_capitalization
):
add_asset_activity(self.name, _("Asset created"))

View File

@ -509,6 +509,7 @@ class AssetCapitalization(StockController):
asset_doc.gross_purchase_amount = total_target_asset_value
asset_doc.purchase_receipt_amount = total_target_asset_value
asset_doc.flags.ignore_validate = True
asset_doc.flags.asset_created_via_asset_capitalization = True
asset_doc.insert()
self.target_asset = asset_doc.name