Code Duplication    Length = 11-12 lines in 2 locations

src/senaite/core/content/worksheettemplate.py 1 location

@@ 542-553 (lines=12) @@
539
540
        # Restrict available instruments to those with the selected method
541
        method = self.getRestrictToMethod()
542
        if method:
543
            # prepare subquery
544
            method_uid = method.UID()
545
            uids = []
546
            brains = api.search(query, SETUP_CATALOG)
547
            for brain in brains:
548
                uid = api.get_uid(brain)
549
                instrument = api.get_object(brain)
550
                if method_uid in instrument.getRawMethods():
551
                    uids.append(uid)
552
            # create a simple UID query
553
            query = {"UID": uids}
554
        return query
555

src/bika/lims/content/worksheettemplate.py 1 location

@@ 186-196 (lines=11) @@
183
184
        # Restrict available instruments to those with the selected method
185
        method_uid = self.getRawRestrictToMethod()
186
        if method_uid:
187
            # prepare subquery
188
            uids = []
189
            brains = api.search(query, SETUP_CATALOG)
190
            for brain in brains:
191
                uid = api.get_uid(brain)
192
                instrument = api.get_object(brain)
193
                if method_uid in instrument.getRawMethods():
194
                    uids.append(uid)
195
            # create a simple UID query
196
            query = {"UID": uids}
197
198
        logger.info("get_widget_contact_query: %r" % query)
199
        return query