From c02665f3ed6a345146009c4dcf9c3eb1d0f62618 Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Fri, 9 Mar 2018 13:55:59 +0100 Subject: [PATCH 1/3] Return UIDs for newly created ARs so that stickers get properly printed --- bika/lims/browser/analysisrequest/add2.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bika/lims/browser/analysisrequest/add2.py b/bika/lims/browser/analysisrequest/add2.py index 0a5f86d43c..1216ab2241 100644 --- a/bika/lims/browser/analysisrequest/add2.py +++ b/bika/lims/browser/analysisrequest/add2.py @@ -1836,7 +1836,7 @@ def ajax_submit(self): return {'errors': errors} # Process Form - ARs = [] + ARs = {} for n, record in enumerate(valid_records): client_uid = record.get("Client") client = self.get_object_by_uid(client_uid) @@ -1853,7 +1853,9 @@ def ajax_submit(self): except (KeyError, RuntimeError) as e: errors["message"] = e.message return {"errors": errors} - ARs.append(ar.Title()) + # We keep the title to check if AR is newly created + # and UID to print stickers + ARs[ar.Title()] = ar.UID() _attachments = [] for attachment in attachments.get(n, []): @@ -1872,20 +1874,19 @@ def ajax_submit(self): level = "error" elif len(ARs) > 1: message = _('Analysis requests ${ARs} were successfully created.', - mapping={'ARs': safe_unicode(', '.join(ARs))}) + mapping={'ARs': safe_unicode(', '.join(ARs.keys()))}) else: message = _('Analysis request ${AR} was successfully created.', - mapping={'AR': safe_unicode(ARs[0])}) + mapping={'AR': safe_unicode(ARs.keys()[0])}) # Display a portal message self.context.plone_utils.addPortalMessage(message, level) - # Automatic label printing won't print "register" labels for Secondary. ARs bika_setup = api.get_bika_setup() auto_print = bika_setup.getAutoPrintStickers() # https://github.com/bikalabs/bika.lims/pull/2153 - new_ars = [a for a in ARs if a[-1] == '1'] + new_ars = [uid for key, uid in ARs.items() if key[-1] == '1'] if 'register' in auto_print and new_ars: return { From cece07d78a03d010dac32be8506dafc9a4371196 Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Fri, 9 Mar 2018 14:52:24 +0100 Subject: [PATCH 2/3] Update CHANGES.rst --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index a6e2075e3c..bdd3d789c4 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -16,6 +16,7 @@ Changelog **Fixed** +- #720 Make automatic sticker printing work with 'registered' option activated - #700 Fix filtering by review state in aggregated list of analyses - #715 AR Rejection Fails when e-mail Notification is enabled - #709 Fix removal not possible of last non-verified Analysis in Manage Analysis View From 49a1f81e1f964e8fca4704bb1e874b8ef17bbcc5 Mon Sep 17 00:00:00 2001 From: Juan Gallostra Date: Mon, 12 Mar 2018 09:59:53 +0100 Subject: [PATCH 3/3] Keep list of ARs ordered by using an OrderedDict --- bika/lims/browser/analysisrequest/add2.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bika/lims/browser/analysisrequest/add2.py b/bika/lims/browser/analysisrequest/add2.py index d2f8113788..1995412a35 100644 --- a/bika/lims/browser/analysisrequest/add2.py +++ b/bika/lims/browser/analysisrequest/add2.py @@ -7,6 +7,7 @@ import json from datetime import datetime +from collections import OrderedDict import magnitude from BTrees.OOBTree import OOBTree @@ -1845,7 +1846,7 @@ def ajax_submit(self): return {'errors': errors} # Process Form - ARs = {} + ARs = OrderedDict() for n, record in enumerate(valid_records): client_uid = record.get("Client") client = self.get_object_by_uid(client_uid)