@@ -129,6 +129,301 @@ Dependencies
129129.. contents ::
130130 :local:
131131
132+ Usage
133+ =====
134+
135+ UI Testing Guide
136+ ----------------
137+
138+ This module has no views of its own. All UI interaction is through views
139+ provided by ``spp_vocabulary `` and ``spp_cel_domain ``. This guide covers
140+ what to verify after installing ``spp_cel_vocabulary ``.
141+
142+ Prerequisites
143+ ~~~~~~~~~~~~~
144+
145+ - Install ``spp_cel_vocabulary `` (auto-installs when both
146+ ``spp_cel_domain `` and ``spp_vocabulary `` are present)
147+ - Log in as an admin user
148+ - Have at least one vocabulary with codes (e.g., a gender vocabulary)
149+
150+ --------------
151+
152+ Test 1: Verify Concept Groups Are Created
153+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
154+
155+ **Path: ** Settings > Vocabularies > Concept Groups
156+
157+ **Steps: **
158+
159+ 1. Navigate to **Settings > Vocabularies > Concept Groups **
160+ 2. Verify the following 10 groups exist:
161+
162+ =========================== ======================= ===============
163+ Name Label CEL Function
164+ =========================== ======================= ===============
165+ ``feminine_gender `` Feminine Gender ``is_female ``
166+ ``masculine_gender `` Masculine Gender ``is_male ``
167+ ``head_of_household `` Head of Household ``is_head ``
168+ ``pregnant_eligible `` Pregnant/Eligible ``is_pregnant ``
169+ ``climate_hazards `` Climate-related Hazards *(empty) *
170+ ``geophysical_hazards `` Geophysical Hazards *(empty) *
171+ ``children `` Children *(empty) *
172+ ``adults `` Adults *(empty) *
173+ ``elderly `` Elderly/Senior Citizens *(empty) *
174+ ``persons_with_disability `` Persons with Disability *(empty) *
175+ =========================== ======================= ===============
176+
177+ 3. Open ``feminine_gender `` and verify:
178+
179+ - Label: "Feminine Gender"
180+ - CEL Function: ``is_female ``
181+ - Description is populated
182+ - **Codes ** tab is empty (groups are created empty by default)
183+
184+ **Expected: ** All 10 groups are present with correct labels, CEL
185+ functions, and descriptions.
186+
187+ --------------
188+
189+ Test 2: Add Codes to a Concept Group
190+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
191+
192+ **Path: ** Settings > Vocabularies > Concept Groups > (select group) >
193+ Codes tab
194+
195+ **Precondition: ** A gender vocabulary with at least a "Female" code must
196+ exist.
197+
198+ **Steps: **
199+
200+ 1. Open ``feminine_gender `` concept group
201+ 2. Click **Edit **
202+ 3. Go to the **Codes ** tab
203+ 4. Click **Add a line **
204+ 5. Search for and select your "Female" vocabulary code
205+ 6. Click **Save **
206+
207+ **Verify: **
208+
209+ - The code appears in the Codes tab with its vocabulary, code value, and
210+ display name
211+ - If the code has a URI, it should be visible (may need Technical tab
212+ for ``code_uris `` field)
213+
214+ **Repeat ** for ``masculine_gender `` with a "Male" code if available.
215+
216+ --------------
217+
218+ Test 3: Idempotent Installation
219+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
220+
221+ **Steps: **
222+
223+ 1. Note the current concept groups and their IDs
224+ 2. Upgrade ``spp_cel_vocabulary `` module (Settings > Apps >
225+ spp_cel_vocabulary > Upgrade)
226+ 3. Navigate back to **Settings > Vocabularies > Concept Groups **
227+
228+ **Expected: **
229+
230+ - No duplicate groups were created
231+ - Existing groups retain their codes (codes added in Test 2 are still
232+ there)
233+ - All 10 groups still present
234+
235+ --------------
236+
237+ Test 4: CEL Expression Validation with Vocabulary Functions
238+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
239+
240+ **Path: ** Custom > CEL Domain > Tools > Rule Preview
241+
242+ **Precondition: ** Codes have been added to ``feminine_gender `` group
243+ (Test 2).
244+
245+ **Steps: **
246+
247+ 1. Navigate to **Custom > CEL Domain > Tools > Rule Preview **
248+ 2. Select a model (e.g., the individual registrant model)
249+ 3. Enter the expression: ``is_female(r.gender_id) ``
250+ 4. Click **Validate & Preview **
251+
252+ **Expected: **
253+
254+ - Validation succeeds (no error)
255+ - The **Summary ** tab shows:
256+
257+ - ``preview_count ``: number of matching records (may be 0 if no
258+ registrants have gender set)
259+ - ``explain_text ``: a human-readable explanation mentioning
260+ ``feminine_gender `` and URIs
261+
262+ **Repeat with these expressions: **
263+
264+ +-----------------------------------------------------------+----------------------------------+
265+ | Expression | Should Validate |
266+ +===========================================================+==================================+
267+ | ``is_female(r.gender_id) `` | Yes |
268+ +-----------------------------------------------------------+----------------------------------+
269+ | ``is_male(r.gender_id) `` | Yes |
270+ +-----------------------------------------------------------+----------------------------------+
271+ | ``in_group(r.gender_id, "feminine_gender") `` | Yes |
272+ +-----------------------------------------------------------+----------------------------------+
273+ | ``code_eq(r.gender_id, "female") `` | Yes (if code exists) |
274+ +-----------------------------------------------------------+----------------------------------+
275+ | ``r.gender_id == code("female") `` | Yes (if code exists) |
276+ +-----------------------------------------------------------+----------------------------------+
277+ | ``members.exists(m, head(m) and is_female(m.gender_id)) `` | Yes |
278+ +-----------------------------------------------------------+----------------------------------+
279+ | ``in_group(r.gender_id, "nonexistent_group") `` | Yes (validates but matches |
280+ | | nothing) |
281+ +-----------------------------------------------------------+----------------------------------+
282+ | ``is_female(r.name) `` | Depends on translator behavior |
283+ +-----------------------------------------------------------+----------------------------------+
284+
285+ --------------
286+
287+ Test 5: Domain Translation Verification
288+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289+
290+ **Path: ** Custom > CEL Domain > Tools > Rule Preview
291+
292+ **Precondition: ** ``feminine_gender `` group has at least one code with a
293+ URI.
294+
295+ **Steps: **
296+
297+ 1. Open Rule Preview
298+ 2. Enter: ``is_female(r.gender_id) ``
299+ 3. Click **Validate & Preview **
300+ 4. Check the **Summary ** tab explanation text
301+
302+ **Expected: **
303+
304+ - The explanation should reference ``feminine_gender `` and list the code
305+ URIs
306+ - The generated domain should check both ``gender_id.uri `` and
307+ ``gender_id.reference_uri ``
308+
309+ --------------
310+
311+ Test 6: Empty Group Behavior
312+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
313+
314+ **Path: ** Custom > CEL Domain > Tools > Rule Preview
315+
316+ **Precondition: ** ``climate_hazards `` group exists but has no codes
317+ assigned.
318+
319+ **Steps: **
320+
321+ 1. Open Rule Preview
322+ 2. Enter: ``in_group(r.gender_id, "climate_hazards") ``
323+ 3. Click **Validate & Preview **
324+
325+ **Expected: **
326+
327+ - Validation succeeds but matches 0 records
328+ - The explanation should indicate the group is empty (e.g.,
329+ ``[EMPTY GROUP] ``)
330+ - Check Odoo logs for a ``[CEL Vocabulary] `` warning about the empty
331+ group
332+
333+ --------------
334+
335+ Test 7: Nonexistent Group Behavior
336+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
337+
338+ **Steps: **
339+
340+ 1. Open Rule Preview
341+ 2. Enter: ``in_group(r.gender_id, "does_not_exist") ``
342+ 3. Click **Validate & Preview **
343+
344+ **Expected: **
345+
346+ - Validation succeeds but matches 0 records
347+ - The explanation should indicate the group was not found (e.g.,
348+ ``[GROUP NOT FOUND] ``)
349+ - Check Odoo logs for a warning with guidance: "Check Settings >
350+ Vocabularies > Concept Groups"
351+
352+ --------------
353+
354+ Test 8: Local Code Support (if applicable)
355+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
356+
357+ **Precondition: ** A local vocabulary code exists with
358+ ``is_local = True `` and a ``reference_uri `` pointing to a standard
359+ code's URI. Both codes are in the same concept group.
360+
361+ **Steps: **
362+
363+ 1. Create a local code (e.g., "Babae" with ``reference_uri `` pointing to
364+ the Female standard code's URI)
365+ 2. Add both the standard and local codes to ``feminine_gender `` group
366+ 3. Open Rule Preview
367+ 4. Enter: ``is_female(r.gender_id) ``
368+ 5. Click **Validate & Preview **
369+
370+ **Expected: **
371+
372+ - The domain checks both ``uri `` and ``reference_uri `` fields
373+ - Records with either the standard code or the local code should be
374+ matched
375+
376+ --------------
377+
378+ Test 9: Security - Read-Only Access
379+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
380+
381+ **Steps: **
382+
383+ 1. Log in as a non-admin user (base user group)
384+ 2. Navigate to **Settings > Vocabularies > Concept Groups **
385+
386+ **Expected: **
387+
388+ - User can view concept groups (read access)
389+ - User cannot create, edit, or delete concept groups
390+
391+ --------------
392+
393+ Test 10: Concept Group Search and Filters
394+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
395+
396+ **Path: ** Settings > Vocabularies > Concept Groups
397+
398+ **Steps: **
399+
400+ 1. Use the search bar to search for "gender"
401+ 2. Apply the "Has CEL Function" filter
402+
403+ **Expected: **
404+
405+ - Search by "gender" finds ``feminine_gender `` and ``masculine_gender ``
406+ - "Has CEL Function" filter shows only groups with a CEL function set
407+ (``feminine_gender ``, ``masculine_gender ``, ``head_of_household ``,
408+ ``pregnant_eligible ``)
409+
410+ --------------
411+
412+ Troubleshooting
413+ ~~~~~~~~~~~~~~~
414+
415+ If expressions return unexpected results:
416+
417+ 1. **Check logs ** for ``[CEL Vocabulary] `` entries — error messages
418+ include guidance on how to fix the issue
419+ 2. **Verify codes are in groups ** — open the concept group and check the
420+ Codes tab
421+ 3. **Verify code URIs ** — codes need a ``uri `` field populated for
422+ domain matching
423+ 4. **Check field names ** — vocabulary functions require Many2one fields
424+ pointing to ``spp.vocabulary.code `` (e.g., ``gender_id ``, not
425+ ``gender ``)
426+
132427Bug Tracker
133428===========
134429
0 commit comments