Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Analyses to an existing Worksheet in a non-open status fails #1281

Closed
Espurna opened this issue Mar 14, 2019 · 3 comments
Closed

Adding Analyses to an existing Worksheet in a non-open status fails #1281

Espurna opened this issue Mar 14, 2019 · 3 comments

Comments

@Espurna
Copy link

Espurna commented Mar 14, 2019

Steps to reproduce

1- Open an already created Worksheet with assigned Analyses.
2- Open the label to add more analyses to the worksheet.
3- Select an analysis and assign it to the worksheet

Current behavior

The new assigned analyses are not assigned to the worksheet and no error is displayed.

Expected behavior

The new assigned analyses to be assigned to the worksheet

Screenshot (optional)

First screen of the Worksheet:

Selection_008

Analyses selected:

Selection_009

Worksheet/Analyses view after clicking on "assign":

Selection_010

@Espurna Espurna added Bug 🐞 P0: Critical Version 1.3 SENAITE Core Version 1.3.x labels Mar 14, 2019
@ramonski
Copy link
Contributor

Seems like addAnalysis of Worksheets only allow to add Analyses if the state is open:
https://github.com/senaite/senaite.core/blob/master/bika/lims/content/worksheet.py#L162

@xispa
Copy link
Member

xispa commented Mar 14, 2019

worksheet_workflow has the transition rollback_to_open available in to_be_verified state:
https://github.com/senaite/senaite.core/blob/master/bika/lims/profiles/default/workflows/bika_worksheet_workflow/definition.xml#L110-L114

And we always try to do a rollback on analysis assignment here: https://github.com/senaite/senaite.core/blob/master/bika/lims/content/worksheet.py#L207

I think we can safely remove this check if we add a condition in analysis guard to not allow the assignment if the current worksheet is closed or verified.

@xispa
Copy link
Member

xispa commented Mar 14, 2019

Umm, somehow, not allowing to add analyses when the worksheet is in to_be_verified state is the expected behavior. Also, considered in the doctest:

But if I remove the remaining analysis, the status of the Worksheet is promoted
to `to_be_verified`, cause all the analyses assigned are in this state:

    >>> fe = filter(lambda an: an.getKeyword() == "Fe", analyses)[0]
    >>> worksheet.removeAnalysis(fe)
    >>> fe.getWorksheet() is None
    True
    >>> api.get_workflow_status_of(fe)
    'unassigned'
    >>> api.get_workflow_status_of(worksheet)
    'to_be_verified'

And now, I cannot add analyses anymore:

    >>> worksheet.addAnalysis(fe)
    >>> filter(lambda an: an.getKeyword() == "Fe", worksheet.getAnalyses())
    []
    >>> fe.getWorksheet() is None
    True
    >>> api.get_workflow_status_of(fe)
    'unassigned'

Neither remove:

    >>> worksheet.removeAnalysis(au)
    >>> map(lambda an: an.getKeyword(), worksheet.getAnalyses())
    ['Au']
    >>> au.getWorksheetUID() == api.get_uid(worksheet)
    True
    >>> api.get_workflow_status_of(au)
    'to_be_verified'

excerpt from https://github.com/senaite/senaite.core/blob/master/bika/lims/tests/doctests/WorkflowAnalysisAssign.rst#assign-transition-and-guard-basic-constraints

So, what do you suggest?
a) Boil out the check and allow the addition of analyses when worksheet is in to_be_verified status
b) Only display the "Add *" views from inside Worksheet when is in an open status

@xispa xispa changed the title Adding Analyses to an existing Worksheet fails Adding Analyses to an existing Worksheet in a non-open status fails Mar 15, 2019
@xispa xispa closed this as completed Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants