Passed
Push — master ( 454a47...f526ab )
by Ramon
04:30
created

build.bika.lims.workflow.worksheet.events   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 10
dl 0
loc 37
rs 10
c 0
b 0
f 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A after_retract() 0 5 2
A after_submit() 0 12 1
A after_remove() 0 5 1
1
# -*- coding: utf-8 -*-
2
#
3
# This file is part of SENAITE.CORE
4
#
5
# Copyright 2018 by it's authors.
6
# Some rights reserved. See LICENSE.rst, CONTRIBUTORS.rst.
7
8
from bika.lims import workflow as wf
9
10
11
def after_submit(obj):
12
    """
13
    Method triggered after a 'submit' transition for the Worksheet passed in is
14
    performed.
15
    This function is called automatically by
16
    bika.lims.workfow.AfterTransitionEventHandler
17
    """
18
    # Submitting a Worksheet must never transition the analyses.
19
    # In fact, a worksheet can only be transitioned to "to_be_verified" if
20
    # all the analyses that contain have been submitted manually after
21
    # the results input
22
    wf.doActionFor(obj, 'attach')
23
24
25
def after_retract(worksheet):
26
    """Retracts all analyses the worksheet contains
27
    """
28
    for analysis in worksheet.getAnalyses():
29
       wf.doActionFor(analysis, "retract")
30
31
32
def after_remove(worksheet):
33
    """Removes the worksheet from the system
34
    """
35
    container = worksheet.aq_parent
36
    container.manage_delObjects([worksheet.getId()])
37