Commit graph

711 commits

Author SHA1 Message Date
Ankush Menat
a303fbc3ea refactor: Consistent API for list/generator
Returning chunks is not expected API. Why? Because we should always be
able to do:

```python
for doc in frappe.get_docs(...):
    ...
```
2026-04-08 21:31:02 +05:30
Ankush Menat
0d833d658e refactor: use as_iterator instead of as_generator
Because it's already used in `db.sql`. So use consistent naming.
2026-04-08 21:17:25 +05:30
Ankush Menat
0d8ddb5958 Merge branch 'develop' into get-docs 2026-04-08 10:50:31 +05:30
Rohit Waghchaure
1c47e262ae feat: do not round fields 2026-04-07 17:01:51 +05:30
mergify[bot]
1907293ba7
Merge branch 'develop' into get-docs 2026-03-19 11:48:31 +00:00
Shubh Doshi
5092225cbc
fix!: prevent submission of non-submittable doctype (#37009)
* fix: prevent submission of non-submittable doctype

* fix: updated failing test cases to use submittable doctype as required

* refactor: corrected to_docstatus and from_docstatus use

* fix: inherit submittability from parent for child tables

* Revert "fix: inherit submittability from parent for child tables"

This reverts commit ee83ee59b4f0596e2d402a1547e92b131ae49579.

* feat: introduce skip_docstatus_validation flag

* test: add test cases for skip_docstatus_validation flag and docstatus transition of non-submittable doctype
2026-03-12 17:24:21 +05:30
Shrihari Mahabal
7ff564c227 refactor: add support for distinct in get_docs 2026-03-10 14:00:08 +05:30
Shrihari Mahabal
16efc5fa45 chore: add docstring for get_docs 2026-03-09 12:39:56 +05:30
Shrihari Mahabal
1f96971622 feat: get_docs to get multiple instantiated document objects 2026-03-09 12:30:27 +05:30
Suraj Shetty
0c9a55f4e5
Merge pull request #37180 from frappe/32475-attached_to_field-and-folder-fields-not-copied-by-copy_attachments_from_amended_from-function 2026-02-24 15:54:40 +05:30
Aarol D'Souza
c55ff193a6
fix: add type hints to whitelisted methods 3 (#37149)
* fix(apps): add type hints to whitelisted methods

* fix(recorder): add type hints to whitelisted methods

* fix(comments): add type hints to whitelisted methods

* fix(oauth2): add type hints to whitelisted methods

* fix(google_calendar): add type hints to whitelisted methods

* fix(print): add type hints to whitelisted methods

* fix(print_format_builder): add type hints to whitelisted methods

* refactor(network_printer_settings): remove unused args

* fix(document): add type hints to whitelisted methods

* fix(user_settings): add type hints to whitelisted methods

* fix(mapper): add type hints to whitelisted methods

* fix(connected_app): add type hints to whitelisted methods

* fix(google_contacts): add type hints to whitelisted methods

* fix(frappecloud_billing): add type hints to whitelisted methods

* test: rewrite test to fit the strict type check

* fix(social_login_key): add type hints to whitelisted methods

* fix(share): add type hints to whitelisted methods

* fix(webhook): add type hints to whitelisted methods

* fix(workflow): add type hints to whitelisted methods

* fix(workflow main): add type hints to whitelisted methods

* fix(workflow_action): add type hints to whitelisted methods

* fix: flexible type hint

* fix(client): add type hints to whitelisted methods

* fix: fix some of the tighter types

* fix(frappecloud_billing): add str typehint to whitelisted endpoint

* fix: target_doc can be dict/json string

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2026-02-20 06:50:19 +00:00
Sumit Jain
b781fa4ee3 fix: Copy attached_to_field and folder when amending documents 2026-02-18 14:04:58 +05:30
Saqib Ansari
326406d139 fix: avoid false cache misses by ensuring string keys for linked fields 2026-02-17 12:21:19 +05:30
Ayaan Ahmad
614bb642ef refactor(model): simplify prefetch per szufisher's suggestion
- Remove fetch_if_empty check from prefetch phase
- Fetch ALL fields, let base_document.py handle fetch_if_empty
- Avoids DRY violation (same logic in two places)
- Efficiency difference is negligible
2026-01-17 21:29:48 +05:30
Ayaan Ahmad
6197b73d52 fix(model): resolve CI failures in bulk link validation
- Remove cache-check-before-get_all due to recursive_defaultdict edge cases
- Fix ruff-format (multi-line to single-line function call)
- Keep cache population after fetch (addresses maintainer request)
- Preserve core N+1 optimization (bulk fetching via get_all)
2026-01-15 00:21:04 +05:30
Ayaan Ahmad
f37890c31f fix(model): address PR feedback for bulk link validation
- Replace **kwargs with explicit link_value_cache parameter
- Check db.value_cache before get_all for cross-document caching
- Populate db.value_cache after fetching for subsequent documents
- Add sorted() for deterministic cache key matching
- Add isinstance guard for integer docnames (MariaDB)
- Fix linting issues (RUF005, slice spacing)
2026-01-14 22:31:22 +05:30
Ayaan Ahmad
3f86d478e8 perf(validation): optimize link validation with bulk pre-fetching
Implements a _prefetch_link_values method that bulk-fetches all link values
before validation, eliminating N+1 queries when saving documents with many
child rows containing Link/Dynamic Link fields.

Performance Impact:
- 50 child rows: 51 queries → 3 queries (94% reduction)
- 500 child rows: 501 queries → 3 queries (99.4% reduction)

Implementation:
- Uses instance-level cache (garbage collected after validation)
- Sentinel pattern to distinguish cache miss from cached-None
- DB-conditional case handling (MariaDB vs Postgres)
- Chunking at 1000 items for safety
- Backward compatible via **kwargs

Edge Cases Handled:
- Empty name lists (skip query)
- Invalid docname types (preserves existing assertions)
- Virtual doctypes (individual fetch)
- Single doctypes (special handling)
- Dynamic links with doctype changes (cache miss fallback)

Closes #35794
2026-01-12 20:23:54 +05:30
Sagar Vora
fc3a85b93a fix: check perms before validating links 2025-12-29 16:08:27 +05:30
Akhil Narang
f7feeea0a0
fix: ruff "unsafe" fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-22 21:06:48 +05:30
Akhil Narang
8723a2b6ee
fix: ruff fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-22 21:06:48 +05:30
Akhil Narang
ef6a0bffc2
fix: update overloaded get_doc() signature
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-10 16:52:37 +05:30
Akhil Narang
2dcfe07ca8
refactor: make use of check_permission parameter for get_lazy_doc
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-10 16:52:26 +05:30
Akhil Narang
75b91f44ce
feat(get_lazy_doc): add in check_permission parameter
So as to avoid manually calling doc.check_permission() often

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-10 15:40:58 +05:30
Akhil Narang
40ebe6b97a
feat(get_doc): add in check_permissions parameter
If a string, we'll try to check for that permission
Otherwise, we'll just check for `read`
2025-12-09 19:31:14 +05:30
Raffael Meyer
afefeb5dc1
refactor: allow defer_insert in doc.log_error (#34631) 2025-11-07 12:35:50 +01:00
Sagar Vora
a93530e221 Merge branch 'develop' into computed_child_table 2025-10-14 12:53:32 +05:30
Sagar Vora
2a42f0688f chore: update docstring 2025-10-14 12:41:58 +05:30
Sagar Vora
a084f5a2f3 refactor: separate only computed CTs, with new include_computed flag 2025-10-14 12:31:47 +05:30
Sagar Vora
3264fb0f12 fix: missing flag 2025-10-01 12:59:48 +05:30
Sagar Vora
4ba6855fff fix: reset virtual ct cache on save/insert 2025-10-01 12:28:45 +05:30
Sagar Vora
2c9c6c0fd5 fix: correct table_fields references 2025-10-01 12:25:00 +05:30
Ejaaz Khan
335c0d5f36 fix: refactor code and change field type 2025-09-30 12:38:39 +05:30
Ejaaz Khan
e69b607aab feat: add validation to prevent changing values on save 2025-09-19 11:21:40 +05:30
Ejaaz Khan
54b34c9535
Merge branch 'develop' into 32489-role-perm-based-masking 2025-09-17 16:17:30 +05:30
Sagar Vora
dddfe7a02f fix: more foolproof implementation for virtal ct 2025-09-10 13:27:35 +05:30
barredterra
76c04fef27 refactor: move virtual child table check into get_table_fields 2025-09-10 12:07:47 +05:30
Raffael Meyer
ee93a01106
Merge branch 'develop' into computed_child_table 2025-09-10 08:34:36 +02:00
Akhil Narang
5b26db7265
Merge pull request #33685 from AMR-Mannesmann/fix(document)-is_child_table_same-for-new-docs
fix(document): is_child_table_same for new docs
2025-09-02 11:37:06 +05:30
Ejaaz Khan
590fe7e520
Merge branch 'develop' into 32489-role-perm-based-masking 2025-09-02 10:48:06 +05:30
Akhil Narang
719af6e722
Merge pull request #33815 from raizasafeel/fix/translation-trailing-spaces
fix: remove trailing spaces in translatable strings
2025-08-28 16:31:45 +05:30
Raizaaa
aa3bb0e4d7 fix: remove trailing spaces in translatable strings 2025-08-27 13:23:17 +03:00
Mihir Kandoi
c24bda0481 feat: enable non negative validation for Percent type fields 2025-08-26 22:12:23 +05:30
Daniel Radl
99d6e1b381 fix(document): is_child_table_same for new docs 2025-08-20 09:30:26 +00:00
Ejaaz Khan
c2544f9096 refactor: change approach of masking fields 2025-08-18 23:38:18 +05:30
mergify[bot]
c0aa39ee9a
Merge branch 'develop' into 32489-role-perm-based-masking 2025-08-01 05:57:54 +00:00
Raffael Meyer
93b4700899
fix: make labels in error message translatable (#33166) 2025-07-23 18:11:51 +05:30
P-Froggy
00a5fde3ad
feat: Enable _doc_before_save for child documents (#33279)
* Initial Commit

* Apply suggestion from @ankush

* refactor: move unrelated code out of try-except block

* test: child table level value change detection

---------

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
Co-authored-by: Ankush Menat <ankush@frappe.io>
2025-07-11 12:33:00 +00:00
Ankush Menat
b74b8f16b7
refactor: slim down init.py further (#33284)
* refactor: move document utils

* test: rewrite init.py test

The LOC is 1000 less than what it used to be.
2025-07-11 15:34:50 +05:30
Sagar Vora
71428b7dcb
feat: utility to commit certain queries after sending response (#32978)
* feat: utility to commit certain queries after sending response

* fix: add error handling

* refactor: subclass CallbackManager
2025-07-08 05:02:27 +00:00
Akhil Narang
ad948c9b98
Revert "Merge pull request #32327 from akhilnarang/allow-passing-name-in-api"
This reverts commit 1e30db26dc, reversing
changes made to 8da72e91e3.
2025-07-03 17:23:48 +05:30