Commit graph

206 commits

Author SHA1 Message Date
Raffael Meyer
9208b58b6f
refactor: use doc.check_permission (#28317)
* refactor: use `doc.check_permission`

* refactor(delete_doc): check_permission_and_not_submitted
2024-11-22 10:41:24 +01:00
Gavin D'souza
15f6fcdf3e
fix(delete_doc): Check if submittable before docstatus validation 2024-09-13 18:50:50 +02:00
Raffael Meyer
fd9e80e364
feat: nudge for all DocTypes that can be disabled, not deleted (#27067)
Co-authored-by: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com>
2024-07-11 05:18:19 +00:00
Ankush Menat
87ffe25e71
fix: reserved keywords as col name (#25718) 2024-03-29 15:43:33 +05:30
Ankush Menat
fc5ce044e6 fix: prevent deletion if document is locked 2024-02-29 16:34:39 +05:30
Ankush Menat
8f00aae160 fix: lock the doc before deleting
Locking only prevents this kinda race conditions:
- User A deletes doc
- User B modifies doc so that it's not deletable anymore.
2024-02-29 16:22:02 +05:30
Ankush Menat
72c2207e0f refactor: useless use of dict in frappe.get_doc 2024-02-10 12:52:38 +05:30
Akhil Narang
26ae0f3460
fix: ruff fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-07 17:04:31 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Ankush Menat
ca293c9aa3 fix: Enqueue deletion of dynamic link after comitting 2024-01-31 18:37:12 +05:30
Ankush Menat
b51a479fc2 fix: don't allow deleting original doc if amendment exists 2023-12-20 13:11:34 +05:30
Ankush Menat
47c3151662
fix: remove data import legacy leftover fields (#23113)
* fix: clear last message if ignoring DNE

* fix: attempt to delete data import legacy leftover fields
2023-11-06 19:18:39 +05:30
Ankush Menat
cc9e92572b perf: dont query ignored link doctypes
Currently the code first queries and then ignores, just don't query linked doctypes if they are ignored via validation.
2023-10-31 15:14:24 +05:30
Ankush Menat
6926669577 perf: Ignore amended_from link fields in link field checks
Small perf benefit at not much cost. `amended_from` are *always*
refererring to cancelled documents so there's no need to check these
fields.
2023-10-31 15:03:08 +05:30
Ankush Menat
1560fa8610
fix: ignore stale custom fields while checking back-links (#22940)
* fix: ignore non-existing back-links

* refactor: less indentation, guard clauses
2023-10-27 14:07:58 +05:30
Saif Ur Rehman
0b92078c60
fix(delete_doc): Check ignore_links_on_delete with parent doctype (#20898) 2023-05-16 09:04:00 +05:30
Gavin D'souza
d357af1533 refactor: Add a maxsplit limit to string splits 2023-01-24 19:22:51 +05:30
Raffael Meyer
ed30a6d59f
refactor(minor): use DocStatus (#19545) 2023-01-10 17:38:11 +05:30
Daizy Modi
d88ef967b9
feat: hook ignore_links_on_delete to skip doctypes on delete (#19347)
* feat: hook `ignore_links_on_delete` to skip doctypes on delete

* fix: helper comment

* fix: helper comment

* test: test case for `ignore_links_on_delete`

* test: fix test case
2022-12-20 11:17:28 +05:30
Raffael Meyer
6e8820e627
chore: translate doctype in link error (#19164) 2022-12-07 00:31:39 +05:30
Ankush Menat
ad7c0816f8
fix: prevent deleting standard doctypes in prod (#18803) 2022-11-08 21:27:41 +05:30
Ankush Menat
20593f155d
fix: delete custom tables when doctype is deleted (#18433)
* fix: delete custom tables when doctype is deleted
2022-10-19 16:45:56 +05:30
Sagar Vora
63e760e3ad chore: remove old code where User Permissions were set in tabDefaultValue 2022-08-22 19:03:30 +05:30
Ankush Menat
d83712d553 feat: delete support for virtual doctypes from desk 2022-07-22 15:42:04 +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
mergify[bot]
81d41c8d3a
Merge pull request #17297 from resilient-tech/dont-remove-custom-perms
fix!: dont delete custom permissions when doctype is deleted
2022-06-26 14:22:55 +00:00
Smit Vora
b6963b1dec fix: ignore integration request when deleting doc 2022-06-26 12:53:38 +05:30
Sagar Vora
3c617e3b06 fix!: dont delete custom permissions when doctype is deleted 2022-06-26 11:51:52 +05:30
gruener
1349a73e14
fix: Virtual DocTypes currently breaking Parent-DocType Update and Deletion (#16977)
When you create a Virtual DocType as a Child Table (which is possible without any warning), then it will lead to several errors when updating or deleting of the parent document.

This is because the following files just execute a SQL Statement for the doctype (which doesnt have a DB Table, as this is the nature of a virtual doctype ;-)

**apps/frappe/frappe/model/document.py**
```py
frappe.db.sql("""delete from `tab{0}` where parent=%s and parenttype=%s and parentfield=%s""".format(df.options), (self.name, self.doctype, fieldname))
```

**apps/frappe/frappe/model/delete_doc.py**
```py
frappe.db.sql(
	"delete from `tab%s` where parenttype=%s and parent = %s" % (t, "%s", "%s"), (doctype, name)
)
```

So at these points, I added a check to not perform any sql command for virtual doctypes. With these changes, my affected situation is solved. Perhaps there are other situations, I didn't encounter yet.

As an additional feature, those virtual doctype models should also get an information about the parent is deleted, to propagate the deletion to the remote data pools; but for now I hope this bugfix can be approved.
2022-06-23 11:38:29 +00:00
Suraj Shetty
0cd41fbf0c
Merge branch 'develop' into fix-document-signature-2 2022-06-01 18:01:12 +05:30
Suraj Shetty
59c7fb9e0d fix: Add "Document Share Key" to doctypes_to_skip in delete_doc.py
- To avoid error while deleting linked document.
2022-06-01 17:59:32 +05:30
Ankush Menat
076eb593e3 refactor: delete_from_table
Whole lot of unnecessary complexity, closure, multiple function calls,
comprehensions all that can be replaced with single `get_all`
2022-05-29 13:46:48 +05:30
Ankush Menat
a0ecb912db fix!: dont delete customizations when doctypes are deleted
If someone deletes doctype and restores it back all customization are
lost, there's no "real" reason to delete all these customization. They
are only ever active if the doctype is being used.

Explanations:

- Custom field: is used by meta when doctype meta is requested, if meta
  isn't requested then custom field is effectively inactive.
- Client script: loaded by meta when doctype is requested by desk. So
  inactive in deleted state.
- Property setter: loaded by meta, so inactive when doctype isn't
  present.
- Report: will break doctype isn't present, but user should delete them
  manually to avoid loss of "scripts" or anything special they might
  have done. Also report's doctype don't 100% indicate that it's based
  solely on that doctype.
2022-05-29 13:46:44 +05:30
chillaranand
1d763a6659 refactor: Fix flake8 issues 2022-05-19 15:34:35 +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
phot0n
bebc8058b6 feat: integer primary keys 2022-03-11 23:46:00 +05:30
Ankush Menat
1a34826203 test: use now instead of is_async in tests 2022-02-23 15:37:56 +05:30
Ankush Menat
c5fbd07840
revert: "fix: use now instead of is_async in tests (#15893)" (#15899)
This reverts commit 1cd4722235.
2022-02-07 19:10:42 +05:30
phot0n
266e1f95ed chore: adding back idx column
This is needed for ordering in display of links as it keeps
track of the clicks on a particular link item
2022-02-07 16:40:01 +05:30
phot0n
b31f3c24f6 refactor: remove parent, parenttype, parentfield, idx columns from non-child table doctypes
* feat: add parent, parenttype, idx, parentfield columns to doctypes when transitioning from normal -> child table

* fix: remove parent, parenttype, parentfield, idx from DocType DocType
2022-02-07 15:12:37 +05:30
Ankush Menat
1cd4722235
fix: use now instead of is_async in tests (#15893) 2022-02-07 14:00:26 +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
f72c445d41 fix: Clear Document cache on rename, delete 2022-01-03 19:02:41 +05:30
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
Suraj Shetty
743e361449
Merge branch 'develop' into core-test-coverage-1 2021-08-23 11:02:50 +05:30
Gavin D'souza
32c6cf1c44 refactor(misc): frappe.db.delete > frappe.db.sql
Use frappe.db.delete wherever possible. Get rid of all the frappe.db.sql ;)

This commit focuses on the pending modules that had relatively easier
DELETE statements.
2021-08-19 19:53:16 +05:30
Suraj Shetty
a7fb1816aa refactor: Remove unused and redundant code 2021-08-19 15:27:25 +05:30
Gavin D'souza
01d275f667 style: Format code for better readability
* Remove trailing whitespaces
* Format code to fit module conventions
* Add appropriate new lines between imports, classes, fn defs, etc
* Added comments, docstrings & module headers
2021-07-28 18:55:27 +05:30
Aradhya-Tripathi
84ff1d0af9 style: removed frappe.db.sql comments 2021-07-28 13:48:01 +05:30
Aradhya-Tripathi
538ef2168b fix: removed wrong queries 2021-07-24 22:58:12 +05:30