Commit graph

2701 commits

Author SHA1 Message Date
Ejaaz Khan
42c5c41628
fix: remove default value from time field (#33515) 2025-08-04 12:59:25 +05:30
Akhil Narang
6461592b5d
Merge pull request #32192 from henriquefalconer/fix/field-level-permissions-filtering
fix: Field Level Permissions Not Applied Correctly in frappe.get_list
2025-08-01 16:35:08 +05:30
Akhil Narang
40e6241c1f
Merge pull request #28786 from gbm001/virtual_custom_link_fields
fix: Allow cancellation/rename of doctypes linked by a virtual custom field
2025-08-01 13:44:46 +05:30
Ejaaz Khan
20315bf030
Merge pull request #33446 from maverjk/patch-3
Update base_document.py to resolve error "AttributeError: 'NoneType' object has no attribute 'fieldtype'"
2025-07-31 12:19:53 +05:30
Maverjk Carter
a9562f6182 fix: check if df exist before accessing its properties 2025-07-31 12:04:15 +05:30
Ayush Chaudhari
761751f269
feat: App-Defined Workflow Tasks and Server Scripts on Transition (#33255)
* feat: add workflow task doctypes

* chore: add Workflow Task to Script Type of Server Scripts

* chore: add description for Workflow Tasks

* feat: fetch dotted paths and corresponding names from hooks

* fix: use Select field instead of Autocomplete

* feat: execute tasks in the background on state transition

* fix: throw error when task not found

* fix: naming for transition task set by user

* fix: child table views

* feat: support for server scripts

* chore: comments and description

* fix: change the casing of docevent options

* fix: change test casing

* feat: Add Workflow Transition field to webhooks

* fix: temporarily remove filter

* feat: add webhooks as workflow actions

* test: test execution of synchronous app-defined methods and server scripts

* chore: shorten the description and change the fieldname of the field 'execute_asynchronously' to 'asynchronous'

* test: server script executipn

* fix: add field to UI

* test: change customer to domain

* test: change Customer to Domain

* fix: patch for change in webhook fields

* chore: fetch only used fields in get_all

* fix: don't run test logic in application code 🙂

* test: separate tests for workflow tasks

* Revert "fix: patch for change in webhook fields"

This reverts commit 2e9c51c43ca2b3698991fbe75cc4032368ab174c.

* chore: break into smaller functions

* test: webhooks with workflow tasks

isolate mock responses to test_sync_tasks

* Revert "fix: change test casing"

This reverts commit e2bad96ed01dea0a26d002ea44a1e0175525ed31.

* Revert "fix: change the casing of docevent options"

This reverts commit ddfc81bf775fad74225f25815b8e3e7b255dc9eb.

* fix: webhook casing

* fix: type hint for doc
2025-07-29 11:01:44 +05:30
Raffael Meyer
93b4700899
fix: make labels in error message translatable (#33166) 2025-07-23 18:11:51 +05:30
Akhil Narang
ce4f7f7418
chore: extend function blacklist
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-07-15 17:05:08 +05:30
Akhil Narang
0934d5117d
fix: strengthen subquery check
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-07-15 17:05:08 +05:30
Akhil Narang
8d62e4de01
Revert "fix(db_query): don't allow unclosed quotes"
This reverts commit 6e6150d193.
2025-07-15 17:05:08 +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
zeel prajapati
2afc1582f6
fix: update delete or cancel popup doc links to handle edge cases (#33261) 2025-07-11 17:57:51 +05:30
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
6e6150d193
fix(db_query): don't allow unclosed quotes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-07-07 17:37:06 +05:30
Akhil Narang
41a13a0b07
fix: tighten function check in validate_order_by_and_group_by
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-07-07 17:37:06 +05:30
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
Sagar Vora
406aae7432 chore: fix typo 2025-07-01 19:43:04 +05:30
Sagar Vora
56c7295b8c
perf: commit only if file is imported (#33114) 2025-06-26 15:51:03 +05:30
Faris Ansari
d584b8691d
Merge pull request #32381 from netchampfaris/api-v2-fixes
feat!: Apply permissions in frappe.qb.get_query

Enhancements:
- Supports applying permissions
- Strict input parsing

BREAKING CHANGE:
```py
# Before
frappe.qb.get_query("Task", fields=["sum(is_completed) as count"])

# After
frappe.qb.get_query("Task", fields=[{"SUM": "is_completed", "as": "count"}])
```
2025-06-23 15:50:25 +05:30
Sagar Vora
18dde69ab0 perf: dont serialize caches 2025-06-21 20:54:11 +05:30
Sagar Vora
d9fc9f21f9 perf: faster meta serialisation 2025-06-21 20:12:39 +05:30
Faris Ansari
09ae9ad086 fix: rename method typing 2025-06-18 15:51:13 +05:30
Sagar Vora
b3e1eda4c8
feat: global frappe.in_test flag (#32960)
* feat: global `frappe.in_test` flag

* feat: helper utility to toggle `frappe.in_test`

* fix: use `toggle_test_mode` util

* fix: use `frappe.in_test`

* chore: add comment explaining global `in_test`

* chore: ignore commit replacing flag usage

* test: temporarily disable `frappe.in_test`

this worked earlier because flag was set in werkzeug.local which was separate for API test client

* test: add comment explaining change
2025-06-17 19:19:31 +05:30
Sagar Vora
5210348322 perf: assume key to be table fieldname 2025-06-14 01:49:07 +05:30
Sagar Vora
d79ca9560b chore: revert _init_* methods of document 2025-06-13 22:24:03 +05:30
Ankush Menat
b162c0d6ec
fix!: Don't update document from keyword args (#32898)
Right now if you do this:

`get_doc(doctype, name, field=value)` then it loads document from DB and
then updates field to value.

This is absurd API and I don't think it was ever done intentionally.
2025-06-11 10:15:35 +00:00
Ankush Menat
44681433c9
fix: for_update for lazy loaded documents (#32897)
* fix: Support for_update on lazy documents

* fix: Pop for_update from arguments

* fix: Don't init empty child tables
2025-06-11 10:02:36 +00:00
Sagar Vora
a6b2f7c991
perf: dont override doc.extend (#32890) 2025-06-11 07:26:46 +00:00
Ankush Menat
893a87df86 fix: append and extend without touching attributes 2025-06-11 10:07:48 +05:30
Ankush Menat
10c3c9ea9b fix: Limit getattr to lazy loaded child tables only 2025-06-11 09:55:45 +05:30
Ankush Menat
5c886ef091 test: test internal implementation of LazyChildTable 2025-06-11 09:55:45 +05:30
Ankush Menat
26cf77562c refactor: rearrange checks, inline and cast super args
Co-authored-by: Sagar Vora <16315650+sagarvora@users.noreply.github.com>
2025-06-11 09:55:45 +05:30
Ankush Menat
e69f79e2ae fix: Support dict as key ~ filters
Triggers full fetch indirectly, but there's no other option for this.
2025-06-11 09:55:45 +05:30
Ankush Menat
bebabc3211 fix: Handle support for DocType and virtual
By falling back to original impl with warning.
This is just to allow "fearless usage".
2025-06-11 09:55:45 +05:30
Ankush Menat
49f582ae57 perf: Use lazy doc in a lot more places 2025-06-11 09:55:45 +05:30
Ankush Menat
4d7348d3c0 refactor: avoid code duplication 2025-06-11 09:55:36 +05:30
Ankush Menat
5b8f7bba2b fix: Ensure some basic checks are present to prevent misuse 2025-06-11 09:55:01 +05:30
Ankush Menat
3e4e944ae9 fix: dont db_update what hasn't changed 2025-06-11 09:55:01 +05:30
Ankush Menat
022dbf444d fix: make doc.save work and empty tables 2025-06-11 09:55:01 +05:30
Ankush Menat
eb77ddab69 feat: Lazy loaded documents
https://docs.python.org/3/howto/descriptor.html#invocation-from-an-instance

After first invokation, object's __dict__ will be used... then we can
assume rest of the code works as expected (?)
2025-06-11 09:55:01 +05:30
Ankush Menat
e4bc7f361b
Revert: DocRef (#32866)
- Hardly used anywhere
- Too many hardcoded `__value__` calls without which it's not usable.
- Another type to worry about
2025-06-10 05:20:56 +00:00
Ankush Menat
49a11a0112
Merge pull request #32865 from ankush/check_link_value
fix: Assert type of link field values
2025-06-10 10:22:00 +05:30
Ankush Menat
22827056ce fix: Assert type of link field values 2025-06-10 10:10:51 +05:30
Sagar Vora
7c4b6b3dc1 fix: check permissions as per specified user 2025-06-09 23:31:50 +05:30
Ankush Menat
8c1ee68ce6
perf: Skip order_by in link validation (#32848)
~10% faster because no QB overhead
2025-06-09 07:35:00 +00:00
Ankush Menat
f9ff807e4c
refactor: Rename get_settings -> get_single_value (#32840)
Not all single doctypes are settings, so this is better. Implicit
caching is fine, same is done for `db` APIs on singles. We *should* aim
for 100% correctness of caching implementation, especially for singles.

Thanks to @netchampfaris for the suggestion.
2025-06-09 04:20:29 +00:00
Ankush Menat
caf415f13e
feat: get_settings (#32821)
* feat: get_settings

get_cached_value doesn't work well with singles because you either need
to pass `None` or repeat doctype name... both are awekward and easy to
shoot yourself in foot with.

* refactor: Use cached settings
2025-06-06 18:34:17 +05:30
Ankush Menat
515d9006a4 refactor: simplify link field checks
Also: perf: only fetch docstatus if required

This will let us do index-only scans.
2025-06-05 21:38:12 +05:30
Ankush Menat
4dd21f175e perf: Avoid seprately fetching docstatus 2025-06-05 15:24:29 +05:30