Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(15)

Side by Side Diff: doc/topics/models/model.rst

Issue 907042: First snapshot of trytond documentation refactoring (Closed)
Patch Set: Some fixes and update Created 15 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 .. _topics-models-model:
2
3 .. module:: trytond.model.model
4
5 =====
6 Model
7 =====
8
9 :class:`Model` Objects
10 ----------------------
11
12 This is the base class that every kinds of model inherits. It defines common
yangoon1 2010/04/11 11:28:32 still wrong
ced 2010/04/14 05:46:10 I don't see what is wrong.
yangoon1 2010/04/14 10:03:33 (every kind of model|all kinds of models)
13 attributes of all models.
14
15 Class attributes are:
16
17 .. attribute:: Model._name
18
19 It contains the a unique name to reference the model throughout the
20 platform.
21
22 .. attribute:: Model._inherits
23
24 .. attribute:: Model._description
25
26 It contains a description of the model.
27
28 .. attribute:: Model._rpc
29
30
31 It contains a dictionary with method name as key and a boolean as value. If
32 a method name is in the dictionary then it is allowed to call it remotely.
33 If the value is ``True`` then the transaction will be committed.
34
35 .. attribute:: Model._error_messages
36
37 It contains a dictionary mapping keywords to an error message. By way of
38 example::
39
40 _error_messages = {
41 'recursive_categories': 'You can not create recursive categories!',
42 'wrong_name': 'You can not use " / " in name field!'
43 }
44
45 .. attribute:: Model._rec_name
46
47 It contains the name of the field used as name of records.
48
49 .. attribute:: Model.id
50
51 The definition of the field ``id`` of records.
52
53 Instance methods:
54
55 .. method:: Model.init(cursor, module_name)
56
57 Register the model in ``ir.model`` and ``ir.model.field``.
58
59 .. method:: Model.raise_user_error(cursor, error, [error_args, [error_descriptio n, [error_description_args, [raise_exception, [context]]]]])
60
61 Raise an exception that will be displayed as an error message in the
62 client. ``error`` is the key of the error message in ``_error_messages``
63 and ``error_args`` is the arguments for the "%"-based substitution of the
64 error message. There is the same parameter for an additional description.
65 The boolean ``raise_exception`` can be set to ``False`` to retrieve the
66 error message strings.
67
68 .. method:: Model.raise_user_warning(cursor, user, warning_name, warning, [warni ng_args, [warning_description, [warning_description_args, [context]]]])
69
70 Raise an exception that will be displayed as a warning message on the
71 client, if the user has not yer bypassed it. ``warning_name`` is used to
yangoon1 2010/04/11 11:28:32 not yet
72 uniquely identify the warning. Others parameters are like in
73 :meth:`Model.raise_user_error`.
yangoon1 2010/04/11 11:28:32 Other parameters what about raise_exception?
ced 2010/04/14 05:46:10 I don't understand.
yangoon1 2010/04/14 10:03:33 Others parameters are like in :meth:`Model.raise_u
74
75 .. method:: Model.default_get(cursor, user, fields_names, [context, [with_rec_na me]])
76
77 Return a dictionary with the default values for each field in
78 ``fields_names``. Default values are defined by the returned value of each
79 instance method with the pattern ``default_`field_name`(cursor, user,
80 [context])``. ``with_rec_name`` allow to add `rec_name` value for each
81 many2one field.
82
83 .. method:: Model.fields_get(cursor, user, [fields_names, [context]])
84
85 Return the definition of each field on the model.
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b