From 184491bbbe979899a4e9a6c9a18f0f945d1d7bcf Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Mon, 15 Jan 2018 14:18:53 +0530 Subject: [PATCH] [hotfix] Validate posting_time (#12484) --- erpnext/utilities/transaction_base.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/erpnext/utilities/transaction_base.py b/erpnext/utilities/transaction_base.py index 65310aa9e30..01125f997bd 100644 --- a/erpnext/utilities/transaction_base.py +++ b/erpnext/utilities/transaction_base.py @@ -5,7 +5,7 @@ from __future__ import unicode_literals import frappe import frappe.share from frappe import _ -from frappe.utils import cstr, now_datetime, cint, flt +from frappe.utils import cstr, now_datetime, cint, flt, get_time from erpnext.controllers.status_updater import StatusUpdater class UOMMustBeIntegerError(frappe.ValidationError): pass @@ -26,6 +26,11 @@ class TransactionBase(StatusUpdater): now = now_datetime() self.posting_date = now.strftime('%Y-%m-%d') self.posting_time = now.strftime('%H:%M:%S.%f') + else: + try: + get_time(self.posting_time) + except ValueError: + frappe.throw(_('Invalid Posting Time')) def add_calendar_event(self, opts, force=False): if cstr(self.contact_by) != cstr(self._prev.contact_by) or \