This document provides patterns and rules for working with content layout forms
used in ERP5, especially on the use on custom fields.
Table of Contents
This guideline provides an advice of how to make field library in your business
Field library is an ERP5 form which will not be accessed from users but used as
a container of proxy fields used as template field by other fields contained in
other real forms and reports. In other words, it is a collection of template
fields of proxy fields commonly used in a business template.
Using proxy field is very useful for providing consistent UI and reducing code
For example, comment field is one of the very common fields in whole ERP5 system
and it should be always the same size everywhere. Then we use proxy field, we can
define the height and width only once to the template field in the core field
library and the remaining is that all other comment fields just inherit the core
template field. This way, we can make consistent UI easily. If we did not use
proxy field, we had to set the same height and width for all comment fields one
by one, this is very hard to maintain.
About field library, this is a kind of buffer between the core field library in
erp5_core and the real fields to be displayed to users. We saw an example of
comment field above, it was a common field globally. But sometimes we want to
change an appearance of generic fields only in some business template. In such
case, we cannot change the core template fields, because they are used globally.
So we can change a field library of a target business template instead. Then we
can customize some fields only in a business template and this does not affect
UIs defined by other business templates.
Sometimes we can find similar patterns in ERP5. For example, when we use a
RelationStringField, we often name it like "my_source_title" by following our
naming convention. And from such names, we can find a pattern. The name suggests
this field uses source category and searches document by title. And we can make
a template field for RelationStringField and put a tales expression to parse
field id and find category name and index property. Once we have such a template
field which is an abstraction of a pattern we don't have to enter a category
name and an index property name each time when adding RelationStringField,
but just using a proxy field and inherit the template field is enough. We can
omit entering various parameters and it is also useful for maintenance, future
changes. Above is a very wide range example which can apply whole ERP5, but we
can find many other small patterns in a specific context managed by single business
template like Accounting, DMS. Therefore finding a pattern and making a template
field is very practical use case of proxy field and field library.
Sometimes we have to enter the same information in multiple places. For example,
a company has the same reference naming rule for Service and Product. In such case,
we have to apply the same input validation functionality to Product_view.my_reference
and Service_view.my_reference. Then we can say that both my_reference in Product_view
and Service_view are the same in reality. In such case, we should make a template field
in field library and reuse the field to inherit from proxy fields in both Product_view
nd Service_view. And in this way even if the input validation rule was changed, we
only have to update the template field and no need to touch proxy fields.
A business template represents one field of application. As the field libraries
are used to shared the semantic configuration of forms, there should be only one
field library per business template (even if this one contains multiple skin folders).
It is sometimes required to surcharge the behaviour of a field library. In this
case, it is required to create another skin folder (following the convention [surcharged_context]_[original_skin_folder_name])
and an empty field library could be created to surcharge the original one.
# In the erp5_project BT5:
But, this other example should never happen:
All proxy fields defined in a BT5 should link to the Field Library defined in this bt5.
Here are some examples that should never happen:
Semantic field defined in a field library could link to Base_viewFieldLibrary
Surcharged skin folder
It is sometimes required to surcharge the behaviour of a skin folder. In this case,
it is required to create another skin folder (following the convention [surcharged_context]_[original_skin_folder_name])
and forms contained in this skin folder could link to the field library defined in the original BT5.
In the erp5_project BT5: erp5_project_trade/PurchaseOrder_view[my_title]
But, this other example should never happen:
As the technical fields have no semantic, it is useless to duplicate them in
each field library. So, only Base_viewFieldLibrary should contains technical
field library. This will ease maintenance (no need to update all field libraries
if a new technical field is created).
Here are some examples that should never happen:
This is a convention to prevent creating multiple technical template fields
(for view, dialog, report) related to the same field class.
Here are some example that should never happen:
Instead, it should be:
All semantic template field defined in a field library should be proxy field (either of semantic or technical field).
Here some examples of technical context :
The technical context is important, we do not always display things in the same
way, and we can have different technical configuration depending on the technical
with technical_context_name having such values:
So we can have :
Nothing particular for many fields, share semantic:
If no semantic field is found, it means that the proxy field will link to a technical
field (which are only defined in Base_viewFieldLibrary).
for Arrow, there is a specific semantic for trade, sometimes there is the point
of view of the seller, sometimes from the buyer (and even sometimes it's only
internal movement, I didn't worked on it yet). So here for every field about
source/destination, I use 2 different names with "sale" or "purchase" inside:
Please try as much as possible to use prefix which are consistent with those
defined in business_fields of the Glossary.
should not be:
If a technical field is always used for the same purpose and if it is good
enough to share for all usages, we don't need semantic field in Base_viewFieldLibrary
and it is acceptable to link to the technical field directly outside from the
default field library.
This is OK, because relation string field is always used for category:
this is bad, because list_field can be used for different purpose :
the above one should be:
In each business field should have only one field library. Before we added many
field libraries in a business template and it was hard to understand each form
dependencies and was also hard to maintain.
Field library would be only one in your business template, then let's define
naming rule. we follow the names of core field libraries.
Basic naming pattern is Base_view(???)FieldLibrary. (???) would be replaced with
your business template name. For example:
Structure of form and field library in a non-core business template would be following:
Each field of field library should be unified semantically. For example, if our
business template has these three fields my_reference, my_code and my_product_name,
add my_reference, my_code and my_product_name in the field library. If multiple
portal types ( A and B ) use a my_reference field and if they are semantically
distinct, add 2 fields in the field library named my_A_reference and my_B_reference.
Finally, those 2 fields will be proxy fields of a generic my_reference.
A procedure of making field library is following:
There are some utility scripts in erp5_forge/erp5_toolbox skin folder.
The appearance of list fields must be different possibly
for region, role, function etc.?
As field library are organized semantically, there will be category specific
template fields like my_region, my_role, my_function in a local field library.
In this way you can unify many my_region fields in your business template to
one and can customize as you want.
source_title is a different field with different UI possibly
between ticket and event (ie. This means source_title field for ticket probably
uses proxy field of another skin than crm)?
You must add my_event_source_title and my_ticket_source_title as a special template
field and this template field should inherit a normal source_title.proxy order
will be following:
(Ticket is a special case)
(Event is a normal case)
In this way we can handle both special case and normal case in one local field
library and because everything is in one local field library, it is easy to
understand proxy field dependencies.
What about localised form boxes (ex.. Japanese address is
not same as French and FormBox must be used)
I think there is nothing special about proxifying formbox. FormBox job is just
choosing an appropriate erp5 form to embed by user language. Probably we define
a naming rule for it and prepare a template field and enter a clever tales
expression to extract required values to make it work, just like RelationStringField.
What about fields with a lot of many specific semantic (ex. Resources in a
purchase order line should be of category use/component whereas resources in
a sale order line should be of category use/product)
I think preparing a template field per specific semantic is enough. In above
example, add my_purchase_resource as a template field and use it from proxy
fields of PurchaseOrderLine and PurchaseOrderCell.Then Add my_sale_resource as
another template field and use it from another proxy fields.
If it's only used in one form, is it useful to have proxy
field ? it's same amount of work to maintain customized field library than to
maintain customized form.
Good point. Having a proxy field is useful, because almost all fields should
follow user's preference and proxy field is the most useful way to realize it.
But I don't think it is useful to have dedicated proxy field for each field.
That's why the current field library provides very few template fields and
basically proxy is made per data type. But there is another opinion. Because
we cannot assume future customisation requirement, and if we want to customise
such minor fields which is used only once in standard business template, then
we have to make a proxy field from scratch and it is boring. So that all fields
should be replaced with proxy field. This is another opinion and we consider
to realize this idea now.
Why some fields in the form displayed to the user might
be not proxy fields ? Isn't it better to make ALL of them proxy field ? I can
understand exceptions for project's specific forms, but it might be better to
do no exception on generic business templates.
Yes, all fields in generic business templates should be proxy fields. If you
find a non-proxy field, it is a mistake, a bug.
Why is it better to use proxy fields in generic business
It allows easier customization in customer projects and help having consistent user interface.