From 493c8ce04e672972e261f60895a0a5ba4b7c6be8 Mon Sep 17 00:00:00 2001 From: Rohit Waghchaure Date: Mon, 28 Jul 2025 14:56:17 +0530 Subject: [PATCH 1/8] fix: incorrect GL entries (cherry picked from commit 4c273fcc99f5601abbe854ed903abc479e2642c2) # Conflicts: # erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py --- erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index b3b18b088ad..8b13dfc11ce 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -781,8 +781,12 @@ class PurchaseInvoice(BuyingController): self.get_provisional_accounts() for item in self.get("items"): +<<<<<<< HEAD if flt(item.base_net_amount): account_currency = get_account_currency(item.expense_account) +======= + if flt(item.base_net_amount) or (self.get("update_stock") and item.valuation_rate): +>>>>>>> 4c273fcc99 (fix: incorrect GL entries) if item.item_code: frappe.get_cached_value("Item", item.item_code, "asset_category") From a944eaf0544200a514222b2281cc56e8a8d28d53 Mon Sep 17 00:00:00 2001 From: rohitwaghchaure Date: Mon, 28 Jul 2025 16:35:39 +0530 Subject: [PATCH 2/8] chore: fix conflicts --- .../accounts/doctype/purchase_invoice/purchase_invoice.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index 8b13dfc11ce..b0de69ed5cd 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -781,12 +781,8 @@ class PurchaseInvoice(BuyingController): self.get_provisional_accounts() for item in self.get("items"): -<<<<<<< HEAD - if flt(item.base_net_amount): - account_currency = get_account_currency(item.expense_account) -======= if flt(item.base_net_amount) or (self.get("update_stock") and item.valuation_rate): ->>>>>>> 4c273fcc99 (fix: incorrect GL entries) + account_currency = get_account_currency(item.expense_account) if item.item_code: frappe.get_cached_value("Item", item.item_code, "asset_category") From 80ae9820f08d75bfffde08ffcde9fb302dcd2cfa Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Tue, 29 Jul 2025 15:17:30 +0530 Subject: [PATCH 3/8] 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 4/8] 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 5/8] 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 6/8] 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 7/8] 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 From 4d12ae069e8d425748942820388c19af67c6902b Mon Sep 17 00:00:00 2001 From: l0gesh29 Date: Tue, 29 Jul 2025 16:03:10 +0530 Subject: [PATCH 8/8] fix: include empty values in user permission (cherry picked from commit f13d98fc7c77e03761efee90b3ad15e28efb7719) --- erpnext/accounts/utils.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py index 04c95e7e376..8ca34783196 100644 --- a/erpnext/accounts/utils.py +++ b/erpnext/accounts/utils.py @@ -27,6 +27,7 @@ from frappe.utils import ( nowdate, ) from pypika import Order +from pypika.functions import Coalesce from pypika.terms import ExistsCriterion import erpnext @@ -2197,6 +2198,8 @@ def run_ledger_health_checks(): def build_qb_match_conditions(doctype, user=None) -> list: match_filters = build_match_conditions(doctype, user, False) criterion = [] + apply_strict_user_permissions = frappe.get_system_settings("apply_strict_user_permissions") + if match_filters: from frappe import qb @@ -2205,6 +2208,12 @@ def build_qb_match_conditions(doctype, user=None) -> list: for filter in match_filters: for d, names in filter.items(): fieldname = d.lower().replace(" ", "_") - criterion.append(_dt[fieldname].isin(names)) + field = _dt[fieldname] + + cond = field.isin(names) + if not apply_strict_user_permissions: + cond = (Coalesce(field, "") == "") | field.isin(names) + + criterion.append(cond) return criterion