Commit graph

63 commits

Author SHA1 Message Date
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +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
8a71054c0c
Merge pull request #24765 from ankush/black_to_ruff
ci: switch to ruff-format
2024-02-05 19:20:51 +05:30
Ankush Menat
de9ac89748 style: re-format with ruff 2024-02-05 18:53:33 +05:30
Ankush Menat
b6eef6ebc2
fix: Skip virtual doctypes in link field checks (#24759) 2024-02-05 18:04:31 +05:30
Hussain Nagaria
8d2137c265 docs: consistent doc strings 2023-12-18 18:27:39 +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
440612f3b9
fix: Check perms before sharing linked docs (#22783) 2023-10-17 18:53:09 +05:30
Ankush Menat
018ed845bd refactor: defer unnecessary json-dumping of messages
Also avoid accessing locals where interface is present like for popping last message.
2023-10-16 18:13:50 +05:30
barredterra
88c8baa9ee refactor: for append to extend, merge list extend
Replace a for append loop with list extend.
Create the list with values instead of creating
an empty list and extending it with another list.
2023-08-09 13:25:39 +02:00
Ankush Menat
fa6dc03cc8
refactor: frappe.cache() usage to frappe.cache (#21282) 2023-06-08 11:47:17 +05:30
Shariq Ansari
da6809ec09
revert: checking if user has permission to meta (#19485) 2023-01-05 13:47:14 +05:30
Ankush Menat
025906840d
perf: remove order_by from linked_with checks (#19229) 2022-12-12 15:39:46 +05:30
Sagar Vora
b1703117fc
chore: remove unused whitelisting from API (#19000) 2022-11-25 11:59:04 +05:30
Ankush Menat
2eec621e95 chore: db.get_all -> get_all
Reduces 1 pointless function call.
Function calls are also not "super cheap" in python.
2022-08-22 11:35:14 +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
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
Gavin D'souza
39fc90cb5b fix(ux): Pop from message_log if DoesNotExistError 2022-03-07 16:35:53 +05:30
Gavin D'souza
38fbe76ebf fix: Eliminate broken & impermissible links from get_linked_docs 2022-03-07 15:50:17 +05:30
Gavin D'souza
6edb1f09e4 refactor: Fetch Linked Documents in single request ;)
This action was broken into some heavy UI stuff that seems to be handled
from the current UI from what I can tell and a request triggered from
the Desk for every suspected linked document (talk about self DOS xD)

Removed long dead with_doctype option in get_linked_docs API. How do i
know it's been long dead? I've not come across code that won't very
obviously break when hit with any non None value.
2022-03-07 15:02:20 +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
Rucha Mahabal
d56fea4a47 fix: use get_all instead of get_list while fetching linked doctypes 2021-12-16 09:11:21 +05:30
Subin Tom
2b8328715e
fix: Sales invoice cancellation error due to get_list (#15243)
* fix: Sales invoice cancellation error due to get_list

* fix: missed out one `get_list`
2021-12-10 07:51:27 +00:00
Suraj Shetty
615db9b55e style: Fix sider alerts 2021-11-28 09:44:05 +05:30
Suraj Shetty
3b276df7c1
Merge branch 'develop' into refactor-linked-with 2021-11-03 11:13:53 +05:30
Ankush Menat
af4ce8156d
fix: remove mutable defaults (#14597)
* fix: mutable defaults

* fix: missing defaults
2021-10-28 09:36:31 +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
leela
8a8fbad0f3 refactor: getting submitted linked reference docs 2021-08-30 12:34:21 +05:30
Gavin D'souza
793b5638d3 style: Fix E201, E202, E401, E701
reported by sider: https://sider.review/gh/repos/1864194/pulls/13344?statuses#issues
2021-05-27 12:48:01 +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
Ankush Menat
d25909c799
fix: ZeroDivision error in progress
When list of docs is of same length as list of doctypes to ignore, the
formula would throw ZeroDivision error. It's meaningless to subtract
these two quantities hence removed it.

Showing accurate progress bar would require pre-computing number of docs
to be cancelled, which is unnecessary.

Related issue: ISS-20-21-10442
2021-03-17 10:08:50 +05:30
Ankush Menat
fb1eac23c5
docs: update docs for linked_with functions 2021-03-16 11:49:37 +05:30
Anurag Mishra
6bfd07be51
feat: Ignore doctypes for cancel_all (#11034) 2020-08-14 16:12:02 +05:30
Prssanna Desai
20815aa349
refactor: remove unnecessary code from get_submitted_linked_docs (#10844)
Co-authored-by: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com>
2020-06-30 08:03:28 +05:30
Anand Narayan
fc69f77f73 fix(linked_docs): infinite recursion due to loops 2020-06-27 22:05:24 -07:00
mergify[bot]
4f6f9f3293
fix: check for self linking (bp #10181) (#10426) 2020-05-20 23:30:27 +05:30
mergify[bot]
0826a9db45
fix: check for self linking and circular linking while getting submitted linked docs (bp #10179) (#10425) 2020-05-20 21:24:09 +05:30
vishal
b2a44e922e fix: added auto_cancel_exempted_doctypes in boilerplate 2020-01-13 13:31:00 +05:30
vishal
9cc39377fe fix: deepsource 2020-01-13 13:31:00 +05:30
vishal
9cf251e53e fix: Distinct check added for possible links 2020-01-13 13:31:00 +05:30
vishal
9be267b96a fix: deepsource 2020-01-13 13:31:00 +05:30
vishal
95f04583e2 fix: validation added for cancel document 2020-01-13 13:31:00 +05:30
vishal
f741d46fdb feat: cancel multiple documents in a single transaction
- show all linked doc in a dialog box on cancel event
- following changes only fetch cancelable docs
- recursively build a list of linked submitted docs
- cancel all linked documents before cancelling current document
- add progress bar and group documents by doctype
- added exempted doctype list in hooks
2020-01-13 13:31:00 +05:30
Faris Ansari
3b86f16b73 New Control: Table MultiSelect (#6675)
* feat(control): Add Table MultiSelect control

* fix: Use btn-group instead of span

* fix: Remove functionality

* fix: Add 'Table MultiSelect' to Field doctypes

* fix: Replace usage of string 'Table' with array `table_fields`

* fix: Use internal array to store values instead of building from HTML elements

* fix(style): Add semicolon

* fix: Read only mode and click to navigate to form

* style: indent

* fix: fallback to empty array

* fix: Add formatters in js and py

* style: missing semicolon

* fix: Add docfield validation
2018-12-28 15:36:59 +05:30
Suraj Shetty
1e23e98a54 Catch KeyError in liked_with to fix failing patch
https://travis-ci.com/frappe/erpnext/jobs/167043420
2018-12-26 11:06:23 +05:30
Manas Solanki
01b6b74b6d [fix] linked with if there are multiple link field in the same doctype (#5587)
* [fix] linked with if there are multiple link field in the same doctype

* handle python 3 and fixed as per reviews
2018-05-30 11:43:39 +05:30
Suraj Shetty
3109123249 Permission improvements (#5494)
* Overwrite "if owner" restriction*
- Overwrite "if owner" restriction if user has other valid roles
(with access rights) without if_owner enabled for it in doc perm
eg:
If a doctype has 2 docperm for Role A and Role B and the docperm with
Role A has  if owner enabled.

Suppose User 1 has Role A, then User 1 should see only docs
which was created by him.

Now if User 2 has Role A and Role B, User 2 should be able to see all the
records because Role B has unrestricted access on doctype.
------------------------------------------------------

Previously in case of User 2, the restriction(of if owner) from Role A
used to reflect and User 2 was only able to view only records made by
him.

This commit will overwrite the if_owner restriction in such case.
- Refactor get_role_permission method

* Add advanced control for user permission
- Add ability to skip user permission check for specific doctype

* Refactor "linked with" method
- Add option to skip linked with doctype which has
ignore_user_permission enabled against them.

* Clear "linked with doctype" cache on doctype changes

* [Minor] Fix formatting

* Fix error and bugs in linked_with method

* Format code

* Add fix to get allowed docs from user_permission

* Fix has_user_permission bug

* Add before migrate patch for user permission

* Fix typo
2018-05-04 13:13:29 +05:30
Achilles Rasquinha
0fc518ace4 python 3 fixes 2018-03-31 18:15:43 +05:30
Aditya Hase
f7da376279 Convert dict.keys() to list explicitly for deleting elems while iterating 2017-09-27 01:08:07 +05:30
Aditya Hase
769338f136 Replaced all instances of basestring with six.string_types 2017-08-11 00:10:11 +05:30