Adding Content to LIMS Setup/Control Panel via Add-On

I am currently trying to add a new content type that is editable via the LIMS Setup/Control Panel. The goal is have a custom Purchase Order content.

Control Panel Button:
image

Listing View:

I have about 90% of it working, but I am having a bit of an issue with the Add Form, and I’m not sure how to address it since it seems to be a weird blend of Dexterity and Archetypes mechanism at the moment…

I have the Bika Listing View for the PurchaseOrderFolder working (added to GenericSetup structure), and the Add button works, but I cannot get the Date and DataGrid Widgets to work at all. Additionally, the content is created immediately, and then is edited. This creates blank entries every time the Add is cancelled.

I assume the Bika widgets don’t work because this is a Dexterity content type while the Bika widgets are all designed for Archetypes. However, the “Add/Edit Form” itself seems to be Archetypes based or something, because I can’t get any of the Dexterity widgets to work either despite defining them as such…

  <object name="PurchaseOrderFolder" meta_type="Dexterity FTI"/>
  <object name="PurchaseOrder" meta_type="Dexterity FTI"/>

Looking for any guidance on adding Dexterity content with Date Widgets in an Add-On in Senaite. I can’t tell if I registered the content incorrectly for the system (so it’s using the wrong Add Form), or if I’m importing the wrong Widgets. Tried both:

from plone.app.z3cform.widget import DatetimeFieldWidget
from bika.lims.browser.widgets import DateTimeWidget

Rather than posting all the GS code, here’s the core files I’m working with
PurchaseOrder GenericSetup Type
PurchaseOrder Behavior
PurchaseOrder Content Type

1 Like

After reviewing some of the content in senaite.patient, I believe I have solved the Widget issue by importing them from senaite.core.z3cform.widgets.

from senaite.core.z3cform.widgets.datetimewidget import DatetimeWidget
from senaite.core.z3cform.widgets.datagridfield import DataGridFieldWidget

However, I am still experiencing the issue where the ‘Add’ button immediately creates the object, and then edits it, leading to blank objects anytime the screen is cancelled.

I tried to match up the GenericSetup config to the PatientFolder and Patient types from senaite.patient, but that has not resolved the issue. Thinking it might have to do with how the ListingView for PatientFolder is invoking the Add button.

Any suggestions would be appreciated.