summaryrefslogtreecommitdiff
path: root/doc/reference
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-10-22 17:57:08 +0200
committerChristophe Simonis <chs@odoo.com>2018-10-22 17:57:08 +0200
commit9dbb7d199cfe085ea5e3a4980de2bd766953ab93 (patch)
tree6ed48459069117f9f2cbd0fffa771c907592bb38 /doc/reference
parenta8cec47c930c1d3b60f0e5c5788106cc30dc1a0b (diff)
parentb81c2bce846c94b5695d680ebbc30f1cfe51e614 (diff)
[MERGE] forward port branch 12.0 up to b81c2bce846
Diffstat (limited to 'doc/reference')
-rw-r--r--doc/reference/guidelines.rst48
-rw-r--r--doc/reference/javascript_reference.rst2
-rw-r--r--doc/reference/module.rst2
-rw-r--r--doc/reference/views.rst10
4 files changed, 48 insertions, 14 deletions
diff --git a/doc/reference/guidelines.rst b/doc/reference/guidelines.rst
index cd83f0bd8f5..10bd221a51e 100644
--- a/doc/reference/guidelines.rst
+++ b/doc/reference/guidelines.rst
@@ -44,7 +44,7 @@ Other optional directories compose the module.
- *wizard/* : regroups the transient models (``models.TransientModel``) and their views
- *report/* : contains the printable reports and models based on SQL views. Python objects and XML views are included in this directory
-- *tests/* : contains the Python/YML tests
+- *tests/* : contains the Python tests
File naming
@@ -622,17 +622,47 @@ online documentation of pyscopg2 to learn of to use it properly:
- Advanced parameter types (http://initd.org/psycopg/docs/usage.html#adaptation-of-python-values-to-sql-types)
-Keep your methods short/simple when possible
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Think extendable
+~~~~~~~~~~~~~~~~
Functions and methods should not contain too much logic: having a lot of small
and simple methods is more advisable than having few large and complex methods.
-A good rule of thumb is to split a method as soon as:
-- it has more than one responsibility (see http://en.wikipedia.org/wiki/Single_responsibility_principle)
-- it is too big to fit on one screen.
+A good rule of thumb is to split a method as soon as it has more than one
+responsibility (see http://en.wikipedia.org/wiki/Single_responsibility_principle).
-Also, name your functions accordingly: small and properly named functions are the starting point of readable/maintainable code and tighter documentation.
+Hardcoding a business logic in a method should be avoided as it prevents to be
+easily extended by a submodule.
-This recommendation is also relevant for classes, files, modules and packages. (See also http://en.wikipedia.org/wiki/Cyclomatic_complexity)
+.. code-block:: python
+
+ # do not do this
+ # modifying the domain or criteria implies overriding whole method
+ def action(self):
+ ... # long method
+ partners = self.env['res.partner'].search(complex_domain)
+ emails = partners.filtered(lambda r: arbitrary_criteria).mapped('email')
+
+ # better but do not do this either
+ # modifying the logic forces to duplicate some parts of the code
+ def action(self):
+ ...
+ partners = self._get_partners()
+ emails = partners._get_emails()
+
+ # better
+ # minimum override
+ def action(self):
+ ...
+ partners = self.env['res.partner'].search(self._get_partner_domain())
+ emails = partners.filtered(lambda r: r._filter_partners()).mapped('email')
+
+The above code is over extendable for the sake of example but the readability
+must be taken into account and a tradeoff must be made.
+
+Also, name your functions accordingly: small and properly named functions are
+the starting point of readable/maintainable code and tighter documentation.
+
+This recommendation is also relevant for classes, files, modules and packages.
+(See also http://en.wikipedia.org/wiki/Cyclomatic_complexity)
Never commit the transaction
@@ -862,7 +892,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')
+ event_type = fields.Selection(string="Type", selection='_selection_type')
# compute and search fields, in the same order of fields declaration
@api.multi
diff --git a/doc/reference/javascript_reference.rst b/doc/reference/javascript_reference.rst
index 034938acaaf..ec125aa9b41 100644
--- a/doc/reference/javascript_reference.rst
+++ b/doc/reference/javascript_reference.rst
@@ -1610,7 +1610,7 @@ order.
.. code-block:: xml
- <field name="datefield" options='{"datepicker": {"daysOfWeekDisabled": [0, 6]}}'/>
+ <field name="datetimefield" options='{"datepicker": {"daysOfWeekDisabled": [0, 6]}}'/>
- monetary (FieldMonetary)
This is the default field type for fields of type 'monetary'. It is used to
diff --git a/doc/reference/module.rst b/doc/reference/module.rst
index 360d5c94186..3ab1b8c9b38 100644
--- a/doc/reference/module.rst
+++ b/doc/reference/module.rst
@@ -130,4 +130,4 @@ Available manifest fields are:
.. _semantic versioning: http://semver.org
.. _existing categories:
- https://github.com/odoo/odoo/blob/master/odoo/addons/base/module/module_data.xml
+ https://github.com/odoo/odoo/blob/12.0/odoo/addons/base/data/ir_module_category_data.xml
diff --git a/doc/reference/views.rst b/doc/reference/views.rst
index 642f394358e..52af59ecad4 100644
--- a/doc/reference/views.rst
+++ b/doc/reference/views.rst
@@ -1011,7 +1011,7 @@ attributes:
``quick_create``
whether it should be possible to create records without switching to the
form view. By default, ``quick_create`` is enabled when the Kanban view is
- grouped, and disabled when not.
+ grouped by many2one, selection, char or boolean fields, and disabled when not.
Set to ``true`` to always enable it, and to ``false`` to always disable it.
@@ -1727,8 +1727,12 @@ Possible children elements of the search view are:
The groupby defined above allows to group data by category.
- When the field is of type ``date`` or ``datetime``, the records are grouped by month by default.
- This can be modified by using one of the following options: day, week, quarter, year.
+ When the field is of type ``date`` or ``datetime``, the filter generates a submenu of the Group By
+ menu in which the following interval options are available: day, week, month, quarter, year.
+
+ In case the filter is in the default set of filters activated at the view initialization,
+ the records are grouped by month by default. This can be changed by using the syntax
+ 'date_field:interval' as in the following example.
Example: