2
.. i18n: OpenERP Object Attributes
3
.. i18n: =========================
5
OpenERP Object Attributes
6
=========================
8
.. i18n: Objects Introduction
9
.. i18n: --------------------
14
.. i18n: To define a new object, you have to define a new Python class then instantiate it. This class must inherit from the osv class in the osv module.
16
To define a new object, you have to define a new Python class then instantiate it. This class must inherit from the osv class in the osv module.
18
.. i18n: Object definition
19
.. i18n: -----------------
24
.. i18n: The first line of the object definition will always be of the form::
26
.. i18n: class name_of_the_object(osv.osv):
27
.. i18n: _name = 'name.of.the.object'
28
.. i18n: _columns = { ... }
30
.. i18n: name_of_the_object()
32
The first line of the object definition will always be of the form::
34
class name_of_the_object(osv.osv):
35
_name = 'name.of.the.object'
40
.. i18n: An object is defined by declaring some fields with predefined names in the class. Two of them are required (_name and _columns), the rest is optional. The predefined fields are:
42
An object is defined by declaring some fields with predefined names in the class. Two of them are required (_name and _columns), the rest is optional. The predefined fields are:
44
.. i18n: Prefined names
45
.. i18n: ---------------
54
.. i18n: Determines whether a corresponding PostgreSQL table must be generated automatically from the object. Setting _auto to False can be useful in case of Open ERP objects generated from PostgreSQL views. See the "Reporting From PostgreSQL Views" section for more details.
56
Determines whether a corresponding PostgreSQL table must be generated automatically from the object. Setting _auto to False can be useful in case of Open ERP objects generated from PostgreSQL views. See the "Reporting From PostgreSQL Views" section for more details.
58
.. i18n: :_columns (required):
62
.. i18n: The object fields. See the fields section for details.
64
The object fields. See the fields section for details.
66
.. i18n: :_constraints:
70
.. i18n: The constraints on the object. See the constraints section for details.
72
The constraints on the object. See the constraints section for details.
74
.. i18n: :_sql_constraints:
78
.. i18n: The SQL Constraint on the object. See theconstraints SQL section for more details.
80
The SQL Constraint on the object. See theconstraints SQL section for more details.
86
.. i18n: The default values for some of the object's fields. See the default value section for details.
88
The default values for some of the object's fields. See the default value section for details.
94
.. i18n: The name of the osv object which the current object inherits from. See the object inheritance section (first form) for details.
96
The name of the osv object which the current object inherits from. See the object inheritance section (first form) for details.
102
.. i18n: The list of osv objects the object inherits from. This list must be given in a python dictionary of the form: {'name_of_the_parent_object': 'name_of_the_field', ...}. See the object inheritance section (second form) for details. Default value: {}.
104
The list of osv objects the object inherits from. This list must be given in a python dictionary of the form: {'name_of_the_parent_object': 'name_of_the_field', ...}. See the object inheritance section (second form) for details. Default value: {}.
106
.. i18n: :_log_access:
110
.. i18n: Determines whether or not the write access to the resource must be logged. If true, four fields will be created in the SQL table: create_uid, create_date, write_uid, write_date. Those fields represent respectively the id of the user who created the record, the creation date of record, the id of the user who last modified the record, and the date of that last modification. This data may be obtained by using the perm_read method.
112
Determines whether or not the write access to the resource must be logged. If true, four fields will be created in the SQL table: create_uid, create_date, write_uid, write_date. Those fields represent respectively the id of the user who created the record, the creation date of record, the id of the user who last modified the record, and the date of that last modification. This data may be obtained by using the perm_read method.
114
.. i18n: :_name (required):
118
.. i18n: Name of the object. Default value: None.
120
Name of the object. Default value: None.
126
.. i18n: Name of the fields used to sort the results of the search and read methods.
128
Name of the fields used to sort the results of the search and read methods.
130
.. i18n: Default value: 'id'.
136
.. i18n: _order = "name"
137
.. i18n: _order = "date_order desc"
142
_order = "date_order desc"
148
.. i18n: Name of the field in which the name of every resource is stored. Default value: 'name'. Note: by default, the name_get method simply returns the content of this field.
150
Name of the field in which the name of every resource is stored. Default value: 'name'. Note: by default, the name_get method simply returns the content of this field.
156
.. i18n: Name of the SQL sequence that manages the ids for this object. Default value: None.
158
Name of the SQL sequence that manages the ids for this object. Default value: None.
164
.. i18n: SQL code executed upon creation of the object (only if _auto is True)
166
SQL code executed upon creation of the object (only if _auto is True)
172
.. i18n: Name of the SQL table. Default value: the value of the _name field above with the dots ( . ) replaced by underscores ( _ ).
174
Name of the SQL table. Default value: the value of the _name field above with the dots ( . ) replaced by underscores ( _ ).