summaryrefslogtreecommitdiff
path: root/addons/account/models/account_account.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 /addons/account/models/account_account.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 'addons/account/models/account_account.py')
-rw-r--r--addons/account/models/account_account.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/addons/account/models/account_account.py b/addons/account/models/account_account.py
index 1622338baf2..b7da1a1ac37 100644
--- a/addons/account/models/account_account.py
+++ b/addons/account/models/account_account.py
@@ -305,6 +305,8 @@ class AccountAccount(models.Model):
"""If we're creating a new account through a many2one, there are chances that we typed the account code
instead of its name. In that case, switch both fields values.
"""
+ if 'name' not in default_fields and 'code' not in default_fields:
+ return super().default_get(default_fields)
default_name = self._context.get('default_name')
default_code = self._context.get('default_code')
if default_name and not default_code: