This document explains how to use the PreferenceTool to integrate user preferences
Table of Contents
The preferenceTool is a generic tool to integrate user preferences in ERP5. It
allows users to add preference documents in the preference folder. The idea is to
have different level of priority on Preference objects:
When accessing a preference, a manager can change the priority of the preference.
The form for viewing a preference have a special behaviours when the authenticated
user has a Manager role.
When you create a new preference it is created with User priority be default.
Later the site manager can change the preference priority to Site by changing the
Priority field on a preference. Enabling a site preference will not set
it into Enabled state but into Globally Enabled. This is a special
state, where all site members have view permission on it.
Creating a group preference is similar to a site preference, except that you
need to configure roles so that the targeted group of users has Auditor role.
There are two different portal types: Preference which is intended for
users and group of users to configure the application behavior and Site Preference
who are intended for managers to configure the global behavior of a site. Only
managers can create and enable Site Preferences.
A Preference must be explicitly activated (ie. in Enabled or Globally Enabled state)
to be taken into account by PreferenceTool. Any active preference on which the
user has the View permission is looked up for this user.
When a user activates a preference, all other user level preferences
he owns are automatically de-activated. A user can only have one active preference at a time.
To query a user preference you must directly call the method on the PreferenceTool, for example:
The first call will work if you have associated a Property Sheet that defines the
preferred_accounting_transaction_source_section attribute or categoryon your
Preference Portal Type. Note that the preferred_ part of the name is not automatically
added, the property is actually called preferred_accounting_transaction_source_section.
Then it will lookup the preferred_accounting_transaction_source_section on all
active Preferences that the user can access (ie. Preference on which he is Owner
or Auditor), in that order:
If the value is not set to None nor an empty list, this preference is used,
otherwise, PreferenceTool tries to get the value on the next preference. If
nothing was found, then PreferenceTool returns None (or the empty list, depending
on what value was found on the Preference itself).
The PreferenceTool was initially created for erp5_accounting, because to display
Accounts balances, we must know what source_section, what currency, etc. relate
to a certain user. Therefore the user must set accounting preferences containing
the following inforomation:
Most accounting preferences are also used for reporting.
The preferences settings also relate directly to the default Accounting Module View
(Accounting Transaction list) as well as its 'Search' function initial settings.
Those settings can be overwritten of course temporarly on the 'Search' refining page.
Preferences can be used as a placeholder for the user to create template
documents that he can reuse later to add new documents to a folder.
Refer to How To Create Templates
for more information.
Some business templates require system-wide preferences. Document conversion for example
requires to connect to an external service (like Cloudooo) and thus
needs a preference parameter with the URL to connect to. These system preferenes
are also accessible via portal_preferences.
Note there should be only one (!) system preference enabled and that ERP5 might already
have created a system preference (obfusiciatingly called Created by Promise Alarms). If you create another one, it
will not take precedence over the existing one automatically, so newly set parameters will not
work when calling a method like getPreferredDocumentConversionServerUrl.
Add your parameters to the above preference instead of creating new system preferences. Make
sure the preference is enabled and if necessary, clear (portal-) caches and restart your zope
(in the webrunner interface). Then parameters should be updated.