Code Duplication    Length = 14-26 lines in 2 locations

bika/lims/browser/analysisrequest/add2.py 1 location

@@ 760-785 (lines=26) @@
757
            "sample_type_uid": sample_type_uid,
758
            "sample_type_title": sample_type_title,
759
            "container_type_uid": container_type_uid,
760
            "container_type_title": container_type_title,
761
            "sample_condition_uid": sample_condition_uid,
762
            "sample_condition_title": sample_condition_title,
763
            "storage_location_uid": storage_location_uid,
764
            "storage_location_title": storage_location_title,
765
            "sample_point_uid": sample_point_uid,
766
            "sample_point_title": sample_point_title,
767
            "environmental_conditions": obj.getEnvironmentalConditions(),
768
            "composite": obj.getComposite(),
769
            "client_sample_id": obj.getClientSampleID(),
770
            "client_reference": obj.getClientReference(),
771
            "sampling_workflow_enabled": obj.getSamplingWorkflowEnabled(),
772
            "adhoc": obj.getAdHoc(),
773
            "remarks": obj.getRemarks(),
774
        })
775
        return info
776
777
    @cache(cache_key)
778
    def get_specification_info(self, obj):
779
        """Returns the info for a Specification
780
        """
781
        info = self.get_base_info(obj)
782
783
        results_range = obj.getResultsRange()
784
        info.update({
785
            "results_range": results_range,
786
            "sample_type_uid": obj.getSampleTypeUID(),
787
            "sample_type_title": obj.getSampleTypeTitle(),
788
            "client_uid": obj.getClientUID(),

bika/lims/browser/analysisrequest/add.py 1 location

@@ 280-293 (lines=14) @@
277
    def partitioned_services(self):
278
        bsc = getToolByName(self.context, 'bika_setup_catalog')
279
        ps = []
280
        for service in bsc(portal_type='AnalysisService'):
281
            service = service.getObject()
282
            if service.getPartitionSetup() \
283
                    or service.getSeparate():
284
                ps.append(service.UID())
285
        return json.dumps(ps)
286
287
    def get_fields_with_visibility(self, visibility, mode=None):
288
        mode = mode if mode else 'add'
289
        schema = self.context.Schema()
290
        fields = []
291
        for field in schema.fields():
292
            isVisible = field.widget.isVisible
293
            v = isVisible(self.context, mode, default='invisible', field=field)
294
            visibility_guard = True
295
            # visibility_guard is a widget field defined in the schema in order to know the visibility of the widget when the field is related to a dynamically changing content such as workflows. For instance those fields related to the workflow will be displayed only if the workflow is enabled, otherwise they should not be shown.
296
            if 'visibility_guard' in dir(field.widget):