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

after_remove()   A

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nop 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