Commit graph

66 commits

Author SHA1 Message Date
UmakanthKaspa
6bb584f725
feat: Support dynamic expressions in workflow update_value field (#34354)
* feat: add dynamic value support for workflow update_value field

* feat: add evaluate as expression checkbox to workflow states

* test: add tests for dynamic workflow update_value expression

* fix: use description field instead of sender in workflow
  tests

* chore: fix typo

---------

Co-authored-by: UmakanthKaspa <kaspaumakanth1999@gmail.com>
Co-authored-by: Akhil Narang <me@akhilnarang.dev>
2025-12-30 15:58:43 +05:30
Akhil Narang
e859b1d312
fix: disable UP040, revert some instances to TypeAlias
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-23 13:12:04 +05:30
Akhil Narang
8723a2b6ee
fix: ruff fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-12-22 21:06:48 +05:30
sokumon
1c68d37f89 fix: show bulk approve as failed when message has error 2025-09-22 16:58:22 +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
Ankush Menat
70e56b2e14
perf: Selectively switch to LIFO ordering when queue is starved (#32226)
When queue is overloaded every job gets delayed by size of the queue,
this means even interactive jobs like prepared reports face significant
wait times.

This flag allows developer to selectively enable LIFO on such jobs where
ordering doesn't matter. Any time we observe queue to be too large,
we'll insert the job at front so it gets highest priority.

This is a common strategy to deal with queue starvation, we are only
applying it explicitly because job execution order matters for
correctness in some cases.
2025-04-23 11:54:21 +05:30
Sagar Vora
fcf657ba80 perf: improved DocStatus API and other minor improvements 2025-02-24 12:51:10 +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
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Ankush Menat
9b8a8c155d
fix: Correct logic for can_cancel (#24196)
You can cancel a document IFF:
- Document has no workflow
- Document has workflow but it doesn't have state with docstatus=2.

closes https://github.com/frappe/frappe/issues/19075
2024-01-08 19:15:19 +05:30
Ankush Menat
6cf168a56f fix: bulk workflow action in background 2023-11-24 17:04:09 +05:30
Ankush Menat
892c5e30a2 refactor: Simpler workflow caching
Entire document is cached, so no need to create another layer of cache.
2023-07-19 16:45:44 +05:30
Ankush Menat
774a75dbde
perf: use cached workflow doc for transitions (#21300)
* fix: expire `RECORDER_INTERCEPT_FLAG` in one hour

Leaving this running in prod can be dangerous.

* perf: Use cached doc in workflows
2023-06-09 12:43:40 +05:30
Ankush Menat
fa6dc03cc8
refactor: frappe.cache() usage to frappe.cache (#21282) 2023-06-08 11:47:17 +05:30
PeterG
a182414610
fix(workflow): populate doc from db in apply_workflow (#21068) 2023-05-24 11:35:37 +05:30
gavin
a093b7b34c
perf(workflow): get_transitions (#18834)
* Load from db only if doc passed is not of type Document. This was
  added earlier to load in case of dicts. ref: https://github.com/frappe/frappe/pull/11883
* Move blocks to evaluate only if required
* Add typing hints
2022-11-10 16:22:28 +05:30
Ankush Menat
81b37cb7d2
refactor: clean up code to py310 supported features (#17367)
refactor: clean up code to py39+ supported syntax

- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes

Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
2022-07-01 11:51:05 +05:30
Rushabh Mehta
6e6fe9521e fix(linting): no single quotes :'| 2022-04-18 17:29:03 +05:30
Rushabh Mehta
57a55e4225 feat(minor): Add document reference to Error Log and doc.log_error 2022-04-18 17:29:03 +05:30
Suraj Shetty
c0c5b2ebdd
style: format all python files using black (#16453)
Co-authored-by: Frappe Bot <developers@frappe.io>
2022-04-12 10:59:25 +05:30
Raffael Meyer
89922bae90
feat: utility methods for docstatus (#15515)
* feat: utility methods for docstatus

* refactor: use utility method for doctsatus

* refactor: enum for docstatus

* refactor: docstatus as property

* fix: set docstatus

* feat: docstatus extends int class

* test: docstatus of BaseDocument

* refactor: occurrences of docstatus

* fix: typo

* refactor: move docstatus to a separate file

* test: docstatus

* fix: sider
2022-02-04 07:41:25 +00:00
Gavin D'souza
3446026555 chore: Update header: license.txt => LICENSE
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
2021-09-03 12:02:59 +05:30
Gavin D'souza
e407b78506 chore: Drop dead and deprecated code
* Remove six for PY2 compatability since our dependencies are not, PY2
  is legacy.
* Removed usages of utils from future/past libraries since they are
  deprecated. This includes 'from __future__ ...' and 'from past...'
  statements.
* Removed compatibility imports for PY2, switched from six imports to
  standard library imports.
* Removed utils code blocks that handle operations depending on PY2/3
  versions.
* Removed 'from __future__ ...' lines from templates/code generators
* Used PY3 syntaxes in place of PY2 compatible blocks. eg: metaclass
2021-05-26 15:31:29 +05:30
prssanna
c982875b6a fix: Show cancel button only if document is cancellable 2020-12-28 13:40:12 +05:30
Gavin D'souza
ed01c67f54 style: Black over updated diffs 2020-12-16 15:19:41 +05:30
conncampbell
7a773d2461 feat: Workflow transition condition allows datetime functions 2020-12-14 20:07:39 -07:00
Shivam Mishra
476f21eb4d fix: load doc from db in get_transitions 2020-11-05 18:40:58 +05:30
Rushabh Mehta
72e266f908 fix(tests): cleanup workflow test and commits 2020-08-17 09:41:54 +05:30
Suraj Shetty
d3e4a97b6f
test: Make email account is email account test (#11139) 2020-07-29 17:17:53 +05:30
prssanna
c329a2c1af fix: add update_after_submit to actions while setting worflow state 2020-05-25 12:22:19 +05:30
mergify[bot]
7a35f70d89
Merge pull request #9833 from marination/change-workflow-status-title
fix: Changed 'Errored' to 'Failed' Transactions in Bulk Workflow Status prompt
2020-04-02 11:56:13 +00:00
marination
ea52e51766 fix: Change 'Errored' to 'Failed' Transactions in Bulk Workflow Status prompt 2020-04-01 11:55:42 +05:30
Suraj Shetty
3b93b2a456 refactor: Commonify transition condition evaluation
- This add safe_globals for transition evaluation in workflow_action
2020-03-24 13:28:30 +05:30
prssanna
c0f87b8ab5 fix: make bulk workflow status dialog minimizable 2020-03-16 16:00:38 +05:30
marination
9aa2723ce7 fix: Handling of Manual Exception raises in Bulk Workflow Log. 2020-02-20 15:01:04 +05:30
mergify[bot]
98ef4c1aa5
Merge pull request #9441 from marination/bulk-workflow-apply
fix: Bulk Workflow Action rollback on Error
2020-02-20 05:41:43 +00:00
marination
f5004865b9 fix: Conditional indicator and made strings translatable 2020-02-19 15:46:40 +05:30
marination
f2459e47b7 fix: Added consolidated feedback message
- Message dialog with errored and succesful documents.
2020-02-11 11:51:49 +05:30
marination
d290c645ef fix: Commit succesfull transactions and rollback the rest 2020-02-10 12:55:39 +05:30
marination
3e0b0fb561 fix: Bulk Workflow Action rollback on Error 2020-02-07 18:41:18 +05:30
mergify[bot]
62ea837d07
Merge pull request #9363 from prssanna/workflow-fix
fix(Workflow): Set workflow state when some action is performed on a …
2020-02-05 10:04:49 +00:00
prssanna
44cbdb0ebd fix: iff workflow state of doc is already correct, don't set workflow state 2020-02-05 11:57:23 +05:30
Suraj Shetty
dee4a7336c fix(translations): Incorrect syntax 2020-01-29 15:22:35 +05:30
prssanna
9202997cb8 fix(Workflow): Set workflow state when some action is performed on a document from the backend if workflow exists 2020-01-27 12:09:07 +05:30
Prssanna Desai
8425110af5 fix: hide Cancel button if workflow state and action for Cancel… (#9151) 2019-12-29 18:12:45 +05:30
Suraj Shetty
67b41deb44 test: Add test case to check get_common_transition_actions 2019-06-02 10:56:20 +05:30
Suraj Shetty
12f06d6af7 fix: Change progress title 2019-05-30 17:29:35 +05:30
Suraj Shetty
1d99c1cc86 fix: Pass complete doc to avoid data loss 2019-05-28 17:00:45 +05:30
Suraj Shetty
cc7ea9fae6 fix: Handle edge cases
Handle edge cases like
- same action is used twice for transision
- workflow field is not set for the doc
2019-05-28 14:48:57 +05:30