Commit graph

460 commits

Author SHA1 Message Date
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
Rushabh Mehta
57a55e4225 feat(minor): Add document reference to Error Log and doc.log_error 2022-04-18 17:29:03 +05:30
Gavin D'souza
4b51b72119 Merge branch 'develop' of github.com:frappe/frappe into refactor-file 2022-04-18 17:28:56 +05:30
Gavin D'souza
801874154d fix: Add return value for doc.delete 2022-04-18 12:02:19 +05:30
Ankush Menat
b409a7eeba fix: extend autoname validation to child items 2022-04-14 15:16:59 +05:30
Gavin D'souza
66655eb8ed Merge branch 'develop' of github.com:frappe/frappe into bg-rename_doc 2022-04-14 13:41:56 +05:30
Gavin D'souza
20742e396f Merge branch 'develop' of github.com:frappe/frappe into test-nestedset 2022-04-12 18:09:22 +05:30
Gavin D'souza
01e101d4b8 chore: Add typing and and style conflicts 2022-04-12 15:40:37 +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
gavin
4756efca91
Merge pull request #16477 from resilient-tech/perf-doc-get
perf: 80% faster `doc.get` for fields with `None` as value
2022-04-01 16:26:27 +05:30
gavin
3f6bbd6349
Merge pull request #16474 from resilient-tech/perf-get-doc-filters
perf: reduce query when calling `get_doc` with filters
2022-04-01 15:53:55 +05:30
Sagar Vora
428fc98fa7 chore: add comment to explain line 2022-04-01 14:28:13 +05:30
Sagar Vora
e73c552632 fix: implement for_update for Single documents 2022-04-01 14:15:35 +05:30
Ankush Menat
046f5d31af
fix: don't update autoname field when using Document.save (#16436) 2022-04-01 14:00: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
Sagar Vora
0ec26cee70 perf: use as_dict parameter 2022-04-01 01:57:09 +05:30
Sagar Vora
d3f8f676d4 fix: show parent in __repr__ only if available 2022-04-01 01:30:58 +05:30
Sagar Vora
e1cc626bd5 style: improve code readability 2022-04-01 01:18:25 +05:30
Sagar Vora
bd35734307 perf: reduce query when calling get_doc with filters 2022-04-01 00:03:54 +05:30
Sagar Vora
76779e7452 fix: incorrect logic for parenttype parameter in get_all_children 2022-03-31 10:12:44 +05:30
Gavin D'souza
28f9802fd9 fix: rollback to savepoint to avoid partial commits
It's better to keep the validations in and out AND separate...this is a
humble attempt for the same :)
2022-03-28 18:47:26 +05:30
Mohammad Hasnain Mohsin Rajan
fda544f424
refactor!: make automatically following documents optional (#16030)
* 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>
2022-03-25 02:01:15 +05:30
Gavin D'souza
d92a64e767 fix: validate before enqueuing rename_doc
* refactor validate_rename
* don't run before_rename hooks twice
* validate_rename kwarg in doc.rename
2022-03-22 14:53:22 +05:30
Suraj Shetty
ff5a909d28 refactor: Update method name
get_new_document_share_key -> get_document_share_key
2022-03-13 19:11:04 +05:30
Suraj Shetty
0514133795 Merge branch 'develop' of https://github.com/frappe/frappe into fix-document-signature 2022-03-13 18:27:39 +05:30
Gavin D'souza
c6a0469f6a fix: Remove lock record if exists 2022-03-08 17:57:18 +05:30
Gavin D'souza
69fe7eecdf Merge branch 'develop' of github.com:frappe/frappe into bg-rename_doc 2022-03-08 16:55:47 +05:30
Sagar Vora
def10e1e13 chore: remove unused variable doc_before_save 2022-03-07 12:41:45 +05:30
gavin
35c18291ec
Merge branch 'develop' into bg-rename_doc 2022-03-04 01:01:36 +05:30
Gavin D'souza
9e36005c70 fix: Remove taken file locks at end of background job 2022-03-03 20:05:05 +05:30
Suraj Shetty
eb1ed9da9d fix: Option set no_expiry 2022-03-01 19:23:01 +05:30
Suraj Shetty
8cd6b88a20 Merge branch 'develop' of https://github.com/frappe/frappe into fix-document-signature 2022-03-01 14:15:25 +05:30
gavin
873c4ad0ec
Merge pull request #16165 from gavindsouza/creation-doc-man
fix: Set creation dates of standard DocTypes correctly
2022-03-01 12:14:34 +05:30