diff --git a/CHANGES.rst b/CHANGES.rst index b0856bb1bc..abb1e6bad1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,8 @@ Changelog **Added** +- #1436 Setting in setup for auto-reception of samples upon creation +- #1433 Added Submitter column in Sample's analyses listing - #1441 Added Auto ID Behavior for Dexterity Contents - #1431 Added Submitter column in Sample's analyses listing - #1422 Notify user with failing addresses when emailing of results reports diff --git a/bika/lims/content/bikasetup.py b/bika/lims/content/bikasetup.py index deb249a4ed..e57f8c5a8e 100644 --- a/bika/lims/content/bikasetup.py +++ b/bika/lims/content/bikasetup.py @@ -528,6 +528,19 @@ def getCounterTypes(self, instance=None): " when 'Sampling workflow' is active") ), ), + BooleanField( + "AutoreceiveSamples", + schemata="Sampling", + default=False, + widget=BooleanWidget( + label=_("Auto-receive samples"), + description=_( + "Select to receive the samples automatically when created by " + "lab personnel and sampling workflow is disabled. Samples " + "created by client contacts won't be received automatically" + ), + ), + ), BooleanField( 'ShowPartitions', schemata="Appearance", diff --git a/bika/lims/workflow/analysisrequest/events.py b/bika/lims/workflow/analysisrequest/events.py index 7eb6755d2f..8edc785c19 100644 --- a/bika/lims/workflow/analysisrequest/events.py +++ b/bika/lims/workflow/analysisrequest/events.py @@ -25,6 +25,7 @@ from bika.lims.interfaces import IVerified from bika.lims.utils import changeWorkflowState from bika.lims.utils.analysisrequest import create_retest +from bika.lims.workflow import doActionFor as do_action_for from bika.lims.workflow import get_prev_status_from_history from bika.lims.workflow.analysisrequest import AR_WORKFLOW_ID from bika.lims.workflow.analysisrequest import do_action_to_analyses @@ -45,6 +46,18 @@ def before_sample(analysis_request): analysis_request.setSampler(api.get_current_user().id) +def after_no_sampling_workflow(analysis_request): + """Function triggered after "no_sampling_workflow transition for the + Analysis Request passed in is performed + """ + setup = api.get_setup() + if setup.getAutoreceiveSamples(): + # Auto-receive samples is enabled. Note transition to "received" state + # will only take place if the current user has enough privileges (this + # is handled by do_action_for already). + do_action_for(analysis_request, "receive") + + def after_reject(analysis_request): """Method triggered after a 'reject' transition for the Analysis Request passed in is performed. Cascades the transition to descendants (partitions)