Commit graph

92 commits

Author SHA1 Message Date
Ankush Menat
039be73af4
refactor: Consider singles for dynamic set_value usage (#21367)
Found all usage using this semgrep rule:

```yaml
    - pattern: frappe.db.set_value($DOCTYPE, ...)
    - pattern-not: frappe.db.set_value("$STR", ...)
```
2023-06-14 10:46:25 +05:30
Ankush Menat
4a81d9f8e3
feat!: populate fields from kwargs in frappe.new_doc (#21190)
This makes it similar to `get_doc` API BUT still signifies intent that
it's a "NEW" document.

Minor Breaking Change: positional arguments are now forcefully keyword
arguments. Only seems to be used internally from what I can tell.

https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/frappe/.*+/frappe.new_doc%5C%28.*%3F%2C.*%3F%5C%29/+lang:python+&patternType=regexp&case=yes&sm=0&groupBy=repo
2023-05-31 12:29:31 +05:30
Raffael Meyer
c7ef28fa0c
fix: don't validate to & from dates if any one is missing in validate_from_to_dates (#19079) 2022-12-03 18:32:59 +05:30
Ankush Menat
a6af1ed542 feat: bulk insert simple Document objects 2022-11-28 15:32:20 +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
Ankush Menat
061a9aa2ab test: db_set does not query for new doc
[skip ci]
2022-10-19 10:58:29 +05:30
Ankush Menat
b8ed8d624c fix: ignore child tables when init-ing parent doc 2022-10-04 14:27:25 +05:30
mergify[bot]
615b27b675
Merge pull request #17854 from netchampfaris/text-editor-has-content
fix: has_content check for fieldtype TextEditor
2022-08-17 11:57:36 +00:00
Ankush Menat
3e2d2a703a test: Use FrappeTestCase everywhere 2022-08-17 16:39:42 +05:30
Ankush Menat
41af9621cd test: undo custom field creation 2022-08-17 16:39:42 +05:30
Faris Ansari
10e49a19b8 test: Text Editor only image content 2022-08-17 15:45:11 +05:30
Ankush Menat
e7082d611f
fix: broken realtime doc change updates (#17567) 2022-07-20 21:05:23 +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
Suraj Shetty
ff6a2e11d1 test: Update test case and add more assertions 2022-05-31 15:00:09 +05:30
Suraj Shetty
e740d72468 refactor: Use boolean while setting a flag 2022-05-30 16:29:46 +05:30
Suraj Shetty
1d9d395d76 test: Case to validate Web Link authentication 2022-05-30 15:35:47 +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
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
4bb5ea609c
fix: get currency name from DB only if options are set and value is truthy (#16382)
* fix: call `frappe.db.exists` only if `options` are set and value is truthy

* fix: sider issue

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>

* fix: use `get_value` instead of `exists`

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>

* test: ensure currency formatting works without currency set in df options or param

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2022-03-23 19:28:01 +05:30
Karthikeyan Singaravelan
880832671a fix: use assertEqual instead of assertEquals for Python 3.11 compatibility 2022-03-21 11:05:43 +00:00
Sagar Vora
c6049d7e7c
fix: always execute method if found in __dict__ (#15958)
285823
2022-02-28 12:42:08 +00:00
mergify[bot]
1df33cbfcf
Merge pull request #15975 from resilient-tech/fix-limit-without-filter
fix: limit without filter
2022-02-15 13:40:56 +00:00
Pruthvi Patel
7ce9f1eaa1 fix: limit without filter 2022-02-15 13:06:55 +05:30
Gavin D'souza
a403934265 test(fix): Generate Note to ensure at least one exists
ref: Failing Postgres CI on https://github.com/frappe/frappe/runs/5186523978?check_suite_focus=true
2022-02-15 12:03:26 +05:30
Gavin D'souza
8165cd2802 test: Add test for docfield.options virtual df usage 2022-02-01 19:00:10 +05:30
Gavin D'souza
9ca768a32c fix(test): Update test_virtual_fields 2022-01-28 12:12:30 +05:30
Gavin D'souza
57f89c8b05 test: Add test for dynamic docfield 2022-01-13 12:23:50 +05:30
Pruthvi Patel
a87899c215 test: add test for limit 2022-01-11 11:12:53 +05:30
Gavin D'souza
4b9d8c0258 fix: Remove extra Document.validate_owner validation 2022-01-04 15:31:08 +05:30
shadrak gurupnor
6c6ff2c16d fix: overriding of owner of doc
feat: Fixed the dilemma of owner field in ToDo document
2022-01-04 13:39:16 +05:30
Ankush Menat
abebd29ef4 test: fix expected failing test 2021-11-18 17:16:20 +05:30
Gavin D'souza
3446026555 chore: Update header: license.txt => LICENSE
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
2021-09-03 12:02:59 +05:30
Suraj Shetty
81cada8b6e
Merge branch 'develop' into get-frmt 2021-08-04 14:20:21 +05:30
Kenneth Sequeira
13caf6910a fix: test_document test fix 2021-06-15 22:33:06 +05:30
Kenneth Sequeira
3336915dae fix: test_document test 2021-06-12 23:15:47 +05:30
Kenneth Sequeira
4bafae6e38 fix: add test cases 2021-06-12 22:04:00 +05:30
Gavin D'souza
e407b78506 chore: Drop dead and deprecated code
* Remove six for PY2 compatability since our dependencies are not, PY2
  is legacy.
* Removed usages of utils from future/past libraries since they are
  deprecated. This includes 'from __future__ ...' and 'from past...'
  statements.
* Removed compatibility imports for PY2, switched from six imports to
  standard library imports.
* Removed utils code blocks that handle operations depending on PY2/3
  versions.
* Removed 'from __future__ ...' lines from templates/code generators
* Used PY3 syntaxes in place of PY2 compatible blocks. eg: metaclass
2021-05-26 15:31:29 +05:30
Suraj Shetty
d58191346e test: Fix exception & remove unnecessary test 2021-05-05 16:17:50 +05:30
Suraj Shetty
618e23ad90 test: Fix test dependencies 2021-05-05 15:45:58 +05:30
Gavin D'souza
8a6bdf5466 chore: Move rename doctype method to dedicated TestCase
Co-authored-by: Marica <maricadsouza221197@gmail.com>
2020-11-27 16:49:49 +05:30
gavin
91822b3c3d
Merge branch 'develop' into rename-doc-rename-link-fields 2020-11-09 15:45:37 +05:30
marination
841f2f4a36 chore: Rename Doctype Test and more explicit comment
- Better decription of why the fix is done, what case it handles
- Test for Renaming Doctype and Record having same name as DocType
2020-11-03 21:57:26 +05:30
Deepesh Garg
dbd8f52e54 feat: Non negative check for Int, Float and Currency fields 2020-10-29 16:40:38 +05:30
Rushabh Mehta
62a8774bb1
feat(role permission): if desk access is removed from a role, attempt to remove it from users too (#10838)
* feat(minor): if desk access is removed from a role, attempt to remove it from users too

* fix(minor): exception for install;

* fix(minor): exception for install
2020-06-29 02:43:23 +00:00
Gavin D'souza
2c1ffaae9c fix(test): update test for updated bleach behaviour
bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1623633
2020-04-10 12:13:48 +05:30
Gavin D'souza
28b2ee0455 chore: added rename_doc tests 2019-12-23 11:05:39 +05:30
Nabin Hait
b375ee9eef fix: merge conflict 2019-06-18 18:45:21 +05:30
Nabin Hait
df438c1697
Revert "fix: Set default only if the dependent field is set (#7130)" (#7644)
This reverts commit 73c1f531e8.
2019-06-05 20:30:13 +05:30