From 579b27d0102c86c42c32b61c2adbd16280d45532 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 24 Feb 2024 17:22:37 +0530 Subject: [PATCH] fix: Cannot read properties of undefined (backport #40081) (#40082) * fix: Cannot read properties of undefined (cherry picked from commit 44ed52c5cfa6a2432769bbb6f3c352aa81025de2) * chore: fix linter issue --------- Co-authored-by: Rohit Waghchaure --- erpnext/public/js/utils.js | 5 ++++- .../doctype/stock_reconciliation/stock_reconciliation.py | 5 +---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/erpnext/public/js/utils.js b/erpnext/public/js/utils.js index 4c76e2a869e..27c7444daf4 100755 --- a/erpnext/public/js/utils.js +++ b/erpnext/public/js/utils.js @@ -40,7 +40,10 @@ $.extend(erpnext, { is_perpetual_inventory_enabled: function(company) { if(company) { - return frappe.get_doc(":Company", company).enable_perpetual_inventory + let company_local = locals[":Company"] && locals[":Company"][company]; + if(company_local) { + return cint(company_local.enable_perpetual_inventory); + } } }, diff --git a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py index 44c2d85b4cc..878af0e22ca 100644 --- a/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py +++ b/erpnext/stock/doctype/stock_reconciliation/stock_reconciliation.py @@ -702,10 +702,7 @@ class StockReconciliation(StockController): if allow_negative_stock: return True - if any( - (d.batch_no and flt(d.qty) == flt(d.current_qty)) - for d in self.items - ): + if any((d.batch_no and flt(d.qty) == flt(d.current_qty)) for d in self.items): allow_negative_stock = True return allow_negative_stock