Ejemplo n.º 1
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    at = getToolByName(portal, 'archetype_tool')
    at.setCatalogsByType('SubGroup', ['bika_setup_catalog', ])
    setup = portal.portal_setup
    setup.runImportStepFromProfile('profile-bika.lims:default', 'controlpanel')

    try:
        _createObjectByType("SubGroups", portal.bika_setup, "bika_subgroups",
                            title="Sub-groups")
        obj = portal.bika_setup.bika_subgroups
        obj.unmarkCreationFlag()
        obj.reindexObject()
    except BadRequest:
        # folder already exists
        pass

    return True
Ejemplo n.º 2
0
def upgrade(tool):
    """ Fix workflow variable review_history permission guard.
    """
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    wf_ids = [
        'bika_analysis_workflow',
        'bika_batch_workflow',
        'bika_cancellation_workflow',
        'bika_duplicateanalysis_workflow',
        'bika_inactive_workflow',
        'bika_publication_workflow',
        'bika_referenceanalysis_workflow',
        'bika_referencesample_workflow',
        'bika_reject_analysis_workflow',
        'bika_sample_workflow',
        'bika_worksheet_workflow',
        'bika_worksheetanalysis_workflow',
    ]
    portal = aq_parent(aq_inner(tool))
    workflow = getToolByName(portal, 'portal_workflow')
    for wf_id in wf_ids:
        wf = workflow.getWorkflowById(wf_id)
        if wf:
            rhdef = wf.variables['review_history']
            rhdef.info_guard = None

    return True
Ejemplo n.º 3
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup

    setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo')

    stub('bika.lims.content.invoicelineitem', 'InvoiceLineItem',
        BaseContent)
    for inv in portal['invoices'].objectValues():
        inv.invoice_lineitems = []
        for invl in inv.objectValues():
            item = dict(
                ItemDate=invl.ItemDate,
                ItemDescription=invl.ItemDescription,
                ClientOrderNumber=invl.ClientOrderNumber,
                Subtotal=invl.Subtotal,
                VATAmount=invl.VATAmount,
                Total=invl.Total,
            )
            inv.invoice_lineitems.append(item)
    return True
Ejemplo n.º 4
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup

    setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo')

    stub('bika.lims.content.pricelistlineitem', 'PricelistLineItem',
        BaseContent)
    for pl in portal['pricelists'].objectValues():
        pl.pricelist_lineitems = []
        for pli in pl.objectValues():
            item = dict(
                title=pli.title,
                ItemDescription=pli.ItemDescription,
                Accredited=pli.Accredited,
                Subtotal="%d.%d" % (pli.Subtotal[0], pli.Subtotal[1]),
                VATAmount="%d.%d" % (pli.VATAmount[0], pli.VATAmount[1]),
                Total="%d.%d" % (pli.Total[0], pli.Total[1]),
                CategoryTitle=pli.CategoryTitle,
            )
            pl.pricelist_lineitems.append(item)
    return True
Ejemplo n.º 5
0
def upgrade(tool):
    """ Sort by Type in instruments
    """
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True


    portal = aq_parent(aq_inner(tool))
    bsc = getToolByName(portal, 'bika_setup_catalog', None)

    if 'getInstrumentType' not in bsc.indexes():
        bsc.addIndex('getInstrumentType', 'FieldIndex')
        bsc.addColumn('getInstrumentType')

        bsc.addIndex('getInstrumentTypeName','FieldIndex')
        bsc.addColumn('getInstrumentTypeName')

    #Del old "getType" Index, it's not used now.
    if 'getType' in bsc.indexes():
        bsc.delIndex('getType')
    if 'getType' in bsc.indexes():
        bsc.delColumn('getType')

    setup = portal.portal_setup

    logger.info("Reindex added indexes in bika_setup_catalog")
    bsc.manage_reindexIndex(
        ids=['getInstrumentType', 'getInstrumentTypeName', ])

    return True
Ejemplo n.º 6
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup

    mp = portal.bika_setup.manage_permission
    mp('Access contents information', ['Authenticated', 'Analyst'], 1)
    mp(permissions.View, ['Authenticated', 'Analyst'], 1)
    portal.bika_setup.reindexObject()

    for obj in portal.bika_setup.bika_analysisservices.objectValues():
        mp = obj.manage_permission
        mp(permissions.View, ['Manager', 'LabManager', 'Analyst'], 0)
        mp('Access contents information', ['Manager', 'LabManager', 'Member', 'LabClerk', 'Analyst', 'Sampler', 'Preserver', 'Owner'], 0)
        obj.reindexObject()

    wf = getToolByName(portal, 'portal_workflow')
    # update affected tools
    setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo')
    setup.runImportStepFromProfile('profile-bika.lims:default', 'workflow-csv')
    wf.updateRoleMappings()

    return True
Ejemplo n.º 7
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup
    workflow = getToolByName(portal, "portal_workflow")

    # /arimports folder permissions
    mp = portal.arimports.manage_permission
    mp(ManageARImport, ['Manager', ], 1)
    mp(permissions.ListFolderContents, ['Manager','Member',], 1)
    mp(permissions.AddPortalContent, ['Manager', ], 0)
    mp(permissions.DeleteObjects, ['Manager'], 0)
    mp(permissions.View, ['Manager','Member'], 0)
    portal.arimports.reindexObject()
    try:
        workflow.doActionFor(portal.arimports, "hide")
    except:
        pass
    portal.arimports.setLayout('@@arimports')
    return True
Ejemplo n.º 8
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup
    typestool = getToolByName(portal, 'portal_types')

    # Add the object to bika_setup
    try:
        portal.bika_setup.manage_delObjects('bika_arpriorities')
    except BadRequest:
        logger.info("Folder doesn't exist")

    try:
        typestool.constructContent(type_name="ARPriorities",
                               container=portal.bika_setup,
                               id='bika_arpriorities',
                               title='AR Priorities')
        obj = portal.bika_setup.bika_arpriorities
        obj.unmarkCreationFlag()
        obj.reindexObject()
    except BadRequest:
        # folder already exists
        pass

    return True
Ejemplo n.º 9
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup

    # re-import js registry
    setup.runImportStepFromProfile('profile-bika.lims:default', 'jsregistry')
    setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo')

    # Update permissions according to Bika Setup
    # By default, restrict user access and management to WS
    bs = portal.bika_setup
    bs.setRestrictWorksheetUsersAccess(True)
    bs.setRestrictWorksheetManagement(True)
    bs.reindexObject()

    # Only LabManagers are able to create worksheets.
    mp = portal.manage_permission
    mp(ManageWorksheets, ['Manager', 'LabManager'],1)

    return True
Ejemplo n.º 10
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup

    # update affected tools
    setup.runImportStepFromProfile('profile-bika.lims:default', 'workflow-csv')

    # /supplyorders folder permissions
    mp = portal.supplyorders.manage_permission
    mp(CancelAndReinstate, ['Manager', 'LabManager', 'LabClerk'], 0)
    mp(ManagePricelists, ['Manager', 'LabManager', 'Owner'], 1)
    mp(permissions.ListFolderContents, ['Member'], 1)
    mp(permissions.AddPortalContent, ['Manager', 'LabManager', 'Owner'], 0)
    mp(permissions.DeleteObjects, ['Manager', 'LabManager', 'Owner'], 0)
    mp(permissions.View, ['Manager', 'LabManager'], 0)
    portal.supplyorders.reindexObject()

    wf = getToolByName(portal, 'portal_workflow')
    wf.updateRoleMappings()

    return True
Ejemplo n.º 11
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))

    # Fix Analysis Services IMM incoherences
    for service in portal.bika_setup.bika_analysisservices.objectValues('AnalysisService'):
        if (service.getInstrumentEntryOfResults() == False):
            # Remove any assigned instrument
            service.setInstruments([])
            service.setInstrument(None)

        if (service.getManualEntryOfResults() == False):
            # Remove any assigned manual method
            service.setMethods([])
            service.set_Method(None)

        service.reindexObject()

    return True
Ejemplo n.º 12
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup

    # Add new Client role
    role = "Client"
    if role not in portal.acl_users.portal_role_manager.listRoleIds():
        portal.acl_users.portal_role_manager.addRole(role)
        portal._addRole(role)

    # Add the role Client role to Clients group
    portal.portal_groups.editGroup('Clients', roles=['Member',
                                                     'Authenticated',
                                                     'Client'])

    # Add all Client contacts to Clients group
    for client in portal.clients.values():
        for contact in client.getContacts():
            user = portal.portal_membership.getMemberById(contact.getUsername())
            if user is not None:
                portal.portal_groups.addPrincipalToGroup(user.getUserName(),
                                                         "Clients")

    # Add AddAttachment permission to Clients
    mp = portal.manage_permission
    mp(AddAttachment, ['Manager', 'LabManager', 'Owner' 'Analyst', 'LabClerk', 'Client', 'Sampler'], 0)

    # Add Analysis Services View permission to Clients
    mp = portal.bika_setup.bika_analysisservices.manage_permission
    mp('Access contents information', ['Authenticated', 'Analyst', 'Client'], 1)
    mp(permissions.View, ['Authenticated', 'Analyst', 'Client'], 1)
    portal.bika_setup.bika_analysisservices.reindexObject()
    for obj in portal.bika_setup.bika_analysisservices.objectValues():
        mp = obj.manage_permission
        mp(permissions.View, ['Manager', 'LabManager', 'Analyst', 'Client'], 0)
        mp('Access contents information', ['Manager', 'LabManager', 'Member', 'LabClerk', 'Analyst', 'Client', 'Sampler', 'Preserver', 'Owner'], 0)
        obj.reindexObject()

    # Grant AttachmentType view access to Clients
    mp = portal.bika_setup.bika_attachmenttypes.manage_permission
    mp('Access contents information', ['Authenticated', 'Analyst', 'Client'], 1)
    mp(permissions.View, ['Authenticated', 'Analyst', 'Client'], 1)
    portal.bika_setup.bika_attachmenttypes.reindexObject()


    wf = getToolByName(portal, 'portal_workflow')
    setup.runImportStepFromProfile('profile-bika.lims:default', 'workflow-csv')
    wf.updateRoleMappings()

    return True
Ejemplo n.º 13
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))

    portal.portal_actions.portal_tabs.queries.visible = False

    return True
Ejemplo n.º 14
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    at = getToolByName(portal, 'archetype_tool')
    at.setCatalogsByType('ARPriority', ['bika_setup_catalog', ])

    return True
Ejemplo n.º 15
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup
    setup.runImportStepFromProfile(
            'profile-bika.lims:default', 'propertiestool')

    return True
Ejemplo n.º 16
0
def upgrade(tool):
    """ Re-import types tool to add condition for sample/partitions view
    """
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup

    setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo')
Ejemplo n.º 17
0
def upgrade(tool):
    """Added bika.lims.analysisservice.edit.js
    """
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup

    # update affected tools
    setup.runImportStepFromProfile('profile-bika.lims:default', 'jsregistry')

    # apply new method/calculation data to old Analysis Services
    portal = aq_parent(aq_inner(tool))
    pc = getToolByName(portal, 'portal_catalog')
    bsc = getToolByName(portal, 'bika_setup_catalog')
    rc=getToolByName(portal, REFERENCE_CATALOG)
    proxies = pc(portal_type="AnalysisService")
    for proxy in proxies:
        an = proxy.getObject()
        rels = an.at_references.objectValues()
        oldmethod = None
        oldinstrument = None
        oldcalc = None
        for rel in rels:
            if rel.relationship == 'AnalysisServiceCalculation':
                oldcalc=rc.lookupObject(rel.targetUID)
            elif rel.relationship == 'AnalysisServiceInstrument':
                oldinstrument=rc.lookupObject(rel.targetUID)
            elif rel.relationship == 'AnalysisServiceMethod':
                oldmethod=rc.lookupObject(rel.targetUID)
            if oldmethod and oldcalc and oldinstrument:
                break

        # Reset the method, instrument and calculations
        if oldmethod:
            an.Schema().getField('Methods').set(an, [oldmethod.UID(),])
            an.Schema().getField('_Method').set(an, oldmethod.UID())
        if oldinstrument:
            an.Schema().getField('Instruments').set(an, [oldinstrument.UID(),])
            an.Schema().getField('Instrument').set(an, oldinstrument.UID())
        if oldcalc:
            an.setUseDefaultCalculation(False);
            an.Schema().getField('DeferredCalculation').set(an, oldcalc.UID())

    return True
Ejemplo n.º 18
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup
    typestool = getToolByName(portal, 'portal_types')

    # update affected tools
    setup.runImportStepFromProfile('profile-bika.lims:default', 'workflow')

    return True
Ejemplo n.º 19
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup
    typestool = getToolByName(portal, 'portal_types')

    # update affected tools
    setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo')
    setup.runImportStepFromProfile('profile-bika.lims:default', 'workflow')

    # Add the SupplyOrderFolder /supplyorders
    try:
        typestool.constructContent(type_name="SupplyOrderFolder",
                               container=portal,
                               id='supplyorders',
                               title='Supply Orders')
        obj = portal['supplyorders']
        obj.unmarkCreationFlag()
        obj.reindexObject()
    except BadRequest:
        # folder already exists
        pass

    # /supplyorders folder permissions
    mp = portal.supplyorders.manage_permission
    mp(permissions.ListFolderContents, ['Manager', 'LabManager', 'LabClerk', ], 0)
    mp(permissions.View, ['Manager', 'LabManager', 'LabClerk'], 0)
    mp('Access contents information', ['Manager', 'LabManager', 'LabClerk'], 0)
    mp(AddSupplyOrder, ['Manager', 'LabManager', 'Owner'], 0)
    portal.supplyorders.reindexObject()

    # /pricelists folder permissions
    mp = portal.pricelists.manage_permission
    mp(permissions.ListFolderContents, ['Manager', 'LabManager', 'LabClerk', ], 0)
    mp(permissions.View, ['Manager', 'LabManager', 'LabClerk'], 0)
    mp('Access contents information', ['Manager', 'LabManager', 'LabClerk'], 0)
    mp(AddPricelist, ['Manager', 'LabManager', 'LabClerk'], 0)
    portal.pricelists.reindexObject()

    return True
Ejemplo n.º 20
0
def upgrade(tool):
    """Add the bika-frontpage view to the selectable views.  This will not
    set the default, but all new sites will have the 'properties.xml' loaded,
    which does set the default.
    """
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup
    setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo')

    return True
Ejemplo n.º 21
0
def upgrade(tool):
    """Added bika.lims.client.view.js
    """
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup

    # reread jsregistry with the new data
    setup.runImportStepFromProfile('profile-bika.lims:default', 'jsregistry')

    return True
Ejemplo n.º 22
0
def upgrade(tool):
    """ Remove Maintenance, Validations, Calibrations ans Schedule
        https://github.com/bikalabs/Bika-LIMS/issues/1134
    """
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup

    # update affected tools
    setup.runImportStepFromProfile('profile-bika.lims:default', 'typeinfo')
    return True
Ejemplo n.º 23
0
def upgrade(tool):
    """Added D3.js library and D3 Control-chart for Instrument QC
    """
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup

    # update affected tools
    setup.runImportStepFromProfile('profile-bika.lims:default', 'jsregistry')

    return True
Ejemplo n.º 24
0
def upgrade(tool):
    """Added bika.lims.loader.js and bika.lims.method.edit.js
    """
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup

    # update affected tools
    setup.runImportStepFromProfile('profile-bika.lims:default', 'jsregistry')

    return True
Ejemplo n.º 25
0
def upgrade(tool):
    """
    """
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315

    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    portal_catalog = getToolByName(portal, "portal_catalog")
    typestool = getToolByName(portal, "portal_types")
    workflowtool = getToolByName(portal, "portal_workflow")
    setup = portal.portal_setup

    # Changes to the catalogs
    at = getToolByName(portal, "archetype_tool")
    at.setCatalogsByType("Batch", ["bika_catalog", "portal_catalog"])
    at.setCatalogsByType("AnalysisRequest", ["bika_catalog", "portal_catalog"])
    at.setCatalogsByType("Sample", ["bika_catalog", "portal_catalog"])
    at.setCatalogsByType("SamplePartition", ["bika_catalog", "portal_catalog"])
    at.setCatalogsByType("ReferenceSample", ["bika_catalog", "portal_catalog"])
    at.setCatalogsByType("Report", ["bika_catalog", "portal_catalog"])
    at.setCatalogsByType("Worksheet", ["bika_catalog", "portal_catalog"])

    at.setCatalogsByType("AnalysisService", ["bika_setup_catalog", "portal_catalog"])
    at.setCatalogsByType("SampleType", ["bika_setup_catalog", "portal_catalog"])
    at.setCatalogsByType("SamplePoint", ["bika_setup_catalog", "portal_catalog"])
    at.setCatalogsByType("Instrument", ["bika_setup_catalog", "portal_catalog"])
    at.setCatalogsByType("Method", ["bika_setup_catalog", "portal_catalog"])
    at.setCatalogsByType("Calculation", ["bika_setup_catalog", "portal_catalog"])
    at.setCatalogsByType("AnalysisProfile", ["bika_setup_catalog", "portal_catalog"])
    at.setCatalogsByType("ARTemplate", ["bika_setup_catalog", "portal_catalog"])
    at.setCatalogsByType("LabProduct", ["bika_setup_catalog", "portal_catalog"])
    at.setCatalogsByType("LabContact", ["bika_setup_catalog", "portal_catalog"])
    at.setCatalogsByType("ReferenceManufacturer", ["bika_setup_catalog", "portal_catalog"])
    at.setCatalogsByType("ReferenceSupplier", ["bika_setup_catalog", "portal_catalog"])
    at.setCatalogsByType("ReferenceDefinition", ["bika_setup_catalog", "portal_catalog"])
    at.setCatalogsByType("WorksheetTemplate", ["bika_setup_catalog", "portal_catalog"])

    portal_catalog.clearFindAndRebuild()

    return True
Ejemplo n.º 26
0
def upgrade(tool):
    """ Add Storage locacations to ARs and Samples.
    """
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    setup = portal.portal_setup

    bc = getToolByName(portal, 'bika_catalog')
    for brain in bc(portal_type='AnalysisRequest'):
        obj = brain.getObject()
        if not obj.getPriority():
            obj.setDefaultPriority()
Ejemplo n.º 27
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))

    # missing /supplyorders folder permission
    clients = portal.clients.objectValues()
    for client in clients:
        mp = client.manage_permission
        mp(AddSupplyOrder, ['Manager', 'LabManager', 'Owner'], 0)
        client.reindexObject()

    return True
Ejemplo n.º 28
0
def upgrade(tool):
    """LIMS-1275 - Remove acquisition for "Modify portal content" permission
    """
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))

    # /bika_setup -
    mp = portal.bika_setup.manage_permission
    mp(permissions.ModifyPortalContent, ['Manager', 'LabManager'], 0)
    portal.batches.reindexObject()

    return True
Ejemplo n.º 29
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))

    for pricelist in portal.pricelists.objectValues('Pricelist'):
        for broken in pricelist.objectValues('PriceListLineItem'):
            pricelist.manage_delObjects([broken.id])

    pc = getToolByName(portal, 'portal_catalog')
    pc.refreshCatalog(clear=1)

    return True
Ejemplo n.º 30
0
def upgrade(tool):
    # Hack prevent out-of-date upgrading
    # Related: PR #1484
    # https://github.com/bikalabs/Bika-LIMS/pull/1484
    from lims.upgrade import skip_pre315
    if skip_pre315(aq_parent(aq_inner(tool))):
        return True

    portal = aq_parent(aq_inner(tool))
    portal_catalog = getToolByName(portal, 'portal_catalog')

    proxies = portal_catalog(portal_type="AnalysisRequest")
    ars = [proxy.getObject() for proxy in proxies]
    for ar in ars:
        if not ar.getPriority():
            ar.setDefaultPriority()


    return True