Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Discard transactions #25971

Merged
merged 10 commits into from
Apr 29, 2024
Merged

Conversation

rutwikhdev
Copy link
Contributor

@rutwikhdev rutwikhdev commented Apr 16, 2024

Fixes: #21515

Added discard action under menu items on draft transactions. This action will do transition validation, check write perms, run hooks and do db_set with docstatus 2.

image

Added Events

Override doc methods: before_discard, on_discard
Client Script: before_discard, after_discard (following same naming conventions as cancel)
Server Script Doctype Events: Before Discard, After Discard

Right now it just validates write perms, perhaps we can add separate permissions later.

docs: https://frappeframework.com/docs/user/en/api/form#form-events

@rutwikhdev rutwikhdev requested a review from a team as a code owner April 16, 2024 14:48
@rutwikhdev rutwikhdev requested review from ankush and removed request for a team April 16, 2024 14:48
@github-actions github-actions bot added the add-test-cases Add test case to validate fix or enhancement label Apr 16, 2024
@rutwikhdev rutwikhdev added docs-pending Feature was merged without docs for some reason and removed add-test-cases Add test case to validate fix or enhancement labels Apr 16, 2024
frappe/model/document.py Outdated Show resolved Hide resolved
frappe/desk/form/save.py Outdated Show resolved Hide resolved
frappe/desk/form/save.py Outdated Show resolved Hide resolved
frappe/public/js/frappe/form/form.js Outdated Show resolved Hide resolved
frappe/public/js/frappe/form/save.js Outdated Show resolved Hide resolved
@ankush
Copy link
Member

ankush commented Apr 17, 2024

TODO:

  • behavior when workflow is active (?)

* use write perms instead of cancel
* update docstring
* remove discard from global namespace
doing explicit transition check for discard because,
* there's only one transition check that is required
* draft(0) > cancelled(2) and submitted(1) > cancelled(2) are valid
  checkes for save so it doesn't make sense editing
  check_docstatus_transition
@rutwikhdev rutwikhdev added backport version-15-hotfix Backport the PR to v15 and removed docs-pending Feature was merged without docs for some reason labels Apr 18, 2024
@ankush ankush self-assigned this Apr 22, 2024
@ankush ankush added defer backport Backports for some PR are deferred for a week or two to test them properly before releasing and removed backport version-15-hotfix Backport the PR to v15 labels Apr 22, 2024
@cogk
Copy link
Contributor

cogk commented Apr 22, 2024

Suggestion: maybe both the Discard and Delete menu items could be merged, with a popup to choose between the two. The advantage is that you have the space to explain the difference between discarding and deleting a draft document.

@ankush
Copy link
Member

ankush commented Apr 23, 2024

@cogk they seem like 2 very different actions 🤔

@ankush
Copy link
Member

ankush commented Apr 23, 2024

Also in some cases we just hide delete based on perms or local requirements.

frappe/desk/form/save.py Show resolved Hide resolved
frappe/model/document.py Show resolved Hide resolved
frappe/public/js/frappe/form/form.js Outdated Show resolved Hide resolved
@ankush ankush added do not backport and removed defer backport Backports for some PR are deferred for a week or two to test them properly before releasing labels Apr 23, 2024
@ankush ankush merged commit ff31290 into frappe:develop Apr 29, 2024
24 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow to cancel draft transactions
3 participants