Commit graph

2378 commits

Author SHA1 Message Date
Suraj Shetty
0f4a1d8f10 fix: Handle invalid descendant filter 2024-01-19 15:49:02 +05:30
Ankush Menat
c177431557
perf: Document objects without circular references (#17080)
* perf: `Document` objects without circular references

Circular references are usuallly considered bad for GC, avoiding them
since they don't seem to be necessary.

* fix: explicitly convert to weakref
2024-01-17 17:22:55 +05:30
Ankush Menat
c0cf13b8e8 Revert "fix: search_link fails when txt contains parentheses (#22892)"
This reverts commit 642e9f4ec1.
2024-01-17 12:44:20 +05:30
Sambasiva Suda
642e9f4ec1
fix: search_link fails when txt contains parentheses (#22892)
* fix: search_link fails when txt contains parentheses

* fix: updating regex to replace number params also

* chore: replacing regex with sqlparse

* chore: not including fields like count(1) in asterisk_fields

* fix: owner/module not identified as column

* chore: lint fix and removing exception

* refactor: better function name

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2024-01-16 21:36:45 +05:30
Ankush Menat
447f02e8d3
fix!: Remove misleading "raise_exception" (#24266)
frappe.permission.has_permission won't accept raise_exception anymore,
it was extremely misleading argument and actual purpose of the argument
was to print perm check logs.
2024-01-11 08:24:18 +00:00
Ankush Menat
b38199a3b3 fix: pass user to has_perm check 2024-01-11 12:34:15 +05:30
Ankush Menat
9f135e8c1d fix: print perm check logs from DB query
Doing has_permission and then manually raising exception erases the perm check messages.

This causes insane amounts of confusion when perm error says X not
permitted while user is trying to check Y.
2024-01-11 12:27:39 +05:30
Ankush Menat
1f6201b4af feat: lazy global translated strings 2024-01-10 21:28:01 +05:30
Ankush Menat
f7413d74fb
Merge pull request #24243 from ankush/annotate_meta
fix(DX): Type annotations for Meta
2024-01-10 16:45:07 +05:30
Ankush Menat
d09df92497 fix(DX): Type annotations for Meta
`frappe.get_meta` returns which is 90% `DocType` + 10% `Meta` specific
stuff, this hack just allows us to mix both for autocompletions.
2024-01-10 15:58:03 +05:30
Ankush Menat
914406d31b feat: extend perm debugging to popular controllers
- [x] File
- [x] Communication
2024-01-10 15:16:52 +05:30
Sagar Vora
417fce091a
fix: delete existing children first to avoid UniqueValidationError (#24140) 2024-01-08 22:00:54 +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
Shariq Ansari
54ecae0656
fix: Allowed standard fields in data export ( creation, owner) (#24187)
Co-authored-by: Pavan Kumar Yekabote <yekabotep@gmail.com>
2024-01-08 17:09:13 +05:30
Ankush Menat
64c221343e
perf: skip ifnull checks on modified field (#24042) 2023-12-30 06:39:32 +00:00
Corentin Flr
42fbb58626
fix(document): Pass parent_doc and parentfield in _set_defaults 2023-12-23 20:40:52 +01:00
Ankush Menat
4d68a46b10
fix: Set default child table fields on save (#23913)
We set defaults on creation of new doc but when you append a new child
doc on existing document it doesn't seem to set the defaults.

This seems like a bug and not a deliberate choice.
2023-12-22 08:02:36 +00:00
Ankush Menat
5e2ace4c08
perf: Use set for tracking whitelisted methods (#23905)
List look ups are O(N). This is still a microoptimization at best
considering other overhead.
2023-12-21 23:19:06 +05:30
Ankush Menat
0fd6f5eed7
Merge pull request #23827 from frappe/api-docs
docs: add Python API missing docstrings / type hints
2023-12-21 12:13:05 +05:30
bourouffala
3015852ce1
fix: Error when displaying dashboard with number card using average and sum functions (#23883) 2023-12-20 11:13:20 +00:00
Ankush Menat
052a2527dd
Merge pull request #23874 from ankush/del_check_links
fix: don't allow deleting original doc if amendment exists
2023-12-20 14:13:41 +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
5ecacd0cd7
Merge pull request #23865 from ankush/no_virtual_select_star
fix: skip virtual fields in perm level checks during DB Query
2023-12-20 12:15:48 +05:30
Ankush Menat
5deabdde21 fix: skip virtual fields in perm level checks during DB Query
DB Query can't access virtual fields so it should ignore all virtual
fields.
2023-12-20 12:00:08 +05:30
Akhil Narang
178b699466
Merge pull request #23432 from marination/doc-connections
fix: Treat Document Links entries as all non-std fields
2023-12-19 16:05:58 +05:30
Hussain Nagaria
8d2137c265 docs: consistent doc strings 2023-12-18 18:27:39 +05:30
Ankush Menat
687752359d
perf: Primary key is never nullable (#23788)
People ususally write queries like these...

```
frappe.get_all(doctype, {"name": ("in", list_of_docs))
```

Ocassionally, the `list_of_docs` is empty because it's dynamically
generated and in this case we end up doing full table scan to find... nothing!
2023-12-14 15:01:19 +00:00
Smit Vora
f62f4472e6
fix: ignore if controller doesn't have get_list attr (#23736) 2023-12-11 23:24:00 +05:30
Shariq Ansari
52cea3e01c chore: better code 2023-12-08 15:49:33 +05:30
Shariq Ansari
78cf0cd142 fix: check if autoname is promt before setting __newname 2023-12-08 10:53:58 +05:30
Sagar Vora
d74e5d2e8a chore: fix typo in comment 2023-12-07 09:31:53 +05:30
barredterra
c35476256f refactor: simplify conditional logic
Command: `sourcery review --fix --enable de-morgan .`
2023-12-05 11:14:41 +01:00
Ankush Menat
ebbd3cd137
fix: skip overriden doctypes during orphan check (#23518)
These are prone to breakage and shouldn't be deleted automatically.

This mostly works fine but there can be cases where it doesn't. So best to leave them untouched.
2023-11-30 11:33:42 +00:00
Ankush Menat
286e0a7b96
fix: Always evaluate Virtual Fields (#23515)
Related: https://github.com/frappe/frappe/issues/23475
Likely caused by: https://github.com/frappe/frappe/pull/22110

Because run_doc_method passes doc from client to server side, we end up
setting values for what is a "virtual field", this is why it finds some
value and not re-evaluate it.

IMO there are only mild breaking ways of fixing this:
1. Virtual fields should always be computed.
2. Virtual fields should not be set when init-ing the arguement. (e.g. from doc.set APIs )
2023-11-30 16:22:22 +05:30
Deepesh Garg
20a7521c92 chore: Provision to ignore child mapping using get mapped doc 2023-11-26 14:33:42 +05:30
marination
d4129721ce fix: Treat Document Links entries as all non-std fields
- Since the field name is specified use it as a non standard field because it is hard to determine which field is standard. It is often wrong to assume the first entry has the statndard field
2023-11-24 16:39:50 +01:00
Ankush Menat
e8fe3b2166
Merge pull request #23414 from ankush/bulk_actions_bg
perf: run bulk actions using background jobs
2023-11-24 18:33:38 +05:30
Smit Vora
bf50952662 fix: after_mapping hook to run custom mapping functions 2023-11-24 17:45:38 +05:30
Ankush Menat
6cf168a56f fix: bulk workflow action in background 2023-11-24 17:04:09 +05:30
ruthra kumar
1e0920409f fix: ignore dynamic fields in virtual doctypes 2023-11-23 14:49:28 +05:30
Ankush Menat
d715b0ad31
Merge pull request #22804 from akhilnarang/non-nullable-fields
feat: allow setting fields as not nullable
2023-11-20 12:46:02 +05:30
ruthra kumar
94b2e509b9 fix: dont rename link fields in Virtual doctypes 2023-11-20 10:11:42 +05:30
Shariq Ansari
729f8be0af
Merge pull request #23248 from anandbaburajan/rename_doc_and_field 2023-11-17 16:15:40 +05:30
anandbaburajan
ebccab0652 fix: copy any flags if required in rename_doc() only on validate 2023-11-17 00:32:28 +05:30
anandbaburajan
0aab6160a4 chore: validate arg for rename_field() 2023-11-17 00:31:04 +05:30
Akhil Narang
731c5c8cd5
refactor(db_query): check for docfield not_nullable
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Akhil Narang
10ad99869a
feat: use user-specified default value if passed
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Akhil Narang
15c925ccc7
feat: check for docfield not_nullable property to decide whether a field can be nullable
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Akhil Narang
390d4e1b13
chore: drop unused variables and parameters
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30
Akhil Narang
75709eede7
feat: set a non-null value if docfield isn't set as nullable
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2023-11-16 14:51:57 +05:30