fix: validate asset before repair
(cherry picked from commit c6baa34812)
# Conflicts:
# erpnext/assets/doctype/asset_repair/asset_repair.json
This commit is contained in:
@@ -138,6 +138,7 @@
|
|||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Asset",
|
"label": "Asset",
|
||||||
|
"link_filters": "[[\"Asset\",\"status\",\"not in\",[\"Work In Progress\",\"Capitalized\",\"Fully Depreciated\",\"Sold\",\"Scrapped\",null]]]",
|
||||||
"options": "Asset",
|
"options": "Asset",
|
||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
@@ -248,7 +249,11 @@
|
|||||||
"index_web_pages_for_search": 1,
|
"index_web_pages_for_search": 1,
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"links": [],
|
"links": [],
|
||||||
|
<<<<<<< HEAD
|
||||||
"modified": "2024-06-13 16:14:14.398356",
|
"modified": "2024-06-13 16:14:14.398356",
|
||||||
|
=======
|
||||||
|
"modified": "2025-06-29 22:30:00.589597",
|
||||||
|
>>>>>>> c6baa34812 (fix: validate asset before repair)
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Assets",
|
"module": "Assets",
|
||||||
"name": "Asset Repair",
|
"name": "Asset Repair",
|
||||||
@@ -286,10 +291,15 @@
|
|||||||
"write": 1
|
"write": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
<<<<<<< HEAD
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
|
=======
|
||||||
|
"row_format": "Dynamic",
|
||||||
|
"sort_field": "creation",
|
||||||
|
>>>>>>> c6baa34812 (fix: validate asset before repair)
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"states": [],
|
"states": [],
|
||||||
"title_field": "asset_name",
|
"title_field": "asset_name",
|
||||||
"track_changes": 1,
|
"track_changes": 1,
|
||||||
"track_seen": 1
|
"track_seen": 1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ class AssetRepair(AccountsController):
|
|||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
self.asset_doc = frappe.get_doc("Asset", self.asset)
|
self.asset_doc = frappe.get_doc("Asset", self.asset)
|
||||||
|
self.validate_asset()
|
||||||
self.validate_dates()
|
self.validate_dates()
|
||||||
self.update_status()
|
self.update_status()
|
||||||
|
|
||||||
@@ -60,6 +61,14 @@ class AssetRepair(AccountsController):
|
|||||||
self.set_stock_items_cost()
|
self.set_stock_items_cost()
|
||||||
self.calculate_total_repair_cost()
|
self.calculate_total_repair_cost()
|
||||||
|
|
||||||
|
def validate_asset(self):
|
||||||
|
if self.asset_doc.status in ("Sold", "Fully Depreciated", "Scrapped"):
|
||||||
|
frappe.throw(
|
||||||
|
_("Asset {0} is in {1} status and cannot be repaired.").format(
|
||||||
|
get_link_to_form("Asset", self.asset), self.asset_doc.status
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def validate_dates(self):
|
def validate_dates(self):
|
||||||
if self.completion_date and (self.failure_date > self.completion_date):
|
if self.completion_date and (self.failure_date > self.completion_date):
|
||||||
frappe.throw(
|
frappe.throw(
|
||||||
|
|||||||
Reference in New Issue
Block a user