Repository: frappe/frappe

Issue:
Document Naming Rule List
### Information about bug

**Based on the posting date, I created a document naming rule list for the purchase receipt. After enabling the document naming rule and creating a purchase receipt, it throws the following error after clicking on save.**

![image](https://user-images.githubusercontent.com/86561623/233557323-ad677423-3fef-4a5d-910f-95dcfa44310b.png)

**Below is the Document Naming Rule.**
![screenshot-20230421-115331](https://user-images.githubusercontent.com/86561623/233557017-030d33e6-64f5-4c73-9a81-c78dc2016af2.png)


### Module

buying, selling

### Version

ERPNext: v13.45.1
Frappe Framework: v13.51.3

### Installation method

None

### Relevant log output / Stack trace / Full Error Message.

_No response_


Discussion:
Hi @SRINIVASREDDY-GANGAVARAPU,

Please check it.

![image](https://user-images.githubusercontent.com/34390782/233568634-ded2ffee-58fb-43b6-95e4-f1a8dbe8614c.png)

Please define the date in YYYY-MM-DD format.
Then reload (Ctrl + Shift + R) and check it.

Thank You!
@Solufyin **Thank You! I have tried your approach but it's not working.**
![screenshot-20230421-132402](https://user-images.githubusercontent.com/86561623/233577270-8963545d-1e5b-4f78-9854-fa403de56ba6.png)

![screenshot-20230421-132347](https://user-images.githubusercontent.com/86561623/233577307-d96f3035-5f28-47fb-a927-5b513f005f3c.png)

I am also facing the same. Anyone help please.
Hi @SRINIVASREDDY-GANGAVARAPU and @Donferarri92,

We do analyze and if found the issue in the code level we will raise the PR.

Thank You!
@Solufyin Thank you for your Support.
Is there any other solution for this issue?
Please Let me know if there is any other solution to this issue.

Resolving patch:
diff --git a/frappe/utils/data.py b/frappe/utils/data.py
--- a/frappe/utils/data.py
+++ b/frappe/utils/data.py
@@ -1530,14 +1530,14 @@ def get_url_to_report_with_filters(name, filters, report_type=None, doctype=None
 	"in": lambda a, b: operator.contains(b, a),
 	"not in": lambda a, b: not operator.contains(b, a),
 	# comparison operators
-	"=": lambda a, b: operator.eq(a, b),
-	"!=": lambda a, b: operator.ne(a, b),
-	">": lambda a, b: operator.gt(a, b),
-	"<": lambda a, b: operator.lt(a, b),
-	">=": lambda a, b: operator.ge(a, b),
-	"<=": lambda a, b: operator.le(a, b),
-	"not None": lambda a, b: a and True or False,
-	"None": lambda a, b: (not a) and True or False,
+	"=": operator.eq,
+	"!=": operator.ne,
+	">": operator.gt,
+	"<": operator.lt,
+	">=": operator.ge,
+	"<=": operator.le,
+	"not None": lambda a, b: a is not None,
+	"None": lambda a, b: a is None,
 }
 
 
@@ -1561,6 +1561,7 @@ def evaluate_filters(doc, filters: Union[Dict, List, Tuple]):
 def compare(val1: Any, condition: str, val2: Any, fieldtype: Optional[str] = None):
 	ret = False
 	if fieldtype:
+		val1 = cast(fieldtype, val1)
 		val2 = cast(fieldtype, val2)
 	if condition in operator_map:
 		ret = operator_map[condition](val1, val2)


Test patch:
diff --git a/frappe/tests/test_utils.py b/frappe/tests/test_utils.py
--- a/frappe/tests/test_utils.py
+++ b/frappe/tests/test_utils.py
@@ -106,6 +106,33 @@ def test_lt_gt(self):
 			)
 		)
 
+	def test_date_time(self):
+		# date fields
+		self.assertTrue(
+			evaluate_filters(
+				{"doctype": "User", "birth_date": "2023-02-28"}, [("User", "birth_date", ">", "01-04-2022")]
+			)
+		)
+		self.assertFalse(
+			evaluate_filters(
+				{"doctype": "User", "birth_date": "2023-02-28"}, [("User", "birth_date", "<", "28-02-2023")]
+			)
+		)
+
+		# datetime fields
+		self.assertTrue(
+			evaluate_filters(
+				{"doctype": "User", "last_active": "2023-02-28 15:14:56"},
+				[("User", "last_active", ">", "01-04-2022 00:00:00")],
+			)
+		)
+		self.assertFalse(
+			evaluate_filters(
+				{"doctype": "User", "last_active": "2023-02-28 15:14:56"},
+				[("User", "last_active", "<", "28-02-2023 00:00:00")],
+			)
+		)
+
 
 class TestMoney(unittest.TestCase):
 	def test_money_in_words(self):