Skip to content

Commit cb77fc3

Browse files
authored
Provide context, widget and fieldname for callable base queries in AT reference widgets (senaite#1914)
* Call base query callable with context, widget and fieldname * Changelog updated * Return the dereferenced base query
1 parent b077f7e commit cb77fc3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGES.rst

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changelog
44
2.2.0 (unreleased)
55
------------------
66

7+
- #1914 Provide context, widget and fieldname for callable base queries in AT reference widgets
78
- #1912 Fixed typo in sample view
89
- #1909 Allow to navigate and select with arrow keys in dexterity reference widget
910
- #1908 Added searchable text querystring converter to catalog API

src/senaite/core/browser/widgets/referencewidget.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ def get_combogrid_options(self, context, fieldName):
120120
def get_base_query(self, context, fieldName):
121121
base_query = self.base_query
122122
if callable(base_query):
123-
base_query = base_query()
123+
try:
124+
base_query = base_query(context, self, fieldName)
125+
except TypeError:
126+
base_query = base_query()
124127
if base_query and isinstance(base_query, six.string_types):
125128
base_query = json.loads(base_query)
126129

@@ -136,7 +139,7 @@ def get_base_query(self, context, fieldName):
136139
if allowed_types \
137140
else self.portal_types
138141

139-
return json.dumps(self.base_query)
142+
return json.dumps(base_query)
140143

141144
def initial_uid_field_value(self, value):
142145
if type(value) in (list, tuple):

0 commit comments

Comments
 (0)