Skip to content

Commit 024fadf

Browse files
committed
[IMP] core: remove support for domains in onchange
Part-of: #116779
1 parent 418159b commit 024fadf

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

odoo/models.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6210,32 +6210,25 @@ def _onchange_eval(self, field_name, onchange, result):
62106210
domain and warning messages are put in dictionary ``result``.
62116211
"""
62126212
onchange = onchange.strip()
6213+
if onchange not in ("1", "true"):
6214+
return
62136215

6214-
def process(res):
6216+
for method in self._onchange_methods.get(field_name, ()):
6217+
res = method(self)
62156218
if not res:
6216-
return
6219+
continue
62176220
if res.get('value'):
62186221
res['value'].pop('id', None)
6219-
self.update({key: val for key, val in res['value'].items() if key in self._fields})
6220-
if res.get('domain'):
6221-
_logger.warning(
6222-
"onchange method %s returned a domain, this is deprecated",
6223-
method.__qualname__
6224-
)
6225-
result.setdefault('domain', {}).update(res['domain'])
6222+
for key, val in res['value'].items():
6223+
if key in self._fields and key != 'id':
6224+
self[key] = val
62266225
if res.get('warning'):
62276226
result['warnings'].add((
62286227
res['warning'].get('title') or _("Warning"),
62296228
res['warning'].get('message') or "",
62306229
res['warning'].get('type') or "",
62316230
))
62326231

6233-
if onchange in ("1", "true"):
6234-
for method in self._onchange_methods.get(field_name, ()):
6235-
method_res = method(self)
6236-
process(method_res)
6237-
return
6238-
62396232
def onchange(self, values, field_name, field_onchange):
62406233
""" Perform an onchange on the given field.
62416234

0 commit comments

Comments
 (0)