ERP5 KM

HowToUsePreferences

PreferenceTool

PreferenceTool is a generic tool to integrate user preferences in ERP5.

Introduction

PreferenceTool allows user to add Preference documents in the preference folder. The idea is to have different level of priority on Preference objects :

  • By default, User create User Level preferences. This is the higher priority.

  • Group preferences have lower priority. They are basically intended to be associated to a user role by setting local role through the ZMI.

  • Site is the lowest priority preference. Site Managers must take care that a preference at the site level always exists and is activated, because many UI parts of ERP5 assume this.

Installation

When accessing a preference, a manager can change the priority of the preference. The form for viewing a preference have a special behaviour when the authenticated user has the Manager role.

How to create a site preference ?

First create a preference, when an user create a Preference, it has the User priority. Later, site manager can change the preference's priority to Site using the standard view, the field Priority becomes editable if the current user has the Manager role. It's then important to add the Auditor role to any member, because every one must have read access to this preference.

How to create a group preference ?

Creating a group preference is similar to a site preference, except that you do not set the Auditor role to all members, but only to the specific group.

How does it works

A Preference must be explicitly activated 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, it deactivates all other user level preferences he owns, so that one can only have one active preference at a time.

When you want to query a user preference, you must call directly the method on the PreferenceTool :

portal.portal_preferences.getPreferredAccountingTransactionSourceSection()

or

portal.portal_preferences.getPreference('preferred_accounting_transaction_source_section')

The previous code will work if you have associated on your Preference Portal Type a Property Sheet that defines the preferred_accounting_transaction_source_section attribute or category. 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 : first User then Group and finally Site level. 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 he got on the Preference itself).

How to add new preference

  • Define a new Property Sheet for the attribute you want to make a preference. Mark this attribute as a preference by setting 'preference': 1 in the property definition. Note that the Property Sheet must be postfixed with Preference (e.g. LocalizationPreference).

  • Create an ERP5Form for the user to set this preference. ( or reuse an existing one )
  • Then you can call preference methods on portal_preferences.
  • PreferenceTool also exist in TALES context of ERP5Form as preferences

How Html Style preferences are used

  • Developper Mode helps developer:

    • adds link to Base_viewInspectionReport

    • adds ability to edit forms, forms' actions and forms' fields
  • Contextual Help adds link to contextual help, with url as defined in Documentation URL preference

  • Translator Mode helps transalting site, by creating special links in forms' fields and some other translateable objects

  • Documentation URL is a URL used by contextual help system

How preferences are used in erp5_accounting

Preference Tool was initially created for erp5_accounting, because to display Accounts balances, we must know what source_section, what currency, ... relates to the user. So the user must set in a preference the following informations :

  • section group category, used for reporting in Account Module main page, list of Transactions for an Account and list of Transaction for an Entity

  • section organisation Object, used for prefilling Accounting Transaction documents

  • currency, used for prefilling Accounting Transaction documents and reporting in Account Module main page, list of Transactions for an Account and list of Transaction for an Entity

  • gap used to display gapId for Account objects who belong to multiple accounting plan classifications.

  • start and stop_date to limit transactions for Account Module main page, list of Transactions for an Account and list of Transaction for an Entity to a given date range.

  • simulation_state to limit transactions for Account Module main page, list of Transactions for an Account and list of Transaction for an Entity to a given date range.

Most accounting preferences are also used for reporting.

The preferences settings also relate directly to 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.

Future plans

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.

/!\ it's almost working now ... this needs to be updated

Discussions

Discussions happens in a dedicated page.

HowToUsePreferences (last edited 2009-11-18 14:19:45 by YoshinoriOkuji)

Page
  • Immutable Page
  • Info
  • Attachments
User
Learn about new ERP5 releases,technical articles, events and more.

Subscribe to the monthly ERP5 Newsletter!