summaryrefslogtreecommitdiff
path: root/odoo/models.py
diff options
context:
space:
mode:
authorVictor Feyens <vfe@odoo.com>2020-07-14 14:29:10 +0000
committerVictor Feyens <vfe@odoo.com>2020-07-23 16:38:17 +0000
commit71ab12840bc787ca486202255cd6faa21281b9e1 (patch)
treedc8b093e25f9215f2f2c53ff0a084500c88ef560 /odoo/models.py
parentc69a092b98ad7a7f8e03024d170efa30038c89a0 (diff)
[IMP] *: do not specify unwanted defaults in default_get
When default_get is called, the wanted fields are specified through the fields_list arg. It is useless to fill the values for unwanted fields. As default_get is called for nearly all records creation, simplifying the default_get overrides: * remove potential wrong side-effects of the values * remove some useless or wrong defaults computations (searches, refs, ...)
Diffstat (limited to 'odoo/models.py')
-rw-r--r--odoo/models.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/odoo/models.py b/odoo/models.py
index 3944401694f..44413e31cb9 100644
--- a/odoo/models.py
+++ b/odoo/models.py
@@ -1206,16 +1206,21 @@ class BaseModel(MetaModel('DummyModel', (object,), {'_register': False})):
@api.model
def default_get(self, fields_list):
- """ default_get(fields) -> default_values
+ """ default_get(fields_list) -> default_values
Return default values for the fields in ``fields_list``. Default
values are determined by the context, user defaults, and the model
itself.
- :param fields_list: a list of field names
- :return: a dictionary mapping each field name to its corresponding
- default value, if it has one.
+ :param list fields_list: names of field whose default is requested
+ :return: a dictionary mapping field names to their corresponding default values,
+ if they have a default value.
+ :rtype: dict
+
+ .. note::
+ Unrequested defaults won't be considered, there is no need to return a
+ value for fields whose names are not in `fields_list`.
"""
# trigger view init hook
self.view_init(fields_list)