Skip to content

Conversation

@barredterra
Copy link
Collaborator

@barredterra barredterra commented Mar 21, 2025

Due to compliance regulations, receipts and business letters must be stored securely for multiple years. We want to protect against accidental or malicious deletion. E. g. we attach a PDF of a Sales Invoice when it is submitted and we are obligated to keep the PDF for 10 years.

This PR introduces a DocType-level setting called Protect Attached Files. If it is enabled, attachments on submitted documents cannot be deleted.

Regardless of protection, we still want to allow:

  • deleting or modifying of draft documents
  • deleting canceled documents.

Thus, if the document is in draft or if it's canceled and you have the necessary role permissions for deleting it, you can also delete protected attachments.

We plan to enable this setting for numerous ERPNext DocTypes via the ERPNext Germany app.

@0xD0M1M0

no-docs

@barredterra barredterra force-pushed the protect-attached-files branch from 9a3257d to d4cbb80 Compare March 21, 2025 18:04
@barredterra barredterra force-pushed the protect-attached-files branch from d4cbb80 to 3b1cc1a Compare March 21, 2025 18:06
@barredterra
Copy link
Collaborator Author

The semgrep failure is not related to this PR.

@barredterra barredterra requested a review from 0xD0M1M0 March 27, 2025 17:36
@barredterra barredterra force-pushed the protect-attached-files branch from ccda94c to 6f791db Compare March 27, 2025 17:45
Copy link
Contributor

@0xD0M1M0 0xD0M1M0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found

@barredterra barredterra requested a review from akhilnarang March 27, 2025 22:34
@barredterra barredterra merged commit 3f5da98 into frappe:develop Mar 31, 2025
26 of 27 checks passed
@barredterra barredterra deleted the protect-attached-files branch March 31, 2025 14:00
@barredterra barredterra added the backport version-15-hotfix Backport the PR to v15 label Mar 31, 2025
mergify bot pushed a commit that referenced this pull request Mar 31, 2025
* feat: protect attached files

* fix: protection does not apply to draft documents

* chore: update descriptions

* feat: hide delete button when file is protected

(cherry picked from commit 3f5da98)

# Conflicts:
#	frappe/core/doctype/doctype/doctype.json
#	frappe/custom/doctype/customize_form/customize_form.json
@abid-omar
Copy link

@SaiFi0102

barredterra added a commit that referenced this pull request Apr 8, 2025
* feat: protect attached files (#31855)

* feat: protect attached files

* fix: protection does not apply to draft documents

* chore: update descriptions

* feat: hide delete button when file is protected

(cherry picked from commit 3f5da98)

# Conflicts:
#	frappe/core/doctype/doctype/doctype.json
#	frappe/custom/doctype/customize_form/customize_form.json

* chore: resolve conflicts

---------

Co-authored-by: Raffael Meyer <14891507+barredterra@users.noreply.github.com>
frappe-pr-bot pushed a commit that referenced this pull request Apr 15, 2025
# [15.64.0](v15.63.1...v15.64.0) (2025-04-15)

### Bug Fixes

* check if user is diabled during api authentication ([ba81f14](ba81f14))
* compare lowercase keyword in global search ([#31832](#31832)) ([df0d514](df0d514))
* drop `branch_name` ([7e2c2a3](7e2c2a3))
* Event google URL field not big enough for irl data ([08e7aba](08e7aba))
* **event:** Handle month ends for repeating monthly ([d1e5c09](d1e5c09))
* **google-calendar:** Use byday variable type properly ([3829c2a](3829c2a))
* improve url validation ([#32052](#32052)) ([#32078](#32078)) ([4907ade](4907ade))
* increase failure threshold for preapred report ([#32063](#32063)) ([#32070](#32070)) ([495db3d](495db3d))
* linter config in boilerplate ([fea2139](fea2139))
* list_view_settings can be missing ([#32048](#32048)) ([8c7e860](8c7e860))
* make app installation possible again ([4d774e8](4d774e8))
* only exclude RUF001 where we're using some ambiguous characters ([42379ea](42379ea))
* Prevent duplicate ToDo creation when assigning ([dc3370b](dc3370b))
* print builder beta print option not working ([5977581](5977581))
* **push_notification:** use cstr to convert a None body to empty string ([#32056](#32056)) ([#32062](#32062)) ([9b7b44d](9b7b44d))
* remove print statement ([ebc484f](ebc484f))
* respect include filters while generating report name ([25d87bd](25d87bd))
* Show doctype name in perm check errors ([#32122](#32122)) ([#32125](#32125)) ([75cc5d1](75cc5d1))
* skip adding app to list if we can't run the permission hook ([#32134](#32134)) ([1d03333](1d03333))
* switch to ruff ([d84dda8](d84dda8))
* sync translations from crowdin ([#32012](#32012)) ([257a864](257a864))
* Use GET for get_events for notification bar ([5215f91](5215f91))
* **UX:** block inserting more than 5000 items in table ([#32127](#32127)) ([#32130](#32130)) ([8e74e4e](8e74e4e))

### Features

* ✨ addes x-priority option to email header and the frappe.sendmail function ([#31966](#31966)) ([#32089](#32089)) ([5cc38b6](5cc38b6))
* add info about pre-commit to README ([7d1b92a](7d1b92a))
* ask for branch name ([a70f2e5](a70f2e5))
* copy config files to new app ([745400f](745400f))
* create pre-commit config for new app ([d1254d3](d1254d3))
* linter workflow for new apps ([186e46d](186e46d))
* protect attached files (backport [#31855](#31855)) ([#31970](#31970)) ([15334b6](15334b6))

### Reverts

* Revert "refactor: _create_app_boilerplate" ([a924cce](a924cce))
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backport version-15-hotfix Backport the PR to v15

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants