Skip to content
Snippets Groups Projects
user avatar
Jérémie Gavrel authored
fee5280f
History
Name Last commit Last update
i18n
security
.hgignore
.hgtags
MetaAnalytic.py
README
__init__.py
__openerp__.py
analytic_code.py
analytic_dimension.py
analytic_dimension.xml
analytic_structure.py
== Configure your OpenERP server for analytic fields ==


By default, up to 5 analytic dimensions can be associated with an object.
You can increase this number by setting an option in the configuration file:

[analytic]
analytic_size = 10



== Add analytic fields to a model ==


At the beginning of the source file, import the MetaAnalytic metaclass:

from openerp.addons.analytic_structure.MetaAnalytic import MetaAnalytic


Inside your Model class, define MetaAnalytic to be used as metaclass:

__metaclass__ = MetaAnalytic


Then, add the _analytic attribute to your class.

Use the analytic fields associated with the model:

_analytic = True

Use analytic fields associated with another model:

_analytic = 'account_move_line'

Use several analytic field structures, associated with different prefixes:

_analytic = {
    'a': 'account_asset_asset',
    't': 'account_move_line',
}



== Add analytic fields to a view ==


Analytic fields can be added to the view individually, like any other field:

<field name="a1_id" />

'a' is the prefix associated with the structure. By default, it is 'a'.
'1' is the dimension's ordering as defined by the analytic structure.


You can also use a div to insert every analytic field within a given structure
(defined by its prefix) that wasn't explicitly placed in the view.

<div class="oe_analytic" required="1" prefix="t" />

The class, oe_analytic, mark the div that will be replaced by analytic fields.
The prefix can be omitted for a structure that uses the default prefix 'a'.
Any other attribute will be propagated to the analytic fields.


Warning: analytic fields should generally not be used inside nested sub-views.
If possible, create a separate record and use the context to specify the view:

<field name="order_line" colspan="4" nolabel="1" context="{
    'form_view_ref' : 'module.view_id',
    'tree_view_ref' : 'model.view_id'
}"/>