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
Gavin D'souza
6b0e4695a8
Merge branch 'develop' into permlevel-apis
2023-01-25 12:08:47 +05:30
Gavin D'souza
4c1b2ae67c
refactor: get_valid_dict
...
* Util get_permitted_fields checks for valid columns instead of planned logic
* Remove virtual field from dict if not in permitted fields
* Remove reliance on sentinel object _DOC_DELETED_ATTR
2023-01-25 12:04:34 +05:30
Gavin D'souza
550261b3dc
fix(db_query): Set & use existing constants
2023-01-24 13:01:05 +05:30
Sagar Vora
71420eb4e6
refactor: simplified get_controller ( #19684 )
...
* refactor: simplified `get_controller`
* chore: more refactor, better error if not subclass
* chore: more correct condition
* refactor: `class_` > `_class`
* chore: use `Meta` instead of DB calls
* chore: `_get_controller` => `import_controller`
* style: remove else block
2023-01-24 01:27:26 +05:30
gavin
d1b7a69141
Merge branch 'develop' into permlevel-apis
2023-01-16 14:54:36 +05:30
Ankush Menat
327300b6c9
fix(UX): Better message for update after submit. ( #19558 )
...
[skip ci]
2023-01-10 19:35:45 +05:30
Gavin D'souza
ae81cd2dd3
fix(doc): Maintain virtual df data in as_valid_dict
2023-01-09 18:44:42 +05:30
Gavin D'souza
c28e4590e8
fix(rest): Delete doc attr if insufficient field permissions
2023-01-09 15:47:21 +05:30
Ankush Menat
a1132075a0
Merge pull request #19326 from resilient-tech/get-latest-fix
...
perf: reuse `_doc_before_save` in `doc.get_latest`
2022-12-19 12:30:30 +05:30
Sagar Vora
2fd2d426cc
fix: better check of whether doctype is child table ( #19329 )
...
* fix: better check of whether doctype is child table
* perf: init `_table_fields` earlier
2022-12-19 11:50:16 +05:30
Sagar Vora
c453ad2d97
perf: reuse _doc_before_save in doc.get_latest
2022-12-17 07:56:54 +00:00
Hussain Nagaria
da7fd35e49
fix: handle HTML code field's has_content
2022-12-14 19:36:07 +05:30
Raffael Meyer
bb5b0e5e64
refactor!: remove compare util from frappe package ( #19234 )
...
Use `from frappe.utils import compare` instead of `frappe.compare`.
2022-12-11 23:20:21 +05:30
Sagar Vora
7f3ea7a520
chore(BaseDocument): simplify _table_fieldnames property init
2022-11-12 00:36:15 +05:30
Ankush Menat
bd21398252
fix: ignore perm level validation if row deleted ( #18290 )
2022-10-05 11:16:28 +05:30
Ankush Menat
b8ed8d624c
fix: ignore child tables when init-ing parent doc
2022-10-04 14:27:25 +05:30
Ankush Menat
0e0e7f276c
fix: dont assume issingle exists ( #18236 )
2022-09-29 10:45:37 +05:30
Faris Ansari
d11692c52f
fix: has_content check for fieldtype TextEditor
...
When a TextEditor field contains only an image, while checking for
content, HTML tags are stripped off including the only image.
This change adds a loose but explicit check for img tag.
2022-08-17 14:40:40 +05:30
Sagar Sharma
d88d9f5186
fix: max_positive_value for Integer types ( #17712 )
...
* fix: max_positive_value for Integer types
* style: formatting
Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2022-08-02 15:48:54 +05:30