Commit graph

29 commits

Author SHA1 Message Date
Abdeali Chharchhodawala
690826ff9b
feat!: faster generation and formatting utils for excel exports (#36323)
* feat: Style builder for report xlsx formatting

* fix: update report to use direct import for query report execution

* refactor: simplify module method retrieval in report execution

* feat: get xlsx styles for report

* refactor: enhance XLSXStyleBuilder with currency formatting and default style registration

* feat: add xlsxwriter dependency for enhanced XLSX report generation

* refactor: enhance XLSXStyleBuilder with improved style registration and formatting methods

* feat: enhance XLSX export functionality with improved styling and metadata support

* refactor: default formatting of currency

* chore: remove some typo

* feat: update make_xlsx function to use xlsxwriter for improved Excel file generation and styling

* perf: some micro optimisations

* refactor: inline generator back and improve condition

* refactor: replace frappe.request_cache with functools.cache

* fix: handle styling in email

* fix: fix old test case to handle styles in export

* refactor: enhance XLSX style handling and registration methods

* refactor: improve currency formatting logic

* fix: update make_xlsx to use constant_memory for large datasets and improve row style handling

* fix: handle None style_id in XLSXStyleBuilder methods to prevent errors

* fix: include owner field with proper doctype naming

* fix: set default date format in XLSX workbook creation

* fix: pass applied filters to metadata

* fix: getting accurate field info for report view exporting

* chore: Minor changes

* feat: add function to generate default XLSX styles for exports

* feat: integrate default XLSX styles into builder report export functionality

* feat: styles on export docs xlsx

* feat: enhance make_xlsx function to support file path saving

* feat: add make_xls function for creating Excel files in old format and improve sheet name sanitization

* fix: handle default date formatting

* refactor: changes xlsx builder usage

* refactor: update xlsx style builder usage

* refactor: enhance field info retrieval with default field support

* fix: handle update key in report data

* refactor: enhance get_field_info to include options and improve label retrieval

* fix: improve error handling for unsupported file formats and ensure applied filters are set correctly

* refactor: update XLSX header index handling and improve metadata structure

* fix: handle currency formatting in reportview export

* fix: update default date format to datetime format in XLSX creation

* fix: update serial number field in auto email report to use 'sr' instead of 'idx'

* fix: enhance XLSX styling by adding right alignment for specific field types

* chore: remove unused code

* fix: update XLSXMetadata attributes for improved report styling options

* perf: further improve currency styling

* fix: correct column index mapping in XLSX export header

* refactor: optimize indentation style registration in XLSXStyleBuilder

* perf: improve apply_indentations

* fix: reduce more attr lookup

* refactor: remove duplication

* fix: use report name in XLSX export instead of hardcoded title

* fix: remove ignore_visible_idx from XLSXMetadata

* fix: review

* fix: update XLSX style fetching logic in build_xlsx_data function

* fix: add right alignment to date, time, and datetime styles in XLSXStyleBuilder

* fix: simplify number format handling in XLSXStyleBuilder

* fix: register common styles in XLSXStyleBuilder for improved style management

* test: add tests for XLSX styles structure and fieldtype column styles in XLSXStyleBuilder

---------

Co-authored-by: Sagar Vora <16315650+sagarvora@users.noreply.github.com>
2026-04-21 19:07:43 +05:30
Aarol D'Souza
77af2d53d6
fix(system console): allow read-only queries in system console (#36652)
* fix(system console): allow read-only queries in system console

* fix(security): make transactions strictly read only for console and scripts

* test: remove test to reflect ban on cte's for security

* fix: Only enable read only mode for SQL query

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
2026-02-05 11:39:10 +00:00
Raffael Meyer
e9c81f38bc
refactor: remove ignored params from call (#35185) 2025-12-11 12:47:11 +01:00
Abdeali Chharchhodawala
4647986aeb
fix!: Always Bold report header row (#34703)
* fix: Always bold report header row

* fix: update test cases

* refactor: add option to bold filter rows in XLSX output

* chore: minor changes

* chore: rename index variable

* revert: undo bold filters param use

* refactor: remove duplication for building xlsx data

* revert: add has_filters parameter to check for filter row bold

* refactor: add type hints and docstrings for XLSX data handling functions
2025-12-11 15:55:51 +05:30
Akhil Narang
6ca4d4d167
refactor(treewide): ruff format
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2025-09-26 13:16:43 +05:30
Rahul Agrawal
c52e5157b4
feat: allow users to export report in background (#33861)
* feat: allow users to email prepared report

* fix: add export in background checkbox in export dialog

* chore: use a common function to send report email

* feat: delete generated files from system after user defined duration

* feat: add exported reports in a folder and periodically clean it

* test: add test for export via report

* fix: add exported folder path as constant

* chore: un-edit report.json

* refactor: for readability

* chore: type hint

* refactor: let the BG job fail if email fails

* refactor: consistent `report_name`

* it reads better now, e.g. attached_to_name=report_name instead of attached_to_name=title

* refactor: `return_file` to its inverse `populate_response`

* chore: more specific error message

---------

Co-authored-by: Rahul Agrawal <deathstarconsole@Rahuls-MacBook-Air.local>
Co-authored-by: Hussain Nagaria <hussainbhaitech@gmail.com>
2025-09-05 14:34:55 +00:00
David Arnold
95950c8d81
refactor: organize test contextmanagers (#28041)
* refactor: prefer staticmethod decorator

* refactor: add cm register utility and keep cms in one file

* refactor: enter safe_exec enabled context (treewide)

* refactor: move trace fields to the other test context managers

* chore: marke all test_runner functions for deprecation

* chore: mark some tests.utils functions for deprecation (moved)

* chore: mark traced_field_conext for deprecation (moved)

* chore: placate semgrep in dumpster

* fix: show deprecation warnings per module in tests (incl. from dumpster)

* chore: remove use of deprecated functions from tests
2024-10-09 02:09:19 +02:00
David Arnold
c114e5fae8
refactor: unit vs integration treewide (#27992)
* refactor: constitute unit test case

* fix: docs and type hints

* refactor: mark presumed integration test cases explicitly

At time of writing, we now have at least two base test classes:

- frappe.tests.UnitTestCase
- frappe.tests.IntegrationTestCase

They load in their perspective priority queue during execution.

Probably more to come for more efficient queing and scheduling.

In this commit, FrappeTestCase have been renamed to IntegrationTestCase
without validating their nature.

* feat: Move test-related functions from test_runner.py to tests/utils.py

* refactor: add bare UnitTestCase to all doctype tests

This should teach LLMs in their next pass that the distinction matters
and that this is widely used framework practice
2024-10-06 09:43:36 +00:00
Akhil Narang
26ae0f3460
fix: ruff fixes
Signed-off-by: Akhil Narang <me@akhilnarang.dev>
2024-02-07 17:04:31 +05:30
Gursheen Anand
4e382fb217 test: build_xlsx_data with filters 2023-12-01 13:09:31 +05:30
RitvikSardana
9368f0aee4 fix: enable server script while testing 2023-09-26 12:02:25 +05:30
RitvikSardana
9ae56289df test: code cleanup 2023-09-25 12:31:18 +05:30
RitvikSardana
32e3198c83 test: code cleanup 2023-09-24 11:34:06 +05:30
RitvikSardana
0c2c6f2aec chore: code cleanup 2023-09-24 02:36:04 +05:30
RitvikSardana
34cd943556 test: added test for conflicting column names 2023-09-24 01:31:41 +05:30
Ankush Menat
465b3f6968 test: use _dict in tests
form_dict is usually _dict, otherwise some unrelated tests will fail.
2022-11-29 11:53:52 +05:30
barredterra
87298f5d76 test: export query report as CSV 2022-11-03 12:02:16 +01:00
Ankush Menat
3e2d2a703a test: Use FrappeTestCase everywhere 2022-08-17 16:39:42 +05:30
Ankush Menat
0a73a3c708 refactor: stringify all non-excel types
style: incorrect EOF

test: excel export types
2022-07-12 15:53:55 +05:30
ruthra kumar
abd8f2c2c4 test: excel export with composite cell value 2022-07-06 12:52:47 +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
barredterra
45cbacf7b0 test: remove string column 2022-03-07 12:29:36 +01:00
barredterra
39ea6a2074 test: improve test data for query report 2022-03-07 12:12:13 +01:00
barredterra
f8b67dfbf6 feat: remove unused parameter "columns" 2022-03-03 20:28:28 +01:00
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 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
b726a8769a test: Fix query report test 2020-10-18 11:20:04 +05:30
Anurag Mishra
02d63dcc4f fix: added option to show indentation (#7855)
* fix: added option to show indentation

* fix: if check
2019-07-09 15:30:07 +05:30
Rohan
302f781fd8 fix(report): Fix file exports for reports that show totals (#6902)
* fix(report): Fix file exports for reports that show totals

* fix(report): Add tests for Query Report export
2019-02-26 16:11:55 +05:30