seitime-frappe/frappe/model
David Arnold 3c1392c8fd
fix: meta signature (#28526)
* fix: meta

* fix: test case

save is required:

1. Fetch values
```python
	def get_invalid_links(self, is_submittable=False):
		"""Return list of invalid links and also update fetch values if not set."""
		...
```

2. Is triggered by
```python

	def _validate_links(self):
		if self.flags.ignore_links or self._action == "cancel":
			return
        ...
```

3. Which is triggered by either `_save` or `insert`

----

`reload` does not trigger link fetch
```python
	def reload(self) -> "Self":
		"""Reload document from database"""
		return self.load_from_db()
```

Neither does the new calling path which does not excempt Document
from caching when initializing meta.

It can be proven that this revert would be an alternative fix. But this
seems design by accident and there's no preceivable reason to excempt
Document args from being cached normally.

diff --git a/frappe/model/meta.py b/frappe/model/meta.py
index c4321f0128..87452c812c 100644
--- a/frappe/model/meta.py
+++ b/frappe/model/meta.py
@@ -70,11 +70,10 @@ def get_meta(doctype: str | dict | DocRef, cached=True) -> "_Meta":
 	Returns:
 	    Meta object for the given doctype.
 	"""
-	if cached and (
-		doctype_name := getattr(doctype, "doctype", doctype)
-		if not isinstance(doctype, dict)
-		else doctype.get("doctype")
-	):
+	if cached and not isinstance(doctype, Document):
+		doctype_name = (
+			getattr(doctype, "doctype", doctype) if not isinstance(doctype, dict) else doctype.get("doctype")
+		)
 		if meta := frappe.cache.hget("doctype_meta", doctype_name):
 			return meta

Therefore, we comply the test.
2024-11-20 04:17:38 +00:00
..
utils docs: docstring on simple singledipatch util (#28437) 2024-11-12 11:52:19 +01:00
__init__.py fix: remove _lt from frappe.model.std_fields (#24662) 2024-02-01 16:05:25 +05:30
base_document.py chore(docref): fix circular imports (#28282) 2024-10-24 22:31:12 +02:00
create_new.py style: re-format with ruff 2024-02-05 18:53:33 +05:30
db_query.py fix: Skip virtual fields in all select queries (#26700) 2024-06-06 09:43:36 +00:00
delete_doc.py fix(delete_doc): Check if submittable before docstatus validation 2024-09-13 18:50:50 +02:00
docfield.py chore!: dead code (#19551) 2023-01-10 18:53:08 +05:30
docstatus.py feat: utility methods for docstatus (#15515) 2022-02-04 07:41:25 +00:00
document.py fix: make read only mode thread safe (#28359) 2024-11-18 15:00:50 +01:00
dynamic_links.py fix: reserved keywords as col name (#25718) 2024-03-29 15:43:33 +05:30
mapper.py fix: make read only mode thread safe (#28359) 2024-11-18 15:00:50 +01:00
meta.py fix: meta signature (#28526) 2024-11-20 04:17:38 +00:00
naming.py fix: Excessive gap locking from hash naming (#28349) 2024-11-01 06:18:22 +00:00
rename_doc.py refactor(rename_doc): also set a 10 hour timeout 2024-10-24 11:25:41 +05:30
sync.py feat: add hook to allow downstream apps to add auto-loading instrumentation for their doctypes (#28479) 2024-11-15 13:04:20 +00:00
trace.py refactor: organize test contextmanagers (#28041) 2024-10-09 02:09:19 +02:00
virtual_doctype.py refactor: migrate virtual doctypes to new API 2024-03-11 18:25:05 +05:30
workflow.py refactor(treewide): enable RUF rules 2024-02-21 16:20:28 +05:30