Commit graph

226 commits

Author SHA1 Message Date
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
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
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
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
18395b66f0 fix(get_permitted_fieldnames): Return all fields if permissions not defined 2023-02-06 12:42:06 +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
4accf0ed9d fix: Consider virtual fields in fields with values conditionally 2023-01-25 12:38:15 +05:30
Gavin D'souza
5c5bd2b104 refactor: Meta.get_permitted_fieldnames
* Remove older API that returned list[df]
* Rename fields in usage scope & Meta internals
2023-01-24 13:09:43 +05:30
Gavin D'souza
d71522091e fix: Apply permlevel restrictions to DatabaseQuery
Allow reading only accessible fields for given user session if
ignore_permissions (get_all) is unset.
2023-01-09 15:47:21 +05:30
Sagar Vora
d072e20cbd chore: fix typo 2022-12-23 06:13:07 +00:00
Sagar Vora
7fdcafddce chore: remove code for handling old dict cache 2022-12-23 06:13:07 +00:00
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
Raffael Meyer
04d1292cf1
fix: consistent translation in meta.get_label (#19080) 2022-12-02 23:38:15 +05:30
Ankush Menat
a6af1ed542 feat: bulk insert simple Document objects 2022-11-28 15:32:20 +05:30
Sagar Vora
cb7d25a293
fix(meta): ensure that insert_after is always considered when sorting fields (#18682)
* fix(meta): ensure that `insert_after` is always considered when sorting fields

* test: add nosemgrep to comment

Co-authored-by: Dany Roberts <danyrt@wahni.com>
2022-10-31 15:37:55 +05:30
Ankush Menat
2b6fc68088
Revert "fix: drop Meta cache during update" (#18186)
* Revert "fix: drop Meta cache during update (#18182)"

This reverts commit 656f6df257.

* fix: replace meta cache keys

Old keys stored different types of data `dict` changing key to indicate
change in type.
2022-09-19 21:28:45 +05:30
Ankush Menat
656f6df257
fix: drop Meta cache during update (#18182) 2022-09-19 19:24:17 +05:30
Sagar Vora
b529c27cb5 fix: ensure error is thrown 2022-09-19 16:21:11 +05:30
Sagar Vora
6c6a969d3a perf: simpler, faster meta cache 2022-09-19 16:21:11 +05:30
Sagar Vora
df8399f5d3 perf: initialise field map when initialising meta 2022-09-19 16:21:11 +05:30
Sagar Vora
fc3ee12baf
perf: cache FormMeta directly (#18165)
* perf: cache `FormMeta` directly

* perf: check if `dt` is table, use `db.get_value` instead of `get_all`
2022-09-19 16:10:32 +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
Sagar Vora
2b873b34dd refactor: remove verbose parameter; add user parameter to Meta.get_permlevel_access 2022-07-30 23:52:20 +05:30
Ankush Menat
261fbfcd11
Revert "fix(doc)!: Always cast datetime, date and time fields"
Revert "fix(doc)!: Always cast datetime, date and time fields (#15891)"

This reverts commit d7789ab6ff.
2022-07-05 13:43:32 +05:30
Himanshu
d7789ab6ff
fix(doc)!: Always cast datetime, date and time fields (#15891)
### BREAKING CHANGE
#### Datetime, Date and Time fields will always be cast to respective objects in `setattr`, this will ensure uniformity while accessing the values, no more `getdate`, `get_datetime`, `to_timedelta` wrapper.
- While importing data, the framework does check for `set_only_once`.
- In normal case scenarios, this will work flawlessly since most date fields might not be set_only_once.
- But in Subscription, the date field is set to `set_only_once` and in `after_insert`, `document.save` is called, and while doing so, `set_only_once` is checked [here](1944a547f9/frappe/model/document.py (L566)).
-This works fine if the data imported is in the correct format.
- If the date's data is not in the correct format, the framework throws an error.
- for eg `06-02-2022 00:00:00 != 06-02-2022`
- fixes [Issue/#15370](https://github.com/frappe/frappe/issues/15370)

> no-docs
2022-07-05 07:07:16 +00:00
Ankush Menat
9a5d11234c
fix: validate scheduler, hook method names (#17400)
* chore: warn about missing scheduler / doc events

* fix: pass list instead of filter

filter can only be iterated upon once

* refactor: many typehints in __init__.py
2022-07-04 19:29:16 +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
gavin
fc9308f8ba
fix: Use same labels for standard fields throughout interfaces (#17031)
* fix(model)!: Match labels in meta & model

Labels for fields have been inconsistent. In standard filters, doc.name
would be labelled as "Name" while it's "ID" in the edit filters option.
Similarly for other fields, the same view will address the same fields
differently. This PR aims to get rid of such inconsistencies.

Changes:

* [model] Change label ID for name to 'Name'
* [meta] Match labels of owner, modified, modified_by
* [meta] Add labels for more fields - from model.js

* fix!: get_label to fetch labels as Desk does

* fix!(label): Refer to name field as 'ID' over 'Name'

* test: Use 'ID' label instead of 'Name'
2022-06-09 15:34:57 +05:30
Ankush Menat
15dbcacd56 refactor: split transaction and prefix functions
refactor: fetching transaction list

refactor: get default naming series

refactor: simplify naming series option scrubbing

fix: remove dead code related to insert series

This code is dead in many ways
- Creates map but it's never evaluated, so it doesn't actually run :D
- Just randomly splits naming series parts to create prefix... makes no
  sense.

fix: deduplicate prefix list
2022-05-31 11:53:40 +05:30
chillaranand
1d763a6659 refactor: Fix flake8 issues 2022-05-19 15:34:35 +05:30
Sagar Vora
a33c2e2abe
refactor(BaseDocument)!: improved get, set and extend methods (#16540)
* perf!: 80% faster doc.get for fields with `None` as value

* perf: quicker init child (#3)

* refactor: avoid repitition and improve error message

* test: `doc.extend`

* fix: improve constant naming

* fix: minor improvements and tests

* refactor: improve naming
2022-05-04 18:37:06 +05:30
Suraj Shetty
6b7fda495b Merge branch 'develop' of https://github.com/frappe/frappe into phone_field_control 2022-04-14 14:19:35 +05:30
Sagar Vora
77879933ce style: make changes as per linter 2022-04-13 13:21:01 +05:30
Sagar Vora
38959637e7
perf: move less expensive condition first
Co-authored-by: gavin <gavin18d@gmail.com>
2022-04-13 11:40:35 +05:30
Sagar Vora
93051389b1 fix: use isinstance instead of looping over __dict__ 2022-04-13 11:20:01 +05:30
Noah Jacob
c2f2fc10e7 Merge branch develop into phone_field_control 2022-04-12 20:40:29 +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
Sagar Vora
aedd2fb2b6
Revert "perf: 80% faster doc.get for fields with None as value" (#16490) 2022-04-01 20:39:27 +05:30
Sagar Vora
811c213082 perf: 80% faster doc.get for fields with None as value 2022-04-01 04:35:19 +05:30
Noah Jacob
579d0643c4 Merge branch 'develop' into phone_field_control 2022-03-22 15:05:45 +05:30
mergify[bot]
32024b4440
Merge pull request #15990 from hrwX/translated_doctype_links
fix: Merge groups for doctype links
2022-02-16 05:24:56 +00:00
hrwx
1a912aa787 fix: merge groups for doctype links 2022-02-15 15:14:22 +00:00
Gavin D'souza
0482f1362a Merge branch 'develop' of github.com:frappe/frappe into dynamic-docfields 2022-02-08 16:50:58 +05:30
phot0n
7bd84496c1 fix: use int for docstatus in get_default_df 2022-02-07 16:43:16 +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
Gavin D'souza
4d00579667 fix: Skip data field validations for virtual field 2022-02-01 18:38:31 +05:30