Passed
Push — master ( bcb3c3...740c75 )
by Pau
04:01
created

bika.health.monkeys.batch   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 10
dl 0
loc 41
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A getClient() 0 16 3
1
# -*- coding: utf-8 -*-
2
#
3
# This file is part of SENAITE.HEALTH.
4
#
5
# SENAITE.HEALTH is free software: you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by the Free
7
# Software Foundation, version 2.
8
#
9
# This program is distributed in the hope that it will be useful, but WITHOUT
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12
# details.
13
#
14
# You should have received a copy of the GNU General Public License along with
15
# this program; if not, write to the Free Software Foundation, Inc., 51
16
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
#
18
# Copyright 2018-2019 by it's authors.
19
# Some rights reserved, see README and LICENSE.
20
21
from bika.health.interfaces import IPatient
22
from bika.lims.interfaces import IClient
23
24
25
def getClient(self):
26
    """Returns the Client from the Batch passed-in, if any
27
    """
28
    # The schema's field Client is only used to allow the user to assign
29
    # the batch to a client in edit form. The entered value is used in
30
    # ObjectModifiedEventHandler to move the batch to the Client's folder,
31
    # so the value stored in the Schema's is not used anymore
32
    # See https://github.com/senaite/senaite.core/pull/1450
33
    parent = self.aq_parent
34
    if IClient.providedBy(parent):
35
        return parent
36
37
    elif IPatient.providedBy(parent):
38
        return parent.getClient()
39
40
    return None
41