From 13109aef9df5feb0088d0b7fa902bd7720f7df95 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Mon, 3 Sep 2018 12:17:57 +0530 Subject: [PATCH] fix: validate only if service stop date --- erpnext/accounts/doctype/sales_invoice/sales_invoice.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index a45b953cddc..53d0fda1fce 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -546,11 +546,12 @@ class SalesInvoice(SellingController): for item in self.items: if item.enable_deferred_revenue: - if date_diff(item.service_stop_date, item.service_start_date) < 0: - frappe.throw(_("Service Stop Date cannot be before Service Start Date")) + if item.service_stop_date: + if date_diff(item.service_stop_date, item.service_start_date) < 0: + frappe.throw(_("Service Stop Date cannot be before Service Start Date")) - if date_diff(item.service_stop_date, item.service_end_date) > 0: - frappe.throw(_("Service Stop Date cannot be after Service End Date")) + if date_diff(item.service_stop_date, item.service_end_date) > 0: + frappe.throw(_("Service Stop Date cannot be after Service End Date")) if old_stop_dates and old_stop_dates[item.name] and item.service_stop_date!=old_stop_dates[item.name]: frappe.throw(_("Cannot change Service Stop Date for item in row {0}".format(item.idx)))