Skip to content

Commit e224a12

Browse files
authored
Merge branch '2.x' into fix-save-button-visibility-in-sampleheader
2 parents 05feedc + 46aa8fd commit e224a12

File tree

2 files changed

+4
-22
lines changed

2 files changed

+4
-22
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Changelog
55
------------------
66

77
- #2874 Fix save button visibility of sample header
8+
- #2875 Fix AttributeError in add_sample when rejection workflow is enabled
89
- #2872 Use AT accessor/mutator in GenericSetup field adapter
910
- #2870 Do a full commit every 1000 migrated worksheets
1011
- #2869 Add adapter lookup for client searchable text index

src/bika/lims/browser/widgets/rejectionwidget.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,10 @@
1919
# Some rights reserved, see README and LICENSE.
2020

2121
from AccessControl import ClassSecurityInfo
22+
from bika.lims import api
2223
from Products.Archetypes.Registry import registerWidget
2324
from Products.Archetypes.Widget import TypesWidget
2425

25-
try:
26-
from zope.component.hooks import getSite
27-
except Exception:
28-
# Plone < 4.3
29-
from zope.app.component.hooks import getSite
30-
3126

3227
class RejectionWidget(TypesWidget):
3328
_properties = TypesWidget._properties.copy()
@@ -53,22 +48,8 @@ def isVisible(self, instance, mode='view', default=None, field=None):
5348

5449
def rejectionOptionsList(self):
5550
"Return a sorted list with the options defined in bikasetup"
56-
plone = getSite()
57-
settings = plone.bika_setup
58-
# RejectionReasons will return something like:
59-
# [{'checkbox': u'on', 'textfield-2': u'b', 'textfield-1': u'c', 'textfield-0': u'a'}]
60-
if len(settings.RejectionReasons) > 0:
61-
reject_reasons = settings.RejectionReasons[0]
62-
else:
63-
return []
64-
sorted_keys = sorted(reject_reasons.keys())
65-
if 'checkbox' in sorted_keys:
66-
sorted_keys.remove('checkbox')
67-
# Building the list with the values only because the keys are not needed any more
68-
items = []
69-
for key in sorted_keys:
70-
items.append(reject_reasons[key].strip())
71-
return items
51+
setup = api.get_senaite_setup()
52+
return setup.getRejectionReasons()
7253

7354
def isRejectionEnabled(self, dd):
7455
"""

0 commit comments

Comments
 (0)