Domains are used by listbox in report and domain mode, in these mode, a tree is
display on the left of the listbox to let the user perform a selection. You can
either define domains using categories or base domains objects. The use of base
domain objects is based on domain generator, this permits the dynamic generation
of domain and thus any possible combination.
Table of Contents
How to define a base domain¶
Just go to portal_domains and add a base domain object, give it an explicit id
and specify a python script into the field Domain Generator.
What does the domain generator script do¶
This script is called for each level in the tree that will be displayed to the
user, it must return a list of domains for a given depth.
The domain generator script takes two arguments, the depth into the tree and
the parent object. Based on this parameter it must generate a list of temporary domains.
Here is an example:
##parameters=depth, parent, **kw
from Products.ERP5Type.Document import newTempDomain
domain_list=[]
if depth == 1:
domain = parent.generateTempDomain(id="new_id")
domain.edit(title="Title", membership_criterion_base_category=('a_category',),\
membership_criterion_category=('a_category/value',),\
domain_generator_method_id=script.id)
domain_list.append(domain)
else:
...
return domain_list
Note that you always have to register the domain_generator_method_id attribute
on new temporary domain in order to make them work
How to use these domain into listbox¶
Just add the base domain id into the Domain Tree or Report Tree field.
Related Articles¶