Commit graph

326 commits

Author SHA1 Message Date
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
6993f51bf9 fix: ignore DoesNotExistError inside get_cached_value 2022-03-30 15:40:09 +05:30
phot0n
bebc8058b6 feat: integer primary keys 2022-03-11 23:46:00 +05:30
phot0n
b31f3c24f6 refactor: remove parent, parenttype, parentfield, idx columns from non-child table doctypes
* feat: add parent, parenttype, idx, parentfield columns to doctypes when transitioning from normal -> child table

* fix: remove parent, parenttype, parentfield, idx from DocType DocType
2022-02-07 15:12:37 +05:30
Gavin D'souza
ad1fedf4a8 fix: Return correct types for time utils 2022-02-02 19:46:09 +05:30
Gavin D'souza
5b6ceb5543 Merge branch 'develop' of github.com:frappe/frappe into set_value-refactor 2022-01-28 18:39:12 +05:30
Gavin D'souza
1811f464a9 Merge branch 'set_value-refactor' into set_value-refactor 2022-01-28 18:38:46 +05:30
Gavin D'souza
8037866dc1 fix: Handle parsing and formatting timedeltas
* Added utils parse_timedelta, format_timedelta
* Added to json_handler for de-serializing timedelta objects
2022-01-28 18:33:03 +05:30
saxenabhishek
efd5c197cb fix: sbool converting int stored as string 2022-01-25 03:07:34 +05:30
Gavin D'souza
429f839ea3 style: Add typing, sorted imports# 2022-01-17 15:31:37 +05:30
barredterra
b1383df15a refactor: use is None instead of == None 2022-01-17 10:37:51 +01:00
Gavin D'souza
b403d67845 fix!: Don't use strtobool in sbool util
strtobool would convert 't', 'yes' to True too. Which shouldn't be a
problem generally but could be one possibly.
2022-01-17 14:55:36 +05:30
Gavin D'souza
227dc26707 Merge branch 'develop' of github.com:frappe/frappe into set_value-refactor 2022-01-17 14:04:13 +05:30
Gavin D'souza
f5072af00d fix: sbool before cint in cast for Check types
Noticed an issue when get_single_value wasn't returning the correct
values; by converting true to 0.

Tested it out. Here's the examples:

In [2]: sbool("2")
Out[2]: '2'

In [3]: cint(sbool("2"))
Out[3]: 2

In [4]: cint(sbool("-1"))
Out[4]: -1

In [5]: cint(sbool("0"))
Out[5]: 0

In [6]: cint(sbool("1000"))
Out[6]: 1000

In [7]: cint(sbool("10_000"))
Out[7]: 10000

In [8]: cint(sbool("true"))
Out[8]: 1
2022-01-11 12:57:23 +05:30
Gavin D'souza
981564e544 Merge branch 'develop' into frappe-postgres-changes 2022-01-07 11:37:28 +05:30
Conor
40ba1ac9ba fix: Postgres Compatibility
* Handle inconsistencies in type handling in DatabaseQuery & Database
  APIs
* Update incompatible queries with frappe.qb notation
* Fixed use cases discovered by failing ERPNext CI tests

fix: db independent syntax for user_type

fix: handle postgres datetime values

feat: add ability to auto commit on db inserts

feat: add ability to escape underscore in postgres

fix: handle missing data in test runner bootstrapping

fix: db independent syntax for queries

fix: refactor to use qb

fix: update cache for language

fix: use pluck in email_queue

Co-authored-by: gavin <gavin18d@gmail.com>

fix: don't auto insert on tests for make_property_setter

fix: remove auto_commit in custom_field insertion

fix: remove auto_commit functionality

fix: review comments

fix: revert link validation

fix: style suggestion for readability

Co-authored-by: gavin <gavin18d@gmail.com>

fix: revert .lower() in link validation

fix: add rollback for setup_wizard

Revert "fix: add rollback for setup_wizard"

This reverts commit 83b3b0913db17718ccd5edae01858cff15603829.

Revert "feat: add ability to escape underscore in postgres"

This reverts commit 8ed9c2aa3306438e94bb813f60e65b416d0b947b.

fix: more concise representation of order fields

Co-authored-by: gavin <gavin18d@gmail.com>
2022-01-07 10:44:57 +05:30
Suraj Shetty
5d5ad78789 refactor: Rename week_starts_on to first_day_of_the_week
For consistency
2022-01-05 14:54:46 +05:30
Suraj Shetty
42e1c15c18 feat: Add setting to configure the day on which week starts 2022-01-04 13:00:31 +05:30
Suraj Shetty
b5e2f78a88 fix: Start week from Sunday instead of Monday
- Like we do in client-side
2022-01-03 13:36:32 +05:30
mergify[bot]
7e34c27690
fix: Incorrect timespan daterange calculation (backport #15369) (#15431)
Co-authored-by: Kartik Sharma <kartiksharma9319@gmail.com>
2021-12-24 00:20:57 +05:30
Kieran
9421736fb9
feat: add number format for BTC 2021-12-08 12:30:02 +00:00
tahir-zaqout
f3aabb5211
Add Translate To Symbol Field (#14971) 2021-11-22 05:55:19 +00:00
rohitwaghchaure
6ae352a05f
fix: ignore filename with dotted path (#14617)
* fix: ignore dotted path in file name

* fix: condition for checking file

* Update data.py

* fix: only allow pdf files

Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2021-10-28 19:23:57 +00:00
Rohit Waghchaure
5ef72dd290 feat: pdf to base64 convert 2021-10-28 12:41:27 +05:30
Jannat Patel
8aa977c5f0 fix: discussions template and time 2021-09-16 12:36:24 +05:30
Jannat Patel
5164b1627d feat: discussions-component-for-website 2021-09-14 15:57:26 +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
gavin
8394bbeb4c
chore(utils): Add type hints for get_timedelta, getdate
Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
2021-08-31 21:50:07 +05:30
Gavin D'souza
9a32513b47 chore: Update frappe.utils.data.cast docstring 2021-08-31 13:11:25 +05:30
Gavin D'souza
176d6d2d06 fix: Check if input is str is_invalid_date_string
This is sort of a breaking change? Because if an int/dict/list/tuple was
passed instead of a str, object doesnt have .startswith (AttributeError)
would be raised instead of just returning None.
2021-08-31 13:07:22 +05:30
Gavin D'souza
8622142d7d fix: Use get_timedelta in cast, add to safe_exec list
* Return date and datetime objects for Date and Datetime field types
  respectively if Falsy output is set
2021-08-31 13:06:10 +05:30
Gavin D'souza
3858e95e80 feat(utils): Add util get_timedelta
get_timedelta returns None in case of invalid or imparsable inputs. This
behaviour is consistent wrt other utils. The util, to_timedelta tries to
convert to timedelta objects only if str object is passed. It returns
the same object if not string, which is absurd...given its called
`to_timedelta`.
2021-08-31 12:57:05 +05:30
Gavin D'souza
b8c51b13e2 fix: Revert to using cast_fieldtype in BaseDocument.cast
* reference: revert Breaking Change -
  https://github.com/frappe/frappe/pull/13989#discussion_r695624003
* Show deprecation warning unless `show_warning` is unset
2021-08-30 13:45:30 +05:30
Gavin D'souza
a2cb9be7a4 feat: frappe.utils.data.cast
Cast the value to the Python native object of the Frappe fieldtype provided. If value is None, the first/lowest value of the `fieldtype` will be returned.

Mapping of Python types => Frappe types:
* float => ("Currency", "Float", "Percent")
* int => ("Int", "Check")
* datetime.datetime => ("Datetime",)
* datetime.date => ("Date",)
* datetime.time => ("Time",)

Deprecate frappe.utils.data.cast_fieldtype in favour of new util cast
which handles types "better"
2021-08-20 12:35:24 +05:30
Gavin D'souza
cb034e4c52 fix: Consistent return types in cast_fieldtype
Note: BREAKING CHANGE
2021-08-20 12:08:39 +05:30
Afshan
c7ad1be6b8 fix: format string for formating date 2021-08-06 22:10:37 +05:30
Ankush
257723cb0a
feat: PythonExpression and Python option with syntax validation for Code field types (#13707)
* feat: `PythonExpression` and `Python` options for `Code` fields

* fix: check python expressions in assignment rule

* fix: replace server script syntax validation

* fix: validate condition in workflow transition

Add PythonExpression in Options.
2021-08-06 04:10:09 +00:00
Gavin D'souza
f6b215938a fix: Use raw string to avoid invalid sequence errors
Escaped when proven easier
2021-05-26 19:30:08 +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
mergify[bot]
8ebc251394
Merge pull request #13065 from gavindsouza/api-updates
fix: Evaluate boolean values better via /api/resource/<doctype>
2021-05-26 04:41:55 +00:00
Kenneth Sequeira
6632b5876a
feat(minor): add number format parameter in fmt_money (#13255)
* feat: add number format parameter in fmt_money

* review fix: move new parameter at the end

Co-authored-by: Kenneth Sequeira <kenneth@Kenneths-MacBook-Air.local>
2021-05-24 16:14:56 +00:00
Gavin D'souza
10fe05da29 Merge branch 'develop' into api-updates 2021-05-20 17:11:43 +05:30
Suraj Shetty
0f94407e6d
Merge pull request #12969 from surajshetty3416/fix-sqli-report-get 2021-05-12 12:57:17 +05:30
leela
72ca7e9753 refactor: remove six dependency 2021-05-07 07:42:04 +05:30
Gavin D'souza
724a5b2536 fix: Evaluate boolean values better via /api/resource/<doctype>
`GET /api/resource/ToDo?limit=10&debug=False&as_dict=0` would be received by the resource handler as debug="False" and as_dict="0" which are both truthy values.

So, even though you requested for a list of lists response without debugging on, you'd get the exact opposite; debug on and a list of dicts.

- Evaluate boolean values for `GET /api/resource/<doctype>`
- Added `limit` parameter as an alias for `limit_page_length`
- Added `frappe.utils.data.sbool` that converts strings to bool values if applicable.
- Added some seemingly stupid comments for the sake of consistency.
2021-04-30 21:18:38 +05:30
Suraj Shetty
d8e91cae32 fix: Strip comments before sanitizing column_name 2021-04-23 01:20:47 +05:30
Syed Mujeer Hashmi
13a57d141e fix: timespan filter for next and last timespans
The timespan filter now considers calendar month, quarter,
half-year, and year for last and next timespans.

Signed-off-by: Syed Mujeer Hashmi <mujeerhashmi@4csolutions.in>
2021-03-16 21:12:07 +05:30
mergify[bot]
465404f66e
Merge pull request #12447 from adityahase/perf-cli
perf: Faster CLI
2021-02-25 01:44:36 +00:00
mergify[bot]
86407e5b48
Merge pull request #12446 from leela/login-attempt-tracker
refactor: Track consecutive login attempts
2021-02-24 10:11:04 +00:00
Saqib
d9737c1d25
Merge branch 'develop' into image-pf-fix 2021-02-24 12:45:21 +05:30