Commit graph

2050 commits

Author SHA1 Message Date
Faris Ansari
d11692c52f fix: has_content check for fieldtype TextEditor
When a TextEditor field contains only an image, while checking for
content, HTML tags are stripped off including the only image.
This change adds a loose but explicit check for img tag.
2022-08-17 14:40: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
2735d1c558
Merge branch 'develop' into refactor-oauth-tests 2022-08-05 15:37:41 +05:30
Sagar Vora
f9bfbfec98
perf: reduce DB calls made in get_fetch_values (#17671)
* perf: reduce DB calls made in `get_fetch_values`

* fix: ensure return value is same as before

* test: add test for `frappe.model.utils.get_fetch_values`
2022-08-05 11:52:37 +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 Sharma
d88d9f5186
fix: max_positive_value for Integer types (#17712)
* fix: max_positive_value for Integer types

* style: formatting

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2022-08-02 15:48:54 +05:30
Ankush Menat
2e85a49fd2
refactor: remove test doctype from core (#17598)
This was commited by mistake, instead of using the test doctype, create
it on demand for tests.
2022-08-01 19:05:13 +05:30
Sagar Vora
d6aa17cc14 chore: add deprecation warning everywhere verbose is used 2022-07-31 00:24:21 +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
d83712d553 feat: delete support for virtual doctypes from desk 2022-07-22 15:42:04 +05:30
Ankush Menat
4c877258f0 test: add tests for virtual doctype desk interactions 2022-07-22 15:34:54 +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
e8efd64dbc refactor!: better API contracts for virtual doctype
Current APIs implement class methods as instance method, which is
problamamtic while implementing methods. E.g. If load_from_db doesn't
like empty docname then all class method will stop working.

This change while breaking is essential for usability of virtual
doctype.
2022-07-22 14:26:02 +05:30
Ankush Menat
e88bc35cae refactor: move is_virtual_doctype to relevant file 2022-07-22 14:25:48 +05:30
Gavin D'souza
1dbc0b4d3c fix(db*): Use common fallback Datetime str
There existed inconsistencies between db_query & db's fallback for min
datetime in str format - missing decimal seconds places. Now, we're
storing the default string once and re-using it to reduce
inconsistencies or room for human errors.
2022-07-22 13:19:25 +05:30
gavin
d285ce910f
Merge branch 'develop' into mariadb-client-refactor 2022-07-22 12:11:54 +05:30
Ankush Menat
e7082d611f
fix: broken realtime doc change updates (#17567) 2022-07-20 21:05:23 +05:30
Gavin D'souza
1ccdad811a Merge branch 'develop' of github.com:frappe/frappe into mariadb-client-refactor 2022-07-19 16:23:24 +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
95f67b8de8
fix: ignore empty part in naming series (#17508)
on v13 doc.get("") returns entire doc dictionary, this gets strigified
and becomes a problem for naming.
2022-07-14 13:14:58 +05:30
Ankush Menat
e652811d55 fix: ignore virtual fields when doing db_update 2022-07-11 18:33:50 +05:30
Ankush Menat
111060224b fix: naming series tool doesn't load if missing numbers 2022-07-07 17:38:52 +05:30
Gavin D'souza
71b5c77e6e Merge branch 'develop' of github.com:frappe/frappe into mariadb-client-refactor 2022-07-05 14:55:02 +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
60c4819373
refactor: safer binding of outer scope in closures (#17389) 2022-07-04 13:39:56 +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 D'souza
cf699fe40b Merge branch 'develop' of github.com:frappe/frappe into mariadb-client-refactor 2022-06-29 13:49:18 +05:30
Ankush Menat
181833848f
Merge pull request #17337 from ankush/lint_cleanup
fix: remove bare exception catching
2022-06-29 11:39:05 +05:30
Ankush Menat
c8ac3f922e Revert "fix: extra column in excel after exporting report with group by (#17126)"
This reverts commit 971b8160a3.
2022-06-28 18:40:27 +05:30
Ankush Menat
d35d7ffbe2 fix: remove bare exception catching
A bare except catches lots of things (like generator iteration end) and should never be used.
2022-06-28 18:05:00 +05:30
gavin
bb0283a1cf
Merge branch 'develop' into mariadb-client-refactor 2022-06-28 14:57:21 +05:30
Shariq Ansari
971b8160a3
fix: extra column in excel after exporting report with group by (#17126)
Co-authored-by: gavin <gavin18d@gmail.com>
2022-06-28 12:39:45 +05:30
gavin
d26dbc1b7d
Merge branch 'develop' into mariadb-client-refactor 2022-06-27 12:25:55 +05:30
mergify[bot]
81d41c8d3a
Merge pull request #17297 from resilient-tech/dont-remove-custom-perms
fix!: dont delete custom permissions when doctype is deleted
2022-06-26 14:22:55 +00:00
Smit Vora
b6963b1dec fix: ignore integration request when deleting doc 2022-06-26 12:53:38 +05:30
Sagar Vora
3c617e3b06 fix!: dont delete custom permissions when doctype is deleted 2022-06-26 11:51:52 +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
gavin
6a91c2cf14
Merge pull request #17141 from vishdha/_format_naming
fix: Use date/time field in document naming
2022-06-23 16:35:16 +05:30
gavin
574f160d3c
Merge branch 'develop' into mariadb-client-refactor 2022-06-23 16:13:03 +05:30
Sagar Vora
c6d8f3bc7f
fix: dont clear _meta when caching doc (#17115)
fix: dont clear meta when caching doc
2022-06-22 12:13:35 +05:30
Himanshu
a4861b2cb9
Merge branch 'develop' into _format_naming 2022-06-20 16:09:23 +05:30
gavin
73f6141e0d
Merge branch 'develop' into mariadb-client-refactor 2022-06-20 15:31:53 +05:30
Gavin D'souza
48243346e3 fix(get_contact_list): Don't pass conditions as query value
* Conditions passed are not valid prepared statement values. They
can be passed as string substitution since they're generated by DBQuery.
* Added typing hints & other improvements
* Removed seemingly pointless try-except block
2022-06-20 13:10:03 +05:30
Raffael Meyer
7b67e1f847
fix: translate doctype in error messages (#17239) 2022-06-20 10:35:57 +05:30
vishdha
27f2cdf016 chore: remove unused code 2022-06-17 13:59:21 +05:30
vishdha
ea18460cc2 fix: date_field not able to fetch in _format_naming autoname 2022-06-17 13:59:21 +05:30