From 80ae9820f08d75bfffde08ffcde9fb302dcd2cfa Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Tue, 29 Jul 2025 15:17:30 +0530 Subject: [PATCH 1/5] fix: post gl entry on completion date of asset repair (cherry picked from commit 5a82b723c29acbdfdc57626aa4c3b52eb5bf321f) # Conflicts: # erpnext/assets/doctype/asset_repair/asset_repair.json # erpnext/assets/doctype/asset_repair/asset_repair.py # erpnext/assets/doctype/asset_repair/test_asset_repair.py --- .../doctype/asset_repair/asset_repair.json | 6 +++++ .../doctype/asset_repair/asset_repair.py | 25 ++++++++++++++++--- .../doctype/asset_repair/test_asset_repair.py | 5 ++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.json b/erpnext/assets/doctype/asset_repair/asset_repair.json index accb5bf54b5..ef65296c728 100644 --- a/erpnext/assets/doctype/asset_repair/asset_repair.json +++ b/erpnext/assets/doctype/asset_repair/asset_repair.json @@ -76,6 +76,7 @@ "fieldname": "completion_date", "fieldtype": "Datetime", "label": "Completion Date", + "mandatory_depends_on": "eval:doc.repair_status==\"Completed\"", "no_copy": 1 }, { @@ -264,7 +265,11 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], +<<<<<<< HEAD "modified": "2022-08-16 15:55:25.023471", +======= + "modified": "2025-07-29 15:14:34.044564", +>>>>>>> 5a82b723c2 (fix: post gl entry on completion date of asset repair) "modified_by": "Administrator", "module": "Assets", "name": "Asset Repair", @@ -302,6 +307,7 @@ "write": 1 } ], + "row_format": "Dynamic", "sort_field": "modified", "sort_order": "DESC", "states": [], diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.py b/erpnext/assets/doctype/asset_repair/asset_repair.py index da933c96057..89e6f4a455f 100644 --- a/erpnext/assets/doctype/asset_repair/asset_repair.py +++ b/erpnext/assets/doctype/asset_repair/asset_repair.py @@ -20,6 +20,23 @@ class AssetRepair(AccountsController): self.set_stock_items_cost() self.calculate_total_repair_cost() +<<<<<<< HEAD +======= + 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): + if self.completion_date and (getdate(self.failure_date) > getdate(self.completion_date)): + frappe.throw( + _("Completion Date can not be before Failure Date. Please adjust the dates accordingly.") + ) + +>>>>>>> 5a82b723c2 (fix: post gl entry on completion date of asset repair) def update_status(self): if self.repair_status == "Pending": frappe.db.set_value("Asset", self.asset, "status", "Out of Order") @@ -195,7 +212,7 @@ class AssetRepair(AccountsController): "voucher_type": self.doctype, "voucher_no": self.name, "cost_center": self.cost_center, - "posting_date": getdate(), + "posting_date": self.completion_date, "against_voucher_type": "Purchase Invoice", "against_voucher": self.purchase_invoice, "company": self.company, @@ -214,7 +231,7 @@ class AssetRepair(AccountsController): "voucher_type": self.doctype, "voucher_no": self.name, "cost_center": self.cost_center, - "posting_date": getdate(), + "posting_date": self.completion_date, "company": self.company, }, item=self, @@ -248,7 +265,7 @@ class AssetRepair(AccountsController): "voucher_type": self.doctype, "voucher_no": self.name, "cost_center": self.cost_center, - "posting_date": getdate(), + "posting_date": self.completion_date, "company": self.company, }, item=self, @@ -265,7 +282,7 @@ class AssetRepair(AccountsController): "voucher_type": self.doctype, "voucher_no": self.name, "cost_center": self.cost_center, - "posting_date": getdate(), + "posting_date": self.completion_date, "against_voucher_type": "Stock Entry", "against_voucher": self.stock_entry, "company": self.company, diff --git a/erpnext/assets/doctype/asset_repair/test_asset_repair.py b/erpnext/assets/doctype/asset_repair/test_asset_repair.py index 274c1768179..c7bad5ee2ed 100644 --- a/erpnext/assets/doctype/asset_repair/test_asset_repair.py +++ b/erpnext/assets/doctype/asset_repair/test_asset_repair.py @@ -4,7 +4,11 @@ import unittest import frappe +<<<<<<< HEAD from frappe.utils import flt, nowdate +======= +from frappe.utils import add_days, add_months, flt, get_first_day, nowdate, nowtime, today +>>>>>>> 5a82b723c2 (fix: post gl entry on completion date of asset repair) from erpnext.assets.doctype.asset.asset import ( get_asset_account, @@ -288,6 +292,7 @@ def create_asset_repair(**args): if args.submit: asset_repair.repair_status = "Completed" + asset_repair.completion_date = add_days(args.failure_date, 1) asset_repair.cost_center = frappe.db.get_value("Company", asset.company, "cost_center") if args.stock_consumption: From 4524c74968873fdcfa455955a1b2b6580548aa47 Mon Sep 17 00:00:00 2001 From: Khushi Rawat <142375893+khushi8112@users.noreply.github.com> Date: Tue, 29 Jul 2025 15:39:10 +0530 Subject: [PATCH 2/5] fix: resolved conflicts --- erpnext/assets/doctype/asset_repair/asset_repair.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.json b/erpnext/assets/doctype/asset_repair/asset_repair.json index ef65296c728..f4fd40589c4 100644 --- a/erpnext/assets/doctype/asset_repair/asset_repair.json +++ b/erpnext/assets/doctype/asset_repair/asset_repair.json @@ -265,11 +265,7 @@ "index_web_pages_for_search": 1, "is_submittable": 1, "links": [], -<<<<<<< HEAD - "modified": "2022-08-16 15:55:25.023471", -======= "modified": "2025-07-29 15:14:34.044564", ->>>>>>> 5a82b723c2 (fix: post gl entry on completion date of asset repair) "modified_by": "Administrator", "module": "Assets", "name": "Asset Repair", @@ -314,4 +310,4 @@ "title_field": "asset_name", "track_changes": 1, "track_seen": 1 -} \ No newline at end of file +} From 59ac7aeb23e9ee8c4d42abd968306b52fa239d5d Mon Sep 17 00:00:00 2001 From: Khushi Rawat <142375893+khushi8112@users.noreply.github.com> Date: Tue, 29 Jul 2025 15:41:20 +0530 Subject: [PATCH 3/5] chore: resolved conflicts --- erpnext/assets/doctype/asset_repair/asset_repair.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.py b/erpnext/assets/doctype/asset_repair/asset_repair.py index 89e6f4a455f..6c90489e61a 100644 --- a/erpnext/assets/doctype/asset_repair/asset_repair.py +++ b/erpnext/assets/doctype/asset_repair/asset_repair.py @@ -20,8 +20,6 @@ class AssetRepair(AccountsController): self.set_stock_items_cost() self.calculate_total_repair_cost() -<<<<<<< HEAD -======= def validate_asset(self): if self.asset_doc.status in ("Sold", "Fully Depreciated", "Scrapped"): frappe.throw( @@ -36,7 +34,6 @@ class AssetRepair(AccountsController): _("Completion Date can not be before Failure Date. Please adjust the dates accordingly.") ) ->>>>>>> 5a82b723c2 (fix: post gl entry on completion date of asset repair) def update_status(self): if self.repair_status == "Pending": frappe.db.set_value("Asset", self.asset, "status", "Out of Order") From 6cdc7811b889dbba638873dc2b80bac0401433df Mon Sep 17 00:00:00 2001 From: Khushi Rawat <142375893+khushi8112@users.noreply.github.com> Date: Tue, 29 Jul 2025 15:42:00 +0530 Subject: [PATCH 4/5] fix: resolved conflicts --- erpnext/assets/doctype/asset_repair/test_asset_repair.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/erpnext/assets/doctype/asset_repair/test_asset_repair.py b/erpnext/assets/doctype/asset_repair/test_asset_repair.py index c7bad5ee2ed..307faa41a1b 100644 --- a/erpnext/assets/doctype/asset_repair/test_asset_repair.py +++ b/erpnext/assets/doctype/asset_repair/test_asset_repair.py @@ -4,11 +4,7 @@ import unittest import frappe -<<<<<<< HEAD -from frappe.utils import flt, nowdate -======= -from frappe.utils import add_days, add_months, flt, get_first_day, nowdate, nowtime, today ->>>>>>> 5a82b723c2 (fix: post gl entry on completion date of asset repair) +from frappe.utils import add_days, flt, nowdate from erpnext.assets.doctype.asset.asset import ( get_asset_account, From b43fbf2a7df65092dfed2b35e98ff9a7ba899adb Mon Sep 17 00:00:00 2001 From: Khushi Rawat <142375893+khushi8112@users.noreply.github.com> Date: Tue, 29 Jul 2025 15:48:41 +0530 Subject: [PATCH 5/5] fix: import get_link_to_form from utils --- erpnext/assets/doctype/asset_repair/asset_repair.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erpnext/assets/doctype/asset_repair/asset_repair.py b/erpnext/assets/doctype/asset_repair/asset_repair.py index 6c90489e61a..e3342e5c16a 100644 --- a/erpnext/assets/doctype/asset_repair/asset_repair.py +++ b/erpnext/assets/doctype/asset_repair/asset_repair.py @@ -3,7 +3,7 @@ import frappe from frappe import _ -from frappe.utils import add_months, cint, flt, getdate, time_diff_in_hours +from frappe.utils import add_months, cint, flt, get_link_to_form, getdate, time_diff_in_hours import erpnext from erpnext.accounts.general_ledger import make_gl_entries