Comments (9)
You are right @toropok . If the client does not have the permission senaite.core: Transition: Receive
granted, the sample should transition to sample_due
. With the if-else
above, the sample won't transition otherwise, but remain in registered
status. Will open another PR
from senaite.core.
Hi @toropok,
thanks for reporting your findings in this issue!
The code above is not the right solution to this problem, because also a client contact might have the permission granted to receive a sample.
The right solution is rather to pass in check_permission=True
to the receive_sample
function in line 145.
Can you check if this solves your issue?
from senaite.core.
Hmm, it seems like the permission check does not work for the temporary sample at this stage.
Maybe it is sufficient for this functionality to check if the current user has the LabManager
role instead of checking the permission of on the object itself.
from senaite.core.
For the records:
With #2359 we increased the performance for the sample create process by changing the initial workflow state of samples from sample_registered
to sample_due
or sample_received
directly and bypass the transition.
Due to this change, we also move from sample_registered
-> sample_received
directly.
However, at the state sample_registered
, we do not allow any permissions.
Therefore, a permission check for senaite.core: Transition: Receive Sample
will always return false, no matter which role the current user has.
Also see the comment in the code at https://github.com/senaite/senaite.core/blob/2.x/src/bika/lims/utils/analysisrequest.py#L179-L187:
def receive_sample(sample, check_permission=False, date_received=None):
"""Receive the sample without transition
"""
# NOTE: In `sample_registered` state we do not grant any roles the
# permission to receive a sample! Not sure if this can be ignored
# when the LIMS is configured to auto-receive samples?
if check_permission and not can_receive(sample):
return False
...
This leaves us with the following options:
- Grant the permission
senaite.core: Transition: Receive Sample
at the statesample_registererd
to the default roles. - Check just the roles of the current user and allow only e.g.
LabManager
andLabClerk
to receive the sample. - Check the default roles for the permission
senaite.core: Transition: Receive Sample
and check if the current user has one of these roles granted.
from senaite.core.
I vote fot the first option, grant the senaite.core: Transition: Receive
Sample at the state sample_registered
to the default roles. At least it feels less an exception to the norm.
from senaite.core.
Another option would be to "always" try the transition, without the need of checking the value for the setting at setup. And let the mutator of the setup settint to grant/revoke the permission for default roles in sample_workflow and registered
status.
from senaite.core.
It should be fixed with #2419
Please check @toropok and give feedback if this works for your use case as well.
from senaite.core.
It should be fixed with #2419 Please check @toropok and give feedback if this works for your use case as well.
@ramonski im sorry for long waiting. Please, check our microfix below (line 144), this makes it work amazing :) just as before for our use-case.
With the code you proposed, when client create sample it appears to be in "Registered" state. However if I understand this if-elif-else
block properly the result state should be "sample due".
if not IReceived.providedBy(ar):
setup = api.get_setup()
# Sampling is required
if ar.getSamplingRequired():
changeWorkflowState(ar, SAMPLE_WORKFLOW, "to_be_sampled",
action="to_be_sampled")
elif setup.getAutoreceiveSamples() and can_receive(ar):
receive_sample(ar)
else:
changeWorkflowState(ar, SAMPLE_WORKFLOW, "sample_due",
action="no_sampling_workflow")
thanks a lot for your time and attention!
from senaite.core.
thanks guys!
from senaite.core.
Related Issues (20)
- Analyses not sorted in Transposed Multiresult Form HOT 1
- Interims missing in Transposed Multiresult Form HOT 1
- No save button for sample information dependent on Manage Sample Form Fields
- failed to create an analysisspec with ResultsRange field by jsonapi
- Calculating datetime differences in Senaite (Bika) calculations appears to be problematic HOT 8
- Spotlight search malfunction after upgrade HOT 2
- Interims field cannot be imported appropriately via two dimension csv
- Usability improvements for setup page HOT 2
- Reference definitions are not able to handle minus values HOT 1
- Lab's account number with a Supplier
- Add Sample Fields, Search By Remarks
- Remarks field on Report with TinyMCE HOT 3
- Error Customizing plone.links.favicon View for ISenaiteCore Interface HOT 8
- app.listing search_box encoding issue (CoffeeScript) HOT 6
- Expand app.listing items selection options [improvement] HOT 3
- Worksheet print templates sorting feature HOT 1
- Worksheet table QC SlotHeader displays Keyword instead of QC Title
- Migrating to Python3 HOT 5
- Retract/Retest action kills HIDDEN mark of the analysis while recreates
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from senaite.core.