From b89b07d0ffefffe9a7bc0e752131c81edc32e31d Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Wed, 16 Nov 2022 12:16:23 +0530 Subject: [PATCH] fix: Validate for deferred revenue only if sales invoice needs repost --- .../doctype/sales_invoice/sales_invoice.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index 4d7fd8eb8b..62cf0dcfeb 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -571,13 +571,14 @@ class SalesInvoice(SellingController): # validate if deferred revenue is enabled for any item # Don't allow to update the invoice if deferred revenue is enabled - for item in self.get("items"): - if item.enable_deferred_revenue: - frappe.throw( - _( - "Deferred Revenue is enabled for item {0}. You cannot update the invoice after submission." - ).format(item.item_code) - ) + if needs_repost: + for item in self.get("items"): + if item.enable_deferred_revenue: + frappe.throw( + _( + "Deferred Revenue is enabled for item {0}. You cannot update the invoice after submission." + ).format(item.item_code) + ) self.db_set("repost_required", needs_repost)