Commit graph

452 commits

Author SHA1 Message Date
David Arnold
d5fd8d7c20
chore(docref): fix circular imports (#28282) 2024-10-24 22:31:12 +02:00
David Arnold
2abba7b51b
fix: don't force values into the string type (#28185) 2024-10-19 19:00:25 +00:00
David Arnold
7348572af8
feat: docref identifier / proxy (#27973)
* feat: add DocRef

* feat: Add comprehensive test cases for DocRef functionality

* chore(db): add field type hints

* fix: ensure document stringer fulfills the DocRef contract
2024-10-19 09:40:26 +05:30
Sumit Bhanushali
847dd62ec0 feat: permission log 2024-09-30 14:54:32 +05:30
Akhil Narang
8260574f0d
Merge pull request #27659 from barredterra/mandatory-field-msg
fix: message for missing mandatory fields
2024-09-24 20:37:48 +05:30
Raffael Meyer
c73734715d
fix: update message needed for test
Co-authored-by: Akhil Narang <me@akhilnarang.dev>
2024-09-24 16:28:04 +02:00
ruthra kumar
2b8df89d55 fix: re-number idx on child table row removal 2024-09-17 14:19:57 +05:30
barredterra
89443beb06 fix: message for missing mandatory fields 2024-09-05 10:45:32 +02:00
barredterra
6ba7e8e11d fix: skip all validation if there's no data 2024-09-02 15:49:41 +02:00
barredterra
8836978b86 refactor: import validation utils 2024-09-02 15:49:08 +02:00
Gavin D'souza
074da5c553
fix: Separate meta.get_valid_fields from *columns 2024-08-28 18:12:42 +02:00
Rushabh Mehta
774d86f642 feat: Workspace Settings - allow enabling and disabling of workspaces during setup 2024-08-04 13:41:08 +05:30
Markus Lobedann
8badd16f1f
fix: don't run setattr for a virtual (read-only) field (#26365) 2024-07-03 16:27:27 +02:00
Ankush Menat
803f7b3990
fix: Don't fiddle with child table indexes (#26450)
- Link fields when referred to increase idx
- This is used in search.py to rank most referred documents higher than
- This doesn't make for child table links at all.
2024-05-16 17:09:56 +05:30
Ankush Menat
53517630ae
fix: Increase folder link field size (#26381)
* fix: increase folder length to 255

File `name` is 255 because it's bootstrapped using mariadb.sql, so users
can create 255 char long folders but can't store anything in it.

* fix(UX): slightly better character len message

Highlight field by making it bold.
2024-05-09 12:10:21 +05:30
Ankush Menat
7b0074e059
refactor!: override_doctype -> Must extend base class (#26152)
* fix: pointless conditions about systemd/supervisor

What does this have to do with hostname?

* fix!: Overriden doctypes must inherit same base class

There is almost never a real need to completely override a class. After
this change we'll only allow extending and not overriding completely.
2024-04-29 10:21:53 +00:00
Ankush Menat
1e4c182b52
fix: retry count per doc instead of global (#26159) 2024-04-25 09:34:52 +00:00
Ankush Menat
30f00fd5f3 fix: invlaid integer validations for biging
closes https://github.com/frappe/frappe/issues/25566
2024-04-06 11:04:55 +05:30
Suraj Shetty
9a1bd6c1ac
fix: No need to sort keys while saving JSON to DB (#25205)
* fix: No need to sort keys while saving JSON to DB

Also, adding indent is unnecessary.
2024-03-04 05:44:46 +00:00
Jannat Patel
898f982a88
fix: replaced created by with owner in base_document (#25059) 2024-02-26 12:12:26 +00:00
Riandrys Gongora Roman
f992821459
fix: translation get label from fieldname 2024-02-22 16:00:59 -05:00
Akhil Narang
3f1e19de85
refactor(treewide): enable RUF rules
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-21 16:20:28 +05:30
Raffael Meyer
fc64e8a0fb
feat: pass doctype as context when translating label (#24903) 2024-02-18 19:42:15 +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
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
Hussain Nagaria
8d2137c265 docs: consistent doc strings 2023-12-18 18:27:39 +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
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
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
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
Marica
6b1ec4703d
fix: Validate invalid links in fetch_from dependency fields (#22993) 2023-10-30 18:43:41 +05:30
Sagar Vora
bcc7cc9a3d
style: use functools.cached_property (#22304) 2023-09-04 16:50:25 +05:30
Sagar Vora
7dc67f2feb chore: add back getattr for virtual docfields which get value from a property 2023-08-18 21:51:56 +05:30
Sagar Vora
928bc46be3 perf: undo regression in as_dict performance 2023-08-18 17:44:45 +05:30
Ankush Menat
c7847395da
fix: remove thread-unsafe class attributes (#22097)
The problem is same as mutable defaults. Container type class attributes
are mutable and shared between all objects.

```python
class CLS:
    attr = {}
    ...

a = CLS()
b = CLS()

a.attr is b.attr  # => True
```
2023-08-17 20:11:20 +05:30
mergify[bot]
fd10ab25cc
Merge pull request #22003 from gavindsouza/refactor-doc-bits
refactor: Use single query to delete child rows on doc.save
2023-08-11 06:45:07 +00:00
Ankush Menat
02e1311b3a build: pin typing_extensions to major version 2023-08-11 11:54:09 +05:30
Gavin D'souza
84f134a683
fix: Add "better" typing hints 2023-08-11 11:45:47 +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
039be73af4
refactor: Consider singles for dynamic set_value usage (#21367)
Found all usage using this semgrep rule:

```yaml
    - pattern: frappe.db.set_value($DOCTYPE, ...)
    - pattern-not: frappe.db.set_value("$STR", ...)
```
2023-06-14 10:46:25 +05:30
Dhia' Alhaq Shalabi
efff6ebba7
fix: doctype name localization (#21197)
[skip ci]
2023-06-01 12:09:25 +05:30
Vincent Vrithof
090c91b44f
fix: virtual fields in child tables not displaying (#20528)
* fix: virtual fields in child tables

* Update frappe/model/base_document.py

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>

* fix: virtual fields in child tables not displaying

---------

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2023-04-06 12:30:58 +05:30
Zhixuan Lai
2d416098c2
fix: link validation fetch from virtual doc (#20055)
Problem: 
document.save() throws "Object is not scriptable exception" when fetching values from virtual doc.

Root cause:
```python
        # ....
        if frappe.get_meta(doctype).get("is_virtual"):
	    values = frappe.get_doc(doctype, docname) <--- Document is not scriptable.
.as_dict()
        # ....

	def set_fetch_from_value(self, doctype, df, values):
		fetch_from_fieldname = df.fetch_from.split(".")[-1]
		value = values[fetch_from_fieldname] <--- Tries to access value by key and throws "Object is not scriptable" exception
```

Solution:
```python
        if frappe.get_meta(doctype).get("is_virtual"):
	    values = frappe.get_doc(doctype, docname).as_dict() <--- Makes the document scriptable.
```
2023-02-16 18:15:40 +05:30
Ankush Menat
95ad5c7696 fix: Dont use meta for get_controller 2023-02-03 16:14:12 +05:30
Ankush Menat
90c4543065 fix: Dont use cached controllers during migration 2023-02-03 13:28:59 +05:30
Shariq Ansari
0f6f599c55
Merge pull request #19871 from developsessions/fix_possible_none_value 2023-02-01 16:40:10 +05:30
developsessions
bcbcc87f4b fix: possible none value evaluation in get_formatted function 2023-02-01 09:24:42 +01:00
Gavin D'souza
7ce0c4c8b3 Merge branch 'develop' into permlevel-apis 2023-01-31 17:47:59 +05:30
barredterra
4bcb12617c fix: assertAlmostEqual with precision 2023-01-26 11:39:41 +01:00