* 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
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
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.
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
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
### 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
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
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.