diff options
| author | jem-odoo <jem@openerp.com> | 2018-02-26 14:19:03 +0100 |
|---|---|---|
| committer | jem-odoo <jem@openerp.com> | 2018-09-25 15:19:30 +0200 |
| commit | 40778d883d7894cccdd709c421aea1dcd056e54d (patch) | |
| tree | 84ed5a82cbe353433c672ce943ae17f54b050e6a /doc | |
| parent | 3c35678ce79697ce40fd61ede3b0d8da2719e3e4 (diff) | |
[IMP] doc: add selection method guideline
Sometime, we need to get selection values from
a method. Here are the guidelines about how
to correctly name method and place it in the
code.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/reference/guidelines.rst | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/doc/reference/guidelines.rst b/doc/reference/guidelines.rst index 11db3c1e8c3..cd83f0bd8f5 100644 --- a/doc/reference/guidelines.rst +++ b/doc/reference/guidelines.rst @@ -826,6 +826,7 @@ Symbols and Conventions - Compute Field : the compute method pattern is *_compute_<field_name>* - Search method : the search method pattern is *_search_<field_name>* - Default method : the default method pattern is *_default_<field_name>* + - Selection method: the selection method pattern is *_selection_<field_name>* - Onchange method : the onchange method pattern is *_onchange_<field_name>* - Constraint method : the constraint method pattern is *_check_<constraint_name>* - Action method : an object action method is prefix with *action_*. Its decorator is @@ -836,7 +837,8 @@ Symbols and Conventions #. Private attributes (``_name``, ``_description``, ``_inherit``, ...) #. Default method and ``_default_get`` #. Field declarations - #. Compute and search methods in the same order as field declaration + #. Compute, inverse and search methods in the same order as field declaration + #. Selection method (methods used to return computed values for selection fields) #. Constrains methods (``@api.constrains``) and onchange methods (``@api.onchange``) #. CRUD methods (ORM overrides) #. Action methods @@ -860,6 +862,7 @@ Symbols and Conventions seats_available = fields.Integer(oldname='register_avail', string='Available Seats', store=True, readonly=True, compute='_compute_seats') price = fields.Integer(string='Price') + type = fields.Selection(string="Type", selection='_selection_type') # compute and search fields, in the same order of fields declaration @api.multi @@ -867,6 +870,10 @@ Symbols and Conventions def _compute_seats(self): ... + @api.model + def _selection_type(self): + return [] + # Constraints and onchanges @api.constrains('seats_max', 'seats_available') def _check_seats_limit(self): |
