Commit graph

2530 commits

Author SHA1 Message Date
David Arnold
75377aaaf5
refactor(typing): type filters (#28218)
* chore(typing): type filters

* chore(typing): type filters for get_list et al

* fix: dashboard chart filter expression

* test: fix case with new-style right hand object to equality check

* chore: place new typed filter under typing verification

* chore: remove debug print statment

* chore: inverse logic of type guard

* fix: add float to filter value types

* chore: clarify value naming
2024-12-04 23:18:53 +00:00
Akhil Narang
84ef6ec677
refactor: fixup with ruff 0.8.1
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-12-04 13:18:04 +05:30
Sumit Bhanushali
e967b37c78 fix: workflow should also support queue_in_background
(cherry picked from commit 3d51e725c6bd89af4cd215a858ab25725b24c847)
2024-12-03 07:02:27 +00:00
Faris Ansari
f7c005dc09
Merge pull request #28629 from netchampfaris/autoincrement-renaming
fix: allow renaming autoincrement documents
2024-12-02 14:25:05 +05:30
Faris Ansari
94b051e05f fix: cast name in UserSettings query 2024-12-02 13:29:36 +05:30
Faris Ansari
46022ff257 chore: formatting 2024-11-30 16:08:10 +05:30
Faris Ansari
e76c33cdbc fix: cast values for renaming autoincrement documents
- cast `name` values to integer
- cast `link_field` values to string
2024-11-30 14:59:59 +05:30
Akhil Narang
88f553e37a
Merge pull request #28617 from aerele/validate-amended-from-record-
feat: validate amended from record docstatus
2024-11-29 17:22:45 +05:30
l0gesh29
35d8ff40ec feat: validate amended from record docstatus 2024-11-28 17:04:44 +05:30
Akhil Narang
a70973b0c5
fix(rename): check for permissions for merged document as well
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-11-28 15:59:45 +05:30
Sumit Bhanushali
87ef74bb7e fix(DocRename): on rename ignore link validation when updating values in single doctype 2024-11-22 16:30:32 +05:30
Raffael Meyer
9208b58b6f
refactor: use doc.check_permission (#28317)
* refactor: use `doc.check_permission`

* refactor(delete_doc): check_permission_and_not_submitted
2024-11-22 10:41:24 +01:00
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
David Arnold
15d122025f
feat: get_meta can derive meta from dict (#28525) 2024-11-20 01:36:04 +00:00
David Arnold
6f35a554a5
fix: make read only mode thread safe (#28359)
* fix: Apply read_only_method decorator to Document methods

* fix: update tests for read-only document context manager

* refactor: place mappers into read-only mode

Reapply "refactor: place mappers into read-only mode"

This reverts commit a8208d57069c63f0982bf2881bcad28a4b349f3c.

read-only mode is now thread safe
2024-11-18 15:00:50 +01:00
David Arnold
67f2b056b4
feat: add hook to allow downstream apps to add auto-loading instrumentation for their doctypes (#28479) 2024-11-15 13:04:20 +00:00
David Arnold
3fe8a0d35e
docs: docstring on simple singledipatch util (#28437) 2024-11-12 11:52:19 +01:00
Raffael Meyer
69a8a362f6
fix: improve permission error message (#28292) 2024-11-06 12:28:09 +01:00
Ankush Menat
16407a50ec
fix: Excessive gap locking from hash naming (#28349)
Because of large common prefix hash naming becomes "too sequential" when
doing a lot of concurrent writes.

I don't know a good tradeoff between both use cases:
1. Lots of reads - prefers large shared prefix.
2. Lots of writes - prefers small shared prefix.

But as of now this punishes writes too badly in form of excessive
locking. Until a better fix is found, it's better to keep it prefix free.

---

A better fix would be a tradeoff of between these two:

1. Reads - temporal locality should result in spatial locality on disk.
2. Writes - temporal locality should NOT result in spatial locality.

temporal locality = data inserted around same time
spatial locality = data sits next to each other in DB pages.

This can be achieved by adding a small request/job specific part to
prefix so each concurrent request has it's own different locality when
writing data.
2024-11-01 06:18:22 +00:00
David Arnold
fcae6050f0
Revert "refactor: place mappers into read-only mode" (#28347)
This reverts commit 583e4bf3e7b4a1a9930707515b16dba704309c55.
2024-10-31 20:35:28 +00:00
Raffael Meyer
73a04e9a5d
refactor(mapper): use doc.check_permission (#28316) 2024-10-31 19:52:47 +01:00
David Arnold
d5fd8d7c20
chore(docref): fix circular imports (#28282) 2024-10-24 22:31:12 +02:00
Akhil Narang
97bb23960d
refactor(rename_doc): also set a 10 hour timeout
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-10-24 11:25:41 +05:30
Akhil Narang
d5a73683db
refactor(rename): use long queue by default
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-10-23 17:38:37 +05:30
David Arnold
90e44d950e
fix: hashable is enough to serve as (composite) cache key (#28189) 2024-10-19 23:19:48 +02:00
David Arnold
2abba7b51b
fix: don't force values into the string type (#28185) 2024-10-19 19:00:25 +00:00
David Arnold
7348572af8
feat: docref identifier / proxy (#27973)
* feat: add DocRef

* feat: Add comprehensive test cases for DocRef functionality

* chore(db): add field type hints

* fix: ensure document stringer fulfills the DocRef contract
2024-10-19 09:40:26 +05:30
Gavin D'souza
b1d96dd532
refactor: Move children load db into separate method
Signed-off-by: Gavin D'souza <gavin.dsouza@switchup.de>
2024-10-17 19:18:59 +02:00
David Arnold
97c25594dc
refactor: place mappers into read-only mode (#27956) 2024-10-13 16:06:01 +02:00
David Arnold
0204db6547
chore: move to use new test record api (#28105) 2024-10-12 23:13:41 +00:00
Sagar Vora
30abcf66e8
fix: escape backslashes in repl to prevent syntax errors (#28052) 2024-10-09 14:28:14 +05:30
David Arnold
95950c8d81
refactor: organize test contextmanagers (#28041)
* refactor: prefer staticmethod decorator

* refactor: add cm register utility and keep cms in one file

* refactor: enter safe_exec enabled context (treewide)

* refactor: move trace fields to the other test context managers

* chore: marke all test_runner functions for deprecation

* chore: mark some tests.utils functions for deprecation (moved)

* chore: mark traced_field_conext for deprecation (moved)

* chore: placate semgrep in dumpster

* fix: show deprecation warnings per module in tests (incl. from dumpster)

* chore: remove use of deprecated functions from tests
2024-10-09 02:09:19 +02:00
David Arnold
5d3697500e
refactor: improve maintainability with a simple dispatcher (#27975)
* refactor: improve maintainability with a simple dispatcher

* refactor: improve maintainability with a init dispatcher on Document

* refactor: improve maintainability with an init dispatcher on meta
2024-10-06 16:56:40 +00:00
Mohamud Amin Ali
e6223b04fc
refactor: Explicit feedback to timestamp mismatch errror
Not necessarily a needed improvement but it adds explicitness to the feedback.

fix: text order

fix: type
2024-10-04 11:46:39 +02:00
David Arnold
c441be55e6
Merge pull request #27955 from blaggacao/feat/add-read-only-document-context
feat: add read only document mode
2024-10-04 00:12:08 +02:00
David
d05f70f9ba
fix: return correct types for owner and modified_by 2024-10-03 23:25:11 +02:00
David
1c4a0fe54f
feat: add read only document mode 2024-10-02 12:02:52 +02:00
Akhil Narang
22a64461aa
Merge pull request #27921 from barredterra/redirect-after-rename
feat: redirect to new record after rename
2024-10-01 15:53:37 +05:30
David Arnold
6ab44a883b
Merge pull request #27870 from blaggacao/feat/custom-section-and-column-placement
feat: improve placement for custom field sections and columns
2024-09-30 13:11:11 +02:00
Sumit Bhanushali
847dd62ec0 feat: permission log 2024-09-30 14:54:32 +05:30
barredterra
49c66c4d9f feat: redirect to new form if it has been renamed 2024-09-27 18:30:35 +02:00
David
2de43f7797
feat: improve placement for custom field sections and columns 2024-09-26 12:54:30 +02:00
Akhil Narang
8260574f0d
Merge pull request #27659 from barredterra/mandatory-field-msg
fix: message for missing mandatory fields
2024-09-24 20:37:48 +05:30
Raffael Meyer
c73734715d
fix: update message needed for test
Co-authored-by: Akhil Narang <me@akhilnarang.dev>
2024-09-24 16:28:04 +02:00
Raffael Meyer
b91cacdd18
feat!: enhance Language to become more of a Locale (#27178) 2024-09-21 16:02:58 +02:00
Akhil Narang
578c9c1864
Merge pull request #27799 from ruthra-kumar/renumber_idx_on_remove
fix: re-number idx on child table row removal
2024-09-17 14:32:39 +05:30
ruthra kumar
2b8df89d55 fix: re-number idx on child table row removal 2024-09-17 14:19:57 +05:30
Gavin D'souza
15f6fcdf3e
fix(delete_doc): Check if submittable before docstatus validation 2024-09-13 18:50:50 +02:00
Akhil Narang
a87de09e79
fix(rename_doc): check permissions for the specific document
A user can have access to write to a document without having access to the whole doctype

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-09-13 11:16:53 +05:30
David
fe73c9f1aa
feat: add value tracer for test debugging 2024-09-05 21:58:19 +02:00