@@ -6210,32 +6210,25 @@ def _onchange_eval(self, field_name, onchange, result):
6210
6210
domain and warning messages are put in dictionary ``result``.
6211
6211
"""
6212
6212
onchange = onchange .strip ()
6213
+ if onchange not in ("1" , "true" ):
6214
+ return
6213
6215
6214
- def process (res ):
6216
+ for method in self ._onchange_methods .get (field_name , ()):
6217
+ res = method (self )
6215
6218
if not res :
6216
- return
6219
+ continue
6217
6220
if res .get ('value' ):
6218
6221
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
6226
6225
if res .get ('warning' ):
6227
6226
result ['warnings' ].add ((
6228
6227
res ['warning' ].get ('title' ) or _ ("Warning" ),
6229
6228
res ['warning' ].get ('message' ) or "" ,
6230
6229
res ['warning' ].get ('type' ) or "" ,
6231
6230
))
6232
6231
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
-
6239
6232
def onchange (self , values , field_name , field_onchange ):
6240
6233
""" Perform an onchange on the given field.
6241
6234
0 commit comments