forked from OCA/server-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
168 lines (98 loc) · 5.38 KB
/
README
File metadata and controls
168 lines (98 loc) · 5.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
== Configure your OpenERP server for analytic fields ==
In your OpenERP server's configuration file, you can set several optional
parameters related to the analytic module.
[analytic]
key = value ...
Those options must be grouped under the [analytic] category. If the category
doesn't exist, add it to your configuration file.
key (default value): description
analytic_size (5): define the maximum number of analytic dimensions
that can be associated with a model.
translate (False): enable or disable the translation of field values on
analytic dimensions (name) and codes (name and description).
== Add the MetaAnalytic metaclass 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
== Add analytic fields to a model ==
First of all, make sure you are using the MetaAnalytic metaclass.
Then, add the _analytic attribute to your class, using the following syntax.
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' : 'module.view_id'
}"/>
== Bind an analytic dimension to a model ==
First of all, make sure you are using the MetaAnalytic metaclass.
Then, add the _dimension attribute to your class, using the following syntax.
Bind the model to an analytic dimension named after the model, using default values:
_dimension = True
Bind the model to an analytic dimension with a specified name, using default values:
_dimension = 'Funding Source'
Bind the model to an analytic dimension, using either custom or default values:
_dimension = {
'name': 'School',
'column': 'analytic_code_id',
'ref_id': 'school_analytic_dimension',
'ref_module': 'my_module',
'sync_parent': False,
'rel_description': True,
'rel_active': (u"Active", 'active_code'),
'use_inherits': False,
'use_code_name_methods': False,
}
key (default value): description
name (= _description or _name): The name of the analytic dimension.
This name is only used when creating the dimension in the database.
column (analytic_id): The field that links each record to an analytic code.
ref_id (= _name + analytic_dimension_id): The external ID that will
be used by the analytic dimension. By setting this value, you can allow two
models to use the same dimension, or a model to use an already existing one.
ref_module (empty string): The name of the module associated with the dimension
record. Change this value in order to use a dimension defined in a data file.
sync_parent (False): Controls the synchronization of the codes' parent-child
hierarchy with that of the model. When using an inherited, renamed parent field,
you must give the parent field name rather than simply True.
use_inherits (special): Determines whether the analytic codes should be bound
to the records by inheritance, or through a simple many2one field.
Inheritance allows for better synchronization, but can only be used if there
are no duplicate fields between the two objects.
The default value is True if the model has no 'name' and 'code_parent_id' field
as well as no inheritance of any kind, and False otherwise. If the object has
inheritances that do not cause conflicts, you can set it to True.
rel_active (False): Create a related field in the model, targeting the
analytic code field 'active' and with an appropriate store parameter.
This is useful when the model doesn't inherit analytic_code and/or when it
already has a field named 'active'.
Can take a pair of string values: (field label, field name).
If given a string, the default field name 'active' will be used.
If given True, the default field label 'Active' will also be used.
rel_description (False): Same as rel_active for the code field 'description'.
If given a string, the default field name 'description' will be used.
If given True, the default field label 'Description' will also be used.
use_code_name_methods (False): Set to True in order to override the methods
name_get and name_search, using those of analytic code.
This allows the analytic code's description to be displayed (and searched)
along with the entry's name in many2one fields targeting the model.