GNOME Bugzilla – Bug 348860
Error with saved multicolumn reports
Last modified: 2018-06-29 21:10:32 UTC
If I try to run a multicolumn report that I have saved in gnucash-2.0 I just get an error "Report error An error occurred while running the report." This happens no matter what I put in the report. Creating the report is fine but when I save it and then restart gnucash and run it from the Custom menu I just get this error. The console shows this: In /usr/local/opt/gnucash/share/gnucash/scm/report.scm: 418: 17* (set! doc (if template (let* # # # ...) #f)) 418: 18* (if template (let* # # # ...) #f) 419: 19 (let* (# # # ...) (gnc:html-document-set-style-sheet! doc stylesheet) ...) 421: 20* [render-view #] In /usr/local/opt/gnucash/share/gnucash/guile-modules/gnucash/report/view-column.scm: 72: 21 (let* (# # # # ...) (let # # #) (for-each # reports) ...) 88: 22* (let ((new-reports #)) (for-each (lambda # #) reports) ...) 89: 23* [for-each #<procedure #f (report-info)> ((7 1 1 #f) (6 1 1 #f))] In unknown file: ?: 24* [#<procedure #f (report-info)> (7 1 1 #f)] In /usr/local/opt/gnucash/share/gnucash/guile-modules/gnucash/report/view-column.scm: 91: 25* (let (# # # #) (if # #) (set! new-reports #)) 95: 26* (if (not callback) (begin (set! callback #) (set! report-info #))) 96: 27 (begin (set! callback #) (set! report-info #)) 97: 28* (set! callback (make-child-options-callback report #)) 98: 29* [make-child-options-callback # #f] 60: 30 (let* ((view-opts #) (child-opts #) (id #)) id) 61: 31* [gnc:report-options #f] In unknown file: ?: 32 (and (eq? (quote #) (record-type-descriptor obj)) (struct-ref obj 2)) ?: 33* [eq? #<record-type <report>> ... ?: 34* [record-type-descriptor #f] ?: 35 (if (struct? obj) (struct-vtable obj) (error (quote not-a-record) obj)) ... ?: 36 [scm-error misc-error #f "~A ~S" (not-a-record #f) #f] <unnamed port>: In procedure scm-error in expression (scm-error (quote misc-error) #f ...): <unnamed port>: not-a-record #f
Created attachment 74976 [details] Example of a saved multicolumn report I can confirm this bug. Saving (or rather, adding) a report creates a saved-reports-2.0 file like this attachment. The information on the subreports is not recorded, and that is likely to be the problem.
*** Bug 488846 has been marked as a duplicate of this bug. ***
Same problem for me in gnucash 2.2.1 I've tracked down the cause: In ~/.gnucash/saved-reports-2.0 only the layout of the multicolumn view is saved. The single reports that the composite consists of are referred to as [snip]((gnc:option-setter option) '((4 1 1 #f) (3 1 1 #f) (2 1 1 #f) (1 1 1 #f)))[snip] and those option sets are saved in ~/.gnucash/books/myfile attached to the _specific page_. Example: [Page 2] PageType=GncPluginPageReport PageName=myfundreportname SchemeOptions4=(let ((options (gnc:report-template-new-options/name "Price"))) (let ((option (gnc:lookup-option options "General" "To"))) ((lambda (option) (if option ((gnc:option-setter option) '(relative . end-cal-year)))) option)) (let ((option (gnc:lookup-option options "General" "Report name"))) ((lambda (option) (if option ((gnc:option-setter option) "Name"))) option)) (let ((option (gnc:lookup-option options "Display" "Plot Width"))) ((lambda (option) (if option ((gnc:option-setter option) 400.0))) option)) (let ((option (gnc:lookup-option options "Display" "Marker Color"))) ((lambda (option) (if option ((gnc:option-setter option) '(243.0 149.0 0.0 255.0)))) option)) (let ((option (gnc:lookup-option options "Display" "Plot Height"))) ((lambda (option) (if option ((gnc:option-setter option) 200.0))) option)) (let ((option (gnc:lookup-option options "Price" "Price of Commodity"))) ((lambda (option) (if option ((gnc:option-setter option) '(commodity-scm "EUREX" "myfund")))) option)) (let ((option (gnc:lookup-option options "Price" "Price Source"))) ((lambda (option) (if option ((gnc:option-setter option) 'pricedb))) option)) (gnc:restore-report 4 "Price" options)) [snip] So everything is fine while this page is open when closing GnuCash, because the option sets are then saved to ~/.gnucash/books/myfile. If this page is not open when closing GnuCash, the option sets are lost for ever, and so is the entire report. Closing and reopening the report page within one session works, as ~/.gnucash/books/myfile is not rewritten. Very, VERY annoying!
As meo, said, very VERY annoying. This defect prevents the saving of those reports that take the most amount of time to set up. For what little it is worth I'm adding my "me too" in the desperate hope someone might fix this soon.
It's really annoying to spend so many time creating a report, and then loose all your work. And i keep reminding myself that i have to leave the report tab open, otherwise i will loose my report on next execution. Isn't there any other way to solve this issue? For what I have seen, the problem is that it's not possible to save a multicolumn report. But that's the only (simple)way I know to create a report. Or is there any other (simple) way to create a custom report?
Here is a workaround (based on the analysis of comment #3): Copy the lines from the configuration file in ~/.gnucash/books/ to your saved-reports file. You can try it on your own risk, if you are familiar with editing saved-reports-2.0: 1. Create, edit and save the multicolumn report as usual 2. Leave the report open and close gnucash 3. Open ~/.gnucash/books/$myfile$ with a text editor and find the [Page] section for your report 4. Copy the lines starting with SchemeOptions$Number$. You don't need "SchemeOptions" without trailing number. 5. Make a backup of ~/.gnucash/saved-reports-2.0, to be sure. 5. Paste the copied lines to ~/.gnucash/saved-reports-2.0 in the section of your saved report. Just below the line like (let ((options .... "Multicolumn View"))) 6. Remove the substrings "SchemeOptions$Number$=" 7. Now you can reopen gnucash again, close the report, close gnucash, reopen gnucash and: open your Multicolumns report as a Custom report I will try to find out how to code this behavior or something similar, but am not sure, if I will get it to work.
Workaround from #6 does the trick for me.
Created attachment 123900 [details] [review] Save embedded reports to saved-reports file When writing the report options to saved-reports the embedded reports (if any exist) are stored too. This is important for saving multicolumn reports.
Committed to trunk, r17748, waiting for back-port. Thanks a lot!
I applied the patch and tested but it didn't seem to work for me. I still got the same error. I'll do a little more testing today if I can. Perhaps I did something wrong. Christian, Did you test the patch?
Ok, I must have done something wrong as it seems to be working ok. It has some very minor strange behaviors such as if I open the saved multicolumn report and then modify the options on one of the reports, then open the saved report in a new tab it retains the changed options from the first tab. This is different from other saved reports. Other than that it works great. I was trying to see if I could take a stab at it but I spent too much time looking at this when C.Ernst would have been better suited to fixing the bug.
I can confirm your "very minor strange behaviour" :-) It seems to be typical for multicolumn reports. The embedded report options are stored in memory and written to ~/.gnucash/books/$myfile$ if you close gnucash. Any changes you make to embedded reports in an open report are not stored to the saved-report (unless you don't save with a different name). So if you open the saved multicolumn report in a second tab, it references the same embedded report like the first tab and takes over it's defaults from the global options. There seems to be an additional issue with the view-column report, that now has become visible: You can't correctly rename a saved report of this type and save it again (can be seen also with 2.2.7). For now it seems to be best to have only one multicolumn tab open and not to reuse a saved multicolumn report or save it again with a different name.
2.2 branch, r17762. Thanks a lot!
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=348860. Please update any external references or bookmarks.