fix: asset repair link and improve notes

This commit is contained in:
anandbaburajan 2023-01-16 18:35:40 +05:30
parent 9627b46ee7
commit 61cd0f98fd
5 changed files with 25 additions and 21 deletions

View File

@ -487,7 +487,7 @@
{ {
"group": "Repair", "group": "Repair",
"link_doctype": "Asset Repair", "link_doctype": "Asset Repair",
"link_fieldname": "asset_name" "link_fieldname": "asset"
}, },
{ {
"group": "Value", "group": "Value",
@ -500,7 +500,7 @@
"link_fieldname": "asset" "link_fieldname": "asset"
} }
], ],
"modified": "2022-11-25 12:47:19.689702", "modified": "2023-01-16 12:01:00.502301",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "Assets", "module": "Assets",
"name": "Asset", "name": "Asset",

View File

@ -295,12 +295,12 @@ def reset_depreciation_schedule(asset_doc, date, notes):
asset_doc, notes, date_of_return=date asset_doc, notes, date_of_return=date
) )
modify_depreciation_schedule_for_asset_repairs(asset_doc) modify_depreciation_schedule_for_asset_repairs(asset_doc, notes)
asset_doc.save() asset_doc.save()
def modify_depreciation_schedule_for_asset_repairs(asset): def modify_depreciation_schedule_for_asset_repairs(asset, notes):
asset_repairs = frappe.get_all( asset_repairs = frappe.get_all(
"Asset Repair", filters={"asset": asset.name}, fields=["name", "increase_in_asset_life"] "Asset Repair", filters={"asset": asset.name}, fields=["name", "increase_in_asset_life"]
) )
@ -309,10 +309,6 @@ def modify_depreciation_schedule_for_asset_repairs(asset):
if repair.increase_in_asset_life: if repair.increase_in_asset_life:
asset_repair = frappe.get_doc("Asset Repair", repair.name) asset_repair = frappe.get_doc("Asset Repair", repair.name)
asset_repair.modify_depreciation_schedule() asset_repair.modify_depreciation_schedule()
notes = _("This schedule was created when Asset {0} went through Asset Repair {1}.").format(
get_link_to_form(asset.doctype, asset.name),
get_link_to_form(asset_repair.doctype, asset_repair.name),
)
make_new_active_asset_depr_schedules_and_cancel_current_ones(asset, notes) make_new_active_asset_depr_schedules_and_cancel_current_ones(asset, notes)

View File

@ -430,7 +430,7 @@ class AssetCapitalization(StockController):
if asset.calculate_depreciation: if asset.calculate_depreciation:
notes = _( notes = _(
"This schedule was created when Asset {0} was consumed when Asset Capitalization {1} was submitted." "This schedule was created when Asset {0} was consumed through Asset Capitalization {1}."
).format( ).format(
get_link_to_form(asset.doctype, asset.name), get_link_to_form(self.doctype, self.get("name")) get_link_to_form(asset.doctype, asset.name), get_link_to_form(self.doctype, self.get("name"))
) )
@ -521,7 +521,7 @@ class AssetCapitalization(StockController):
asset_doc.gross_purchase_amount = total_target_asset_value asset_doc.gross_purchase_amount = total_target_asset_value
asset_doc.purchase_receipt_amount = total_target_asset_value asset_doc.purchase_receipt_amount = total_target_asset_value
notes = _( notes = _(
"This schedule was created when target Asset {0} was updated when Asset Capitalization {1} was submitted." "This schedule was created when target Asset {0} was updated through Asset Capitalization {1}."
).format( ).format(
get_link_to_form(asset_doc.doctype, asset_doc.name), get_link_to_form(self.doctype, self.name) get_link_to_form(asset_doc.doctype, asset_doc.name), get_link_to_form(self.doctype, self.name)
) )
@ -537,7 +537,7 @@ class AssetCapitalization(StockController):
if asset.calculate_depreciation: if asset.calculate_depreciation:
reverse_depreciation_entry_made_after_disposal(asset, self.posting_date) reverse_depreciation_entry_made_after_disposal(asset, self.posting_date)
notes = _( notes = _(
"This schedule was created when Asset {0} was restored when Asset Capitalization {1} was cancelled." "This schedule was created when Asset {0} was restored on Asset Capitalization {1}'s cancellation."
).format( ).format(
get_link_to_form(asset.doctype, asset.name), get_link_to_form(self.doctype, self.name) get_link_to_form(asset.doctype, asset.name), get_link_to_form(self.doctype, self.name)
) )

View File

@ -56,8 +56,8 @@ class AssetRepair(AccountsController):
): ):
self.modify_depreciation_schedule() self.modify_depreciation_schedule()
notes = _("This schedule was created when Asset Repair {0} was submitted.").format( notes = _("This schedule was created when Asset {0} was repaired through Asset Repair {1}.").format(
get_link_to_form(self.doctype, self.name) get_link_to_form(self.asset_doc.doctype, self.asset_doc.name), get_link_to_form(self.doctype, self.name)
) )
self.asset_doc.flags.ignore_validate_update_after_submit = True self.asset_doc.flags.ignore_validate_update_after_submit = True
make_new_active_asset_depr_schedules_and_cancel_current_ones(self.asset_doc, notes) make_new_active_asset_depr_schedules_and_cancel_current_ones(self.asset_doc, notes)
@ -80,8 +80,8 @@ class AssetRepair(AccountsController):
): ):
self.revert_depreciation_schedule_on_cancellation() self.revert_depreciation_schedule_on_cancellation()
notes = _("This schedule was created when Asset Repair {0} was cancelled.").format( notes = _("This schedule was created when Asset {0}'s Asset Repair {1} was cancelled.").format(
get_link_to_form(self.doctype, self.name) get_link_to_form(self.asset_doc.doctype, self.asset_doc.name), get_link_to_form(self.doctype, self.name)
) )
self.asset_doc.flags.ignore_validate_update_after_submit = True self.asset_doc.flags.ignore_validate_update_after_submit = True
make_new_active_asset_depr_schedules_and_cancel_current_ones(self.asset_doc, notes) make_new_active_asset_depr_schedules_and_cancel_current_ones(self.asset_doc, notes)

View File

@ -127,12 +127,20 @@ class AssetValueAdjustment(Document):
current_asset_depr_schedule_doc.flags.should_not_cancel_depreciation_entries = True current_asset_depr_schedule_doc.flags.should_not_cancel_depreciation_entries = True
current_asset_depr_schedule_doc.cancel() current_asset_depr_schedule_doc.cancel()
if self.docstatus == 1:
notes = _( notes = _(
"This schedule was created when Asset {0} was adjusted through Asset Value Adjustment {1}." "This schedule was created when Asset {0} was adjusted through Asset Value Adjustment {1}."
).format( ).format(
get_link_to_form(asset.doctype, asset.name), get_link_to_form(asset.doctype, asset.name),
get_link_to_form(self.get("doctype"), self.get("name")), get_link_to_form(self.get("doctype"), self.get("name")),
) )
elif self.docstatus == 2:
notes = _(
"This schedule was created when Asset {0}'s Asset Value Adjustment {1} was cancelled."
).format(
get_link_to_form(asset.doctype, asset.name),
get_link_to_form(self.get("doctype"), self.get("name")),
)
new_asset_depr_schedule_doc.notes = notes new_asset_depr_schedule_doc.notes = notes
new_asset_depr_schedule_doc.insert() new_asset_depr_schedule_doc.insert()