Hi everyone, I am looking to add new fields to Sample, by developing a custom_lims add on to modify Sample and Patient fields. The problem is I cannot access ISample or Sample (commented below). Can someone who went through this help me? I am working with docker image of 2.x.
extender.py ----->
from zope.interface import implements
from zope.component import adapts
from plone.app.content.interfaces import INameFromTitle
from bika.lims.content.sample import Sample # does not work
from bika.lims.interfaces import ISample # does not work
from senaite.core.interfaces import ISamples # does not work
from senaite.lims.content.sample import Sample # does not work
from archetypes.schemaextender.interfaces import ISchemaExtender, IBrowserLayerAwareExtender
from archetypes.schemaextender.interfaces import ISchemaModifier
from Products.Archetypes import atapi
from custom.lims.interfaces import ICustomLimsLayer # your browser layer
This is my code extender.py, the problem is that the add view no show the new field:
from zope.interface import implements
from zope.component import adapts
from archetypes.schemaextender.interfaces import ISchemaExtender
from archetypes.schemaextender.field import ExtensionField
from Products.Archetypes.public import TextField
from Products.Archetypes.public import TextAreaWidget
from bika.lims.interfaces import IAnalysisRequest
class ExtendedTextField(ExtensionField, TextField):
“”“Campo de texto extendido para SchemaExtender.”“”
class AnalysisRequestExtender(object):
“”“Extiende el esquema de AnalysisRequest añadiendo el campo ‘partidas’.”“”
adapts(IAnalysisRequest)
implements(ISchemaExtender)
# Definir el nuevo campo.
fields = [
ExtendedTextField(
‘partidas’, # nombre interno del campo
default=‘’, # valor por defecto
widget=TextAreaWidget(
label=“Partidas”, # etiqueta visible en el formulario
description=“Ingrese las partidas asociadas”,
rows=4, cols=40,
visible={‘view’: ‘visible’, ‘edit’: ‘visible’},
),
),
]
def __init__(self, context):
self.context = context
def getFields(self):
# Devolver los campos a insertar en el esquema
return self.fields
Thanks for sharing, I am doing something similar. However, the extra fields are shown only when I click on the sample and try to edit it. It does not appear when I do ‘add Sample’. Also, it breaks and I get a SampleHeader error. I tried adapting ‘ISample’ instead, but I cannot resolve the right reference to ISample using version 2.x docker.
from zope.interface import implements
from zope.component import adapts
# from bika.lims.content.sample import Sample
# from bika.lims.interfaces import ISample
# from bika.lims.interfaces import ISample
# from senaite.lims.content.sample import Sample
from Products.Archetypes.public import AnnotationStorage, StringField, StringWidget
# from bika.lims.content.analysisrequest import IAnalysisRequest
from bika.lims.interfaces import IAnalysisRequest
class ExtraARFields(object):
implements(ISchemaExtender)
adapts(IAnalysisRequest)
# adapts(ISample)
fields = [
StringField(
"wellPosition",
storage=AnnotationStorage(),
required=False,
mutator="setWellPosition",
accessor="getWellPosition",
widget=StringWidget(
label="Well Position",
visible={'view': 'visible', 'edit': 'visible'},
),
)
]
Contribute to hochkofler/senaite.manufacture development by creating an account on GitHub.
My addon aims to extend SENAITE’s functionality for the pharmaceutical industry where I work.
It focuses on product registration, product presentations, and linking to batches.
It also records deviations and nonconformities based on obtained samples.
Currently, senaite.manufacture only creates new product content.
I’m from Bolivia (my native language is Spanish). If you need any support we can help each other, you can contact me privately (I sent you my email and number).
and once we have solved the problem we will post the solution in this thread