code: def addReferences(self, reference, service_uids):
          
          # TODO Workflow - Analyses. Assignment of refanalysis to Instrument
          addedanalyses = []
          wf = getToolByName(self, 'portal_workflow')
          bsc = getToolByName(self, 'bika_setup_catalog')
          bac = getToolByName(self, 'bika_analysis_catalog')
          ref_type = reference.getBlank() and 'b' or 'c'
          ref_uid = reference.UID()
          postfix = 1
          for refa in reference.getReferenceAnalyses():
              grid = refa.getReferenceAnalysesGroupID()
              try:
                  cand = int(grid.split('-')[2])
                  if cand >= postfix:
                      postfix = cand + 1
              except:
                  pass
          postfix = str(postfix).zfill(int(3))
          refgid = 'I%s-%s' % (reference.id, postfix)
          for service_uid in service_uids:
              # services with dependents don't belong in references
              service = bsc(portal_type='AnalysisService', UID=service_uid)[0].getObject()
              calc = service.getCalculation()
              if calc and calc.getDependentServices():
                  continue
              ref_analysis = reference.addReferenceAnalysis(service)
  
              # Set ReferenceAnalysesGroupID (same id for the analyses from
              # the same Reference Sample and same Worksheet)
              # https://github.com/bikalabs/Bika-LIMS/issues/931
              ref_analysis.setReferenceAnalysesGroupID(refgid)
              ref_analysis.setInstrument(self)
              ref_analysis.reindexObject()
              addedanalyses.append(ref_analysis)
  
          # Set DisposeUntilNextCalibrationTest to False
          if (len(addedanalyses) > 0):
              self.getField('DisposeUntilNextCalibrationTest').set(self, False)
  
          return addedanalyses
docs: Add reference analyses to reference