Commit graph

493 commits

Author SHA1 Message Date
Ankush Menat
a6af1ed542 feat: bulk insert simple Document objects 2022-11-28 15:32:20 +05:30
Aradhya Tripathi
07bd958dfd
Merge branch 'develop' into bg-submissions 2022-11-12 08:37:55 +05:30
gavin
9ad0538521
perf(doc): skip order_by when name is set in load_from_db (#18837)
Setting ORDER BY clause in the SQL nudges MariaDB to not use index
(even) for primary keys.
2022-11-10 16:53:28 +05:30
Sagar Vora
a42ca7d8c1
fix: raise exception if doc before save is not found (#18796)
* fix: raise exception if doc before save is not found

* test: ensure error is raised when trying to save new doc using `doc.save()`

* chore: add comment explaining condition

* test: clearer name and docstring
2022-11-09 19:45:41 +05:30
Aradhya
f587140f6f Merge branch 'develop' of https://github.com/Aradhya-Tripathi/frappe into bg-submissions 2022-11-04 18:34:41 +05:30
Sagar Vora
8b84042037
fix: load doc_before_save in check_if_latest (#18752) 2022-11-04 10:44:17 +05:30
Sagar Vora
6d45b500a1
perf: load _doc_before_save sooner to avoid DB call in check_if_latest (#18666)
* perf: load `_doc_before_save` sooner to avoid DB calls in `check_if_latest`

* fix: specify `for update` in `load_doc_before_save`
2022-10-29 17:55:57 +05:30
Aradhya
7cefc240ac fix: merge conflicts 2022-10-21 14:22:51 +05:30
Daizy Modi
fce9ccedaa
fix: only execute generator if value is not found in redis cache (#18472)
* fix: use of generator in

* fix: improve docstring

* fix: improve docstring

* fix: directly assign value to flags

Co-authored-by: Daizy <DaizyModi>
2022-10-20 16:48:03 +05:30
Ankush Menat
1bd61d5c25 fix: dont db_set on unsaved document 2022-10-18 17:38:03 +05:30
phot0n
3cae3d057c refactor(minor): made unlock_doc_and_update_status into a simple function
* renamed unlock_doc_and_update_status -> unlock_reference_doc
* added queued_doc property
* renamed check_locked_document -> check_if_locked
* reduced the statuses in submission queue
* refactored unlock_reference_doc a bit
2022-10-13 14:07:11 +05:30
Aradhya
fdf1ed9656 Merge branch 'develop' of https://github.com/frappe/frappe into bg-submissions 2022-10-12 19:34:00 +05:30
Aradhya
01ff3d8bcc fix: fixed locking and checking 2022-10-11 21:20:08 +05:30
Aradhya
b733c82a77 feat: Added identifier for locked state of documents
refactor(minor): removed is locked setter to avoid redundancy
2022-10-09 21:26:21 +05:30
Aradhya
0c00c34ad6 fix: temporary document locking 2022-10-09 18:44:28 +05:30
Aradhya
d8ff47aac2 fix: checking and unlocking the correct doc 2022-10-08 04:50:09 +05:30
Aradhya
9074e3e13d feat: Added unlocked button for locked documents not in queue 2022-10-08 01:38:03 +05:30
Ankush Menat
64a0e19329 Revert "fix!: Dont update modified by default in db.set_value (#18301)"
This reverts commit 6aaefd6633.
2022-10-06 22:02:31 +05:30
Ankush Menat
6aaefd6633
fix!: Dont update modified by default in db.set_value (#18301) 2022-10-06 16:01:20 +05:30
Aradhya
b15e07dd79 refactor: better locking and unlocking 2022-10-05 15:58:49 +05:30
Aradhya
198bc39085 refactor: moved submission from document class 2022-10-04 17:20:14 +05:30
Ankush Menat
b8ed8d624c fix: ignore child tables when init-ing parent doc 2022-10-04 14:27:25 +05:30
Aradhya
9cc826541f fix: fixed functionality 2022-10-04 02:41:14 +05:30
Aradhya
eae73ae5d4 feat: log reports for queued submits 2022-10-03 17:36:33 +05:30
Ankush Menat
49af8f7db1
Merge pull request #18050 from ankush/read_only_maintenance
feat: Zero* downtime migrations
2022-09-09 18:17:57 +05:30
Ankush Menat
55617b9e86 fix: defer logging during read only mode
Deferred:
- Error log
- view log
- web page view

Disable:
- "_seen" tracking used on list view to highlight unseen docs.
- "seen" on error log.
- dashboard chart last ts caching
2022-09-09 17:34:46 +05:30
phot0n
bca63f8e46 chore: remove unused update_log_for_doc_creation flag
* chore: add note/warning for log_types
2022-08-26 18:51:18 +05:30
Ankush Menat
61a9349789 perf: use is_virtual_doctype and remove limit
This reduces 1 query for each child table read

Removed limit cause with 1000+ doctypes in frappe+erpnext this cache
will just keep getting trashed for no reason. There's clear upper bound
on size so no need to limit it here.
2022-08-21 17:37:40 +05:30
Sagar Vora
c82b6e758e
Merge pull request #17681 from resilient-tech/fix-child-perm
refactor: improved child table permission check
2022-08-09 10:15:36 +00:00
Sagar Vora
7129d6128f chore: lazier import; improved docstrings 2022-08-09 11:50:15 +05:30
Gavin D'souza
b14f8f4e03 feat(minor): Expose force to doc.delete 2022-08-02 17:30:07 +05:30
Gavin D'souza
d6ba7caf92 chore: Add typing for Document.doc_before_save 2022-08-02 17:30:07 +05:30
Sagar Vora
d6aa17cc14 chore: add deprecation warning everywhere verbose is used 2022-07-31 00:24:21 +05:30
Ankush Menat
f1d638473f refactor: add reload function back
Assigning a function to a different name breaks inheritance model.

E.g. doc.reload() won't call virtual doctype's load_from_db but call
original load_from_db
2022-07-22 14:50:13 +05:30
Ankush Menat
e7082d611f
fix: broken realtime doc change updates (#17567) 2022-07-20 21:05:23 +05:30
Nabin Hait
31ef1c7355
perf: option to skip realtime notify update after insert (#17543)
While doing optimization for the period closing voucher, found that `notify_update` takes a significant amount of time to execute (200 seconds in this case), even though it was not required at all in this specific case (insert of GL Entry). That's why made the function optional by using a flag.

Related PR: https://github.com/frappe/erpnext/pull/31626
2022-07-19 09:53:04 +00:00
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
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
gruener
1349a73e14
fix: Virtual DocTypes currently breaking Parent-DocType Update and Deletion (#16977)
When you create a Virtual DocType as a Child Table (which is possible without any warning), then it will lead to several errors when updating or deleting of the parent document.

This is because the following files just execute a SQL Statement for the doctype (which doesnt have a DB Table, as this is the nature of a virtual doctype ;-)

**apps/frappe/frappe/model/document.py**
```py
frappe.db.sql("""delete from `tab{0}` where parent=%s and parenttype=%s and parentfield=%s""".format(df.options), (self.name, self.doctype, fieldname))
```

**apps/frappe/frappe/model/delete_doc.py**
```py
frappe.db.sql(
	"delete from `tab%s` where parenttype=%s and parent = %s" % (t, "%s", "%s"), (doctype, name)
)
```

So at these points, I added a check to not perform any sql command for virtual doctypes. With these changes, my affected situation is solved. Perhaps there are other situations, I didn't encounter yet.

As an additional feature, those virtual doctype models should also get an information about the parent is deleted, to propagate the deletion to the remote data pools; but for now I hope this bugfix can be approved.
2022-06-23 11:38:29 +00:00
Suraj Shetty
53a079f101 fix: doc.get_title should return empty string if title is not set
(cherry picked from commit b244c9148192362de43aa483b328709745f3be82)
2022-06-13 06:16:57 +00:00
Ankush Menat
21442f5cba perf: disable creating version for new docs
Each new doc inserts a version, this contains nothing but creator and
creation time.. which is already immutable information on the original
document.

This was added for cases like data import to track from where document
got created, ref: b7dfe7969d

Fix: only add a version on creation IF creation info is present on flags
2022-06-12 18:07:55 +05:30
gavin
44dba28159
Merge branch 'develop' into refactor-file 2022-06-08 12:43:35 +05:30
Gavin D'souza
5ec2690160 Merge branch 'develop' into refactor-file 2022-06-01 15:47:55 +05:30
Suraj Shetty
a22b22c703 fix: Remove shareable link feature 2022-05-30 13:22:51 +05:30
Suraj Shetty
0d10624ce5 Merge branch 'develop' of https://github.com/frappe/frappe into fix-document-signature 2022-05-05 14:20:29 +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
Gavin D'souza
1d84483289 Merge branch 'develop' of github.com:frappe/frappe into refactor-file 2022-04-21 11:45:50 +05:30
Gavin D'souza
892e05fdc1 Merge branch 'develop' of github.com:frappe/frappe into bg-rename_doc 2022-04-20 16:04:27 +05:30
Rushabh Mehta
6e6fe9521e fix(linting): no single quotes :'| 2022-04-18 17:29:03 +05:30