specify / specify7

Specify 7
https://www.specifysoftware.org/products/specify-7/
GNU General Public License v2.0
66 stars 36 forks source link

Inconsistent Label Generation for same Collection Object #3570

Closed melton-jason closed 9 months ago

melton-jason commented 1 year ago

Some more strange label report behavior ... .

The label report should be excluding labels that don’t have the current determination, and should exclude labels for preparations with sizes other than the selected ones (we have Large, Small, and Mini labels for different size jars).

We create tissue labels in Excel and there is no tissue label report in Specify (that value is just a placeholder in the table) so it is odd that it is generating “small” labels for those.

  • FWRI

Describe the bug There seems to be an inconsistent generation of labels among all of the different ways one can generate a label.
More specifically, among the 'Generate Label' button on the form ('Generate Label on Save' checkbox produces the same behavior), and manually identifying the Collection Object (in this case via catalog number) in the report in the Reports Dialog.

I have prepared a simple test Collection Object record to demonstrate this issue.

I will be using the Small Labels JRXML App Resource as a Label throughout this example.

Note that the Report Query is only supposed to fetch records that have a Small Label Size for their Preparations

fwri_report_query_line

Here are the preparations on the test Collection Object record. fwri_test_preps

When the Collection Object is saved (when the 'Generate Label on Save' checkbox is checked), or when the Generate Label button is pressed on the form and the Small Labels Label selected, the following Label is generated:

fwri_test_label_button

As shown in the Report Query, this Label should NOT have any information for the Tissue preparation. In fact, Specify will generate a Label for ALL Preparations on the Collection Object, regardless of its data.

If the Catalog Number (000165434) is manually entered into the Small Labels Report Query, then the correct and expected Label is generated: fwri_test_manual_report

Possible Explanation It appears that somehow the Query might be undefined when the Label is run. I think that instead of a Query, the Label is using all of the available data on the Collection Object as a substitute for a Query.

This would make sense, given the Label Definition. Here is a relevant section.

<textFieldExpression   class="java.lang.String"><![CDATA[$F{1,63-preparations.preparation.countAmt}==null?"":"Count: "+$F{1,63-preparations.preparation.countAmt}+" Pres. "+$F{1,63-preparations.preparation.text2}]]></textFieldExpression>

Nowhere in the logic of the Label does it check for the Label Size of the Preparation (preparation.remarks in the database), as this is supposed to be filtered out when the Query is executed.

For future and easy reference for the Developer tasked to this issue, the Generate Label button is rendered via the following function. https://github.com/specify/specify7/blob/de940f090b68553f063b40fe15be22077b5099b9/specifyweb/frontend/js_src/lib/components/FormCommands/index.tsx#L20-L52

Desktop: Replicated on:

Reported By Florida Fish and Wildlife Research Institute (FWRI)

grantfitzsimmons commented 1 year ago

Where can we tell Specify which report to run on the 'Generate Invoice on save' command? We seem to be running an outdated query/report which shouldn't even be accessible anymore via that function. I looked through all sorts of backend config files but didn't spot anything.

This is in S7. We only have one Loan report in the list but is seems that we run an old query with it (which results in duplicate records in the Loan Invoice) when run via the generate on save. This is based on comments I received from back in Canberra. I'll give it a spin later tonight to see if I can figure out what's going on.

Ok, I can confirm that I get a pop-up when I go via Generate on Save. I'm selecting the same report as via the Reports menu, but the output is different. The same happens for a specific loan label report we built. It looks like the Generate on Save ignores the determination.present=True query line, which is something we initially forgot but subsequently added into the query. These are the only reports in the system, both built in S6 iReport.

Behavior is different based on where you run the report from for Corinna at CSIRO as well.

melton-jason commented 1 year ago

Also see https://github.com/specify/specify7/issues/3141#issuecomment-1569495107

zoewarner1 commented 12 months ago

Hello - just a bump from us (CSIRO) on this one, as our users have queried us again on this issue. Thanks!