Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reference widget lookups #2384

Merged
merged 81 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
adafa14
Lookup default catalog with the API
ramonski Sep 8, 2023
0dc1322
Compatibilty with new reference widget
ramonski Sep 9, 2023
3eb3dc3
Fix description and query
ramonski Sep 10, 2023
455aefb
Compatibility with new reference widget
ramonski Sep 10, 2023
ca34eaa
Added portal_type to query
ramonski Sep 11, 2023
d3ae2f4
Additional CSS class
ramonski Sep 11, 2023
8b04708
Handle select/deselect events in editform
ramonski Sep 11, 2023
c792f6f
Ensure portal_type query
ramonski Sep 11, 2023
7516b89
Refactored labcontact schema
ramonski Sep 11, 2023
8edf506
Fix dynamic default department
ramonski Sep 11, 2023
8991fda
Handle referencefield select/deselect
ramonski Sep 11, 2023
99a6001
Generated Production JS
ramonski Sep 11, 2023
4cf9a28
Description improved
ramonski Sep 11, 2023
3701245
Imports sorted
ramonski Sep 11, 2023
991a0ec
Compatibility with new reference widget
ramonski Sep 11, 2023
53b4d6f
Also allow supplier contacts
ramonski Sep 11, 2023
ecc10eb
Compatibility with new reference widget for analysis category
ramonski Sep 11, 2023
9b49a59
Compatibility with new reference widget
ramonski Sep 11, 2023
0f8d366
Make flake8 happy
ramonski Sep 11, 2023
57d3819
Removed dead code
ramonski Sep 11, 2023
cc9b170
Compatibility with new reference widget
ramonski Sep 11, 2023
d1fc195
Compatibility with new reference widget
ramonski Sep 11, 2023
e12d0f8
Compatibility with new reference widget
ramonski Sep 11, 2023
993fd0f
Compatibility with new reference widget
ramonski Sep 11, 2023
0233fb8
Compatibility with new reference widget
ramonski Sep 11, 2023
73a8337
Compatibility with new reference widget
ramonski Sep 11, 2023
c2c8507
Compatibility with new reference widget
ramonski Sep 11, 2023
7fa58e8
Changed to selection widget
ramonski Sep 11, 2023
a41b7fd
Compatibility with new reference widget
ramonski Sep 11, 2023
094c391
Imports sorted
ramonski Sep 11, 2023
c0878a0
Compatibility with new reference widget
ramonski Sep 11, 2023
78d791f
Minor change
ramonski Sep 11, 2023
79a8cb6
Compatibility with new reference widget
ramonski Sep 11, 2023
5ada03f
Compatibility with new reference widget
ramonski Sep 11, 2023
9183734
Compatibility with new reference widget
ramonski Sep 11, 2023
235806c
Compatibility with new reference widget
ramonski Sep 11, 2023
1822d1e
Compatibility with new reference widget
ramonski Sep 11, 2023
42b2234
Compatibility with new reference widget
ramonski Sep 11, 2023
ddeb889
Compatibility with new reference widget
ramonski Sep 11, 2023
4c0a982
compatibility with new reference widget
ramonski Sep 11, 2023
9a5bfbd
Compatibility with new reference widget
ramonski Sep 11, 2023
e432d35
Compatibility with new reference widget
ramonski Sep 11, 2023
8004011
Compatibility with new reference widget
ramonski Sep 11, 2023
02cc06b
Compatibility with new reference widget
ramonski Sep 11, 2023
285c98d
compatibility with new reference widget
ramonski Sep 11, 2023
4a9e51d
Disallow removal if readonly
ramonski Sep 11, 2023
c95a348
Compatibility with new reference widget
ramonski Sep 11, 2023
6006122
Compatibility with new reference sample
ramonski Sep 11, 2023
8d65034
Minor change
ramonski Sep 11, 2023
a1c8369
Compatibility with new reference widget
ramonski Sep 11, 2023
d8da142
compatibility with new reference widget
ramonski Sep 11, 2023
255eb51
Make allowed types a tuple
ramonski Sep 11, 2023
6efd749
compatibility with new reference widget
ramonski Sep 11, 2023
48a30cb
Compatibility with new reference widget
ramonski Sep 11, 2023
4e88935
compatibility with new reference widget
ramonski Sep 11, 2023
f6e0e17
compatibility with new reference widget
ramonski Sep 11, 2023
2042154
Compatibility with new reference widget
ramonski Sep 11, 2023
f77d680
Compatibility with new reference widget
ramonski Sep 11, 2023
b41965e
Avoid acquisition in lookup
ramonski Sep 11, 2023
921c449
compatibility with new reference widget
ramonski Sep 11, 2023
85c2739
Compatibility with new refrence widget
ramonski Sep 11, 2023
91308cf
compatibility with new reference widget
ramonski Sep 11, 2023
6f1855d
Compatibility with new reference widget
ramonski Sep 11, 2023
532caeb
Compatibility with new reference widget
ramonski Sep 11, 2023
24d07c0
Changelog updated
ramonski Sep 11, 2023
1e89a54
Removed unused import
ramonski Sep 11, 2023
081a443
Merge branch '2.x' into fix-at-uidreference-fields-with-no-catalog-set
ramonski Sep 11, 2023
35b77ae
Use title instead of fullname
ramonski Sep 11, 2023
c4d4e3e
Handle empty value lookups
ramonski Sep 11, 2023
194df41
Merge branch 'fix-at-uidreference-fields-with-no-catalog-set' of http…
ramonski Sep 11, 2023
6a57eca
Fix batch referencewidget error while searching for Batch
xispa Sep 12, 2023
680660b
Fix old-style referencewidget for SampleContainer in SampleType
xispa Sep 12, 2023
2c8ab01
Remove unnecessary showOn=True
xispa Sep 12, 2023
7b6dfed
Fix AttributeError when looking for PrimaryAnalysisRequest objects
xispa Sep 12, 2023
0b88494
Make lint happy
xispa Sep 12, 2023
2c1aeb5
Display the batch subgroup Title instead of the Id
xispa Sep 12, 2023
5573045
Avoid waking up the object
ramonski Sep 12, 2023
69dfbdd
Don't wake up the object for Missing.Value
ramonski Sep 12, 2023
5d32821
No getPrefix in columns
ramonski Sep 12, 2023
279746e
Cleanup
ramonski Sep 12, 2023
185f4cb
Added a todo for a fix
xispa Sep 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
2.5.0 (unreleased)
------------------

- #2384 Fix reference widget lookups
- #2379 Add listing adapter for sample workflow "receive" transition
- #2382 Fix missing fields in client edit mode and listing
- #2378 Reactivate auditlog catalog mappings
Expand Down
3 changes: 2 additions & 1 deletion src/bika/lims/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,8 @@ def get_review_status(brain_or_object):
:returns: Value of the review_status variable
:rtype: String
"""
if is_brain(brain_or_object):
if is_brain(brain_or_object) \
and base_hasattr(brain_or_object, "review_state"):
return brain_or_object.review_state
return get_workflow_status_of(brain_or_object, state_var="review_state")

Expand Down
68 changes: 31 additions & 37 deletions src/bika/lims/content/abstractbaseanalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@
from Products.Archetypes.Widget import SelectionWidget
from Products.Archetypes.Widget import StringWidget
from Products.CMFCore.permissions import View
from Products.CMFCore.utils import getToolByName
from senaite.core.browser.fields.records import RecordsField
from senaite.core.catalog import SETUP_CATALOG
from senaite.core.p3compat import cmp
from zope.interface import implements

# Anywhere that there just isn't space for unpredictably long names,
Expand Down Expand Up @@ -419,20 +417,22 @@
# The category of the analysis service, used for filtering, collapsing and
# reporting on analyses.
Category = UIDReferenceField(
'Category',
"Category",
schemata="Description",
required=1,
allowed_types=('AnalysisCategory',),
vocabulary='getAnalysisCategories',
allowed_types=("AnalysisCategory",),
widget=ReferenceWidget(
label=_("Analysis Category"),
description=_("The category the analysis service belongs to"),
showOn=True,
catalog_name=SETUP_CATALOG,
base_query={
'is_active': True,
'sort_on': 'sortable_title',
'sort_order': 'ascending',
label=_(
"label_analysis_category",
default="Analysis Category"),
description=_(
"description_analysis_category",
default="The category the analysis service belongs to"),
catalog=SETUP_CATALOG,
query={
"is_active": True,
"sort_on": "sortable_title",
"sort_order": "ascending",
},
)
)
Expand Down Expand Up @@ -475,20 +475,27 @@
# The analysis service's Department. This is used to filter analyses,
# and for indicating the responsibile lab manager in reports.
Department = UIDReferenceField(
'Department',
"Department",
schemata="Description",
required=0,
allowed_types=('Department',),
allowed_types=("Department",),
widget=ReferenceWidget(
label=_("Department"),
description=_("The laboratory department"),
showOn=True,
catalog_name=SETUP_CATALOG,
base_query=dict(
is_active=True,
sort_on="sortable_title",
sort_order="ascending",
),
label=_(
"label_analysis_department",
default="Department"),
description=_(
"description_analysis_department",
default="Select the responsible department"),
catalog=SETUP_CATALOG,
query={
"is_active": True,
"sort_on": "sortable_title",
"sort_order": "ascending"
},
columns=[
{"name": "Title", "label": _("Department Name")},
{"name": "getDepartmentID", "label": _("Department ID")},
],
)
)

Expand Down Expand Up @@ -893,19 +900,6 @@ def getTotalDiscountedBulkPrice(self):
vat = vat and vat or 0
return float(price) + (float(price) * float(vat)) / 100

@security.public
def getAnalysisCategories(self):
"""A vocabulary listing available (and activated) categories.
"""
bsc = getToolByName(self, 'senaite_catalog_setup')
cats = bsc(portal_type='AnalysisCategory', is_active=True)
items = [(o.UID, o.Title) for o in cats]
o = self.getCategory()
if o and o.UID() not in [i[0] for i in items]:
items.append((o.UID(), o.Title()))
items.sort(lambda x, y: cmp(x[1], y[1]))
return DisplayList(list(items))

@security.public
def getLowerDetectionLimit(self):
"""Get the lower detection limit
Expand Down
40 changes: 23 additions & 17 deletions src/bika/lims/content/analysiscategory.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,25 @@

import transaction
from AccessControl import ClassSecurityInfo
from bika.lims.browser.fields import UIDReferenceField
from Products.Archetypes.Field import FloatField
from Products.Archetypes.Field import TextField
from Products.Archetypes.Schema import Schema
from Products.Archetypes.Widget import DecimalWidget
from Products.Archetypes.Widget import TextAreaWidget
from Products.Archetypes.public import BaseContent
from Products.Archetypes.public import registerType
from Products.CMFCore.WorkflowCore import WorkflowException
from zope.interface import implements

from bika.lims import api
from bika.lims import bikaMessageFactory as _
from senaite.core.browser.widgets.referencewidget import ReferenceWidget
from bika.lims.browser.fields import UIDReferenceField
from bika.lims.catalog.bikasetup_catalog import SETUP_CATALOG
from bika.lims.config import PROJECTNAME
from bika.lims.content.bikaschema import BikaSchema
from bika.lims.interfaces import IAnalysisCategory
from bika.lims.interfaces import IDeactivable
from bika.lims.interfaces import IHaveDepartment
from Products.Archetypes.Field import FloatField
from Products.Archetypes.Field import TextField
from Products.Archetypes.public import BaseContent
from Products.Archetypes.public import registerType
from Products.Archetypes.Schema import Schema
from Products.Archetypes.Widget import DecimalWidget
from Products.Archetypes.Widget import TextAreaWidget
from Products.CMFCore.WorkflowCore import WorkflowException
from senaite.core.browser.widgets.referencewidget import ReferenceWidget
from zope.interface import implements

Comments = TextField(
"Comments",
Expand All @@ -57,15 +56,22 @@
required=1,
allowed_types=("Department",),
widget=ReferenceWidget(
label=_("Department"),
description=_("The laboratory department"),
showOn=True,
catalog_name=SETUP_CATALOG,
base_query={
label=_(
"label_category_department",
default="Department"),
description=_(
"description_category_department",
default="Select the responsible department"),
catalog=SETUP_CATALOG,
query={
"is_active": True,
"sort_on": "sortable_title",
"sort_order": "ascending"
},
columns=[
{"name": "Title", "label": _("Department Name")},
{"name": "getDepartmentID", "label": _("Department ID")},
],
)
)

Expand Down
Loading