Commit graph

2250 commits

Author SHA1 Message Date
Ankush Menat
8155371162
fix: ignore DOCTYPES_FOR_DOCTYPE in issingle check (#21375) 2023-06-14 18:21:55 +05:30
Ankush Menat
3f3ee12338 Revert: keep supporting set_value for singles
w/ explicit check for singles

This shouldn't have any performance impact as last function call only
happens if we THINK it's single doctype. use set_single_value to avoid
that extra function call.
2023-06-14 17:30:32 +05:30
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
Ankush Menat
3005e66e45 refactor!: Drop previously deprecated code 2023-06-13 16:00:43 +05:30
Ankush Menat
8a30667a97
fix: Fetch non-cached version of Meta on Customize Form. (#21269)
* fix: Replace meta cache when uncached meta is requested

* fix: use meta from DB on customize form

* refactor: make cached kw only, use _dev_server
2023-06-12 14:59:42 +05:30
Ankush Menat
774a75dbde
perf: use cached workflow doc for transitions (#21300)
* fix: expire `RECORDER_INTERCEPT_FLAG` in one hour

Leaving this running in prod can be dangerous.

* perf: Use cached doc in workflows
2023-06-09 12:43:40 +05:30
Devin Slauenwhite
19d211f1d2
feat: rearranging standard fields in customize form (#19822)
* feat: rearranging standing fields

* fix: fixed creation of property setter

* refactor: renamed setup_sortable

* fix: loading field_order property

* refactor: removed redundant db call

* fix: field_order not found

* test: Added tests for field order in customize form

* refactor: better naming

* refactor: simplified logic

* feat: Updating field order on custom field creation

* feat: Added support for custom fiels

* refactor: moving to meta

* refactor: changed property type to json

* fix: new standard field insert order.

* fix: don't modify insert_after of system generated custom fields.

# This is because system generated fields are to be treated as standard fields. If the user restores the form to default, this value will be used to reset the original position.

# The new position of form fields are stored in the field_order Property Setter.

* fix: treat system generated fields as standard fields when sorting.

* revert: check for is_system_generated

* Revert "fix: new standard field insert order."

This reverts commit 6cdbe42f28d5944165dd100a9bb9172463951fda.

* fix: prioritize field_order over insert_after.

# Use insert_after as fallback in event the field doesn't exist in field_order

* fix(test): delete existing custom field

* fix: order of standard fields without field_order property.

* Revert "Revert "fix: new standard field insert order.""

This reverts commit c830f1ba2fe1e602b09c11a897869d9992097c1e.

* test: field order of newly migrated standard fields.

* fix(test): clear test_standard_field from previous test run.

* fix: sort with insert_after for system generated fields.

* fix(test): reset standard field creation before re-run and after successful test.

* fix: insert_after position should be + 1

* chore: remove debug statement

* test: system generated customized fields

* chore: remove print

* chore: lint all

* fix: show quick link to Table MultiSelect DocTypes

* refactor: change backend implementation of `CustomizeForm` and `Meta`

* test: simplify tests

* fix: rename `idx` to `index` for clarity

* perf: define `existing_fields` conditionally

---------

Co-authored-by: Aradhya <aradhyatripathi51@gmail.com>
Co-authored-by: Aradhya Tripathi <67282231+Aradhya-Tripathi@users.noreply.github.com>
Co-authored-by: Sagar Vora <sagar@resilient.tech>
2023-06-08 17:14:44 +05:30
Ankush Menat
fa6dc03cc8
refactor: frappe.cache() usage to frappe.cache (#21282) 2023-06-08 11:47:17 +05:30
Ankush Menat
106ff1f1ee fix: move cache clearing away from document
Passing lambda function from inside document object would keep reference
to document alive. This means increasing memeory usage in bulk
processing.

Refer https://github.com/frappe/frappe/pull/17061 for example

This also extends it to db.set_value
2023-06-03 22:53:10 +05:30
Ankush Menat
be1da0dd00 chore: remove duplicate cache clearing 2023-06-03 22:53:10 +05:30
Ankush Menat
339cbf208c fix: Cache clearing implementation 2023-06-03 22:53:10 +05:30
Ankush Menat
680cf73cba fix: link_count
This didn't work correctly, if link_count is present in cache it would
just read and dump it back in.

This has practically never worked correctly.
2023-06-03 18:44:19 +05:30
Ankush Menat
3f1c66de10 refactor: move flush_local_link_count to hook 2023-06-03 18:44:19 +05:30
Dhia' Alhaq Shalabi
efff6ebba7
fix: doctype name localization (#21197)
[skip ci]
2023-06-01 12:09:25 +05:30
Ankush Menat
4a81d9f8e3
feat!: populate fields from kwargs in frappe.new_doc (#21190)
This makes it similar to `get_doc` API BUT still signifies intent that
it's a "NEW" document.

Minor Breaking Change: positional arguments are now forcefully keyword
arguments. Only seems to be used internally from what I can tell.

https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/frappe/.*+/frappe.new_doc%5C%28.*%3F%2C.*%3F%5C%29/+lang:python+&patternType=regexp&case=yes&sm=0&groupBy=repo
2023-05-31 12:29:31 +05:30
Saurabh
aabaab0fd2
feat: used cached version of document in mapper (#21186)
* fix: in get_mapped_doc return cached version if available

* feat: specify explicitly cached version of doc in doc_mapper


[skip ci]
2023-05-31 11:15:33 +05:30
Ankush Menat
3df13ca392 feat: new operator - descendants of (inclusive)
Co-Authored-By: Faris Ansari <netchamp.faris@gmail.com>
2023-05-29 16:59:57 +05:30
Ankush Menat
43714825b0
fix: sync importable doctype before documents (#21131) 2023-05-26 15:58:26 +05:30
Sagar Vora
2eca7b4837 chore: more pythonic code
[skip ci]
2023-05-25 18:47:39 +05:30
PeterG
a182414610
fix(workflow): populate doc from db in apply_workflow (#21068) 2023-05-24 11:35:37 +05:30
Shariq Ansari
2cd8a860e5 fix: sync workspace custom block doctype while installing 2023-05-17 18:16:11 +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
Ritwik Puri
2e2c8316c6
fix: use sentinel value for checking existence of key in doc while parsing naming series (#20994) 2023-05-15 14:58:14 +05:30
Ritwik Puri
4bd32bcf04
fix: naming part should be empty if field is empty (#20978) 2023-05-14 00:41:12 +05:30
Gavin D'souza
63a605876f fix: Pass current dt as fallback parent_doctype 2023-04-27 14:37:15 +05:30
Gavin D'souza
a22cbe8ae5 fix: Setup permission_map & use get_permitted_fields 2023-04-22 14:58:28 +05:30
Gavin D'souza
a1f59c5a82 fix: Allow only search fields for select permission type 2023-04-22 12:46:15 +05:30
Gavin D'souza
36ee97a8f8 fix: Dont assume user & permission_type in get_permitted_fileds 2023-04-21 17:40:00 +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
Ankush Menat
45c86e2ff8
fix: nestedset rename (#20498) 2023-03-29 12:49:28 +05:30
gavin
3da5a84d7c
fix(meta): get_permitted_fields with no field-columns (#20401) 2023-03-20 21:00:03 +05:30
Sagar Vora
70ede18942
fix: improved implementation of between filter (#20190) 2023-03-02 09:51:02 +05:30
Shariq Ansari
c11c2303ad
Merge branch 'develop' into feat-number-card-workspace-dev 2023-03-01 19:16:21 +05:30
Sagar Vora
e0d7c9d901
chore: remove dead helper function (#20191) 2023-03-01 12:05:30 +05:30
Suraj Shetty
7abdad3282 Merge branch 'develop' of https://github.com/frappe/frappe into newsletter-analytics 2023-02-28 14:31:03 +05:30
Shariq Ansari
d37423916c fix: prioritize workspace_number_card doctype while installing 2023-02-28 13:40:40 +05:30
Suraj Shetty
b397ec3858 feat: Track count of views on newsletter emails 2023-02-23 13:45:53 +05:30
gavin
3406b6d752
fix(db_query): selecting linked fields as alias (#20085)
* fix(db_query): Don't track link_tables separately

Treat all joined tables the same, expand the fieldnames whether Table or
Link type with their respective table names

* fix(db_query): Add link join conditions for all relevant fields

* Revert "fix(db_query): Add link join conditions for all relevant fields"

This reverts commit 79622ab4cea5aa73a24f4ba7afde8e83510a79fb.

* Revert "fix(db_query): Don't track link_tables separately"

This reverts commit b8364f781e52e7ffaa7faa8878ef409b023f2288.

* fix: Check link field tables permissions in permlevel checks

* test: Fix, add for test_permlevel_fields

Previous assertion was wrong :')
added extra to check if access is fine
2023-02-22 22:14:15 +05:30
Devin Slauenwhite
d5ce94d6a5
feat: disable comment count on list view settings. (#20039)
* feat: add list view setting disable column count.

* fix: cast using sbool

* fix: make modified last-child if comment_count is disabled.
2023-02-22 18:17:45 +05:30
Rucha Mahabal
89d63ea82b
fix: false positive attr check while applying permlevel (#20069)
* fix: false positive attr check while applying permlevel

* Revert "fix: false positive attr check while applying permlevel"

This reverts commit 9114788590ce12be977df847c13b00e3bf72ac2a.

* fix: ignore AttributeError while trying to pop low permlevel fields

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2023-02-20 12:18:37 +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
Suraj Shetty
044eec35a6 fix: Do not filter columns like "_assign" & "_user_tags" 2023-02-14 14:00:42 +05:30
Ankush Menat
163b9290e3
Merge pull request #19916 from gavindsouza/distinct-get_count
fix(db_query): apply_fieldlevel_read_permissions
2023-02-14 11:56:22 +05:30
Gavin D'souza
ebc32a34f6 fix(trim-tables): Exclude virtual doctypes from query 2023-02-09 15:29:06 +05:30
Gavin D'souza
db209cbdf7 fix: Permit no fields if dt is table and no parenttype is specified 2023-02-06 13:33:49 +05:30
Gavin D'souza
5829dabf74 fix: Add DefaultValue to core_doctypes_list 2023-02-06 12:45:02 +05:30
Gavin D'souza
18395b66f0 fix(get_permitted_fieldnames): Return all fields if permissions not defined 2023-02-06 12:42:06 +05:30
Gavin D'souza
4648c287f9 fix(meta): get_permitted_fields
Don't return any fields if user doesn't have permission for at least one
field
2023-02-04 11:55:02 +05:30
Gavin D'souza
f9eff18fd0 fix(meta): Remove faulty permitted fields cache
The Meta property didn't respect user parameter passed
2023-02-03 22:12:26 +05:30
Gavin D'souza
da3b98c91a Merge branch 'develop' into distinct-get_count 2023-02-03 20:26:21 +05:30