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.
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
* fix: make automatically following documents optional
* fix: optimize email triggers for document followed
* test: add tests for document follow settings
* test: sync global search before testing
* fix: extend pypika's cast function to mimic varchar cast in MariaDB
Co-authored-by: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com>
Co-authored-by: phot0n <ritwikpuri5678@gmail.com>
* Make args "internal" to avoid name collision. Added __ since these
args would be utilized by the internal API alone
* perf(EAFP): Try taking a lock and then figure out if there's an error
instead of the double computation
* Notify document update on completion of Document Action
Transform current document object using the rename_doc API. The design
of the API should allow for easy action queueing.
Defined as `rename(self, name: str, merge: bool = False, force: bool = False)`
Usage:
In [1]: doc = frappe.get_doc("Person", "5a188f66c1")
In [2]: doc.rename("5a188f66c2")
In [3]: doc.name
Out[3]: '5a188f66c2'