Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dynamic analysis specification listing error for empty excel columns #1820

Merged
merged 3 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
2.0.0 (unreleased)
------------------

- #1820 Fix dynamic analysis specification listing error for empty excel columns
- #1819 Fix rejection report is attached as a ".bin" file in notification email
- #1817 Fix duplicated rejection reasons in rejection viewlet (sample view)
- #1815 Hide unit display after fields in manage analyses listing
Expand Down
15 changes: 12 additions & 3 deletions src/bika/lims/browser/dynamic_analysisspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import collections

import six

from bika.lims import _
from bika.lims import api
from senaite.app.listing.view import ListingView
Expand Down Expand Up @@ -68,7 +70,7 @@ def update(self):
def before_render(self):
super(DynamicAnalysisSpecView, self).before_render()

def make_empty_item(self, **kw):
def make_empty_item(self, record):
"""Create a new empty item
"""
item = {
Expand All @@ -80,11 +82,18 @@ def make_empty_item(self, **kw):
"disabled": False,
"state_class": "state-active",
}
item.update(**kw)
for k, v in record.items():
# ensure keyword dictionary keys contains only strings
if not self.is_string(k):
continue
item[k] = v
return item

def is_string(self, value):
return isinstance(value, six.string_types)

def folderitems(self):
items = []
for record in self.specs:
items.append(self.make_empty_item(**record))
items.append(self.make_empty_item(record))
return items