Remove id to on_change calls that are cached
issue8234 review275131002
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Do not set id for on_change calls if cached
|
||||
* Add cache on RPC
|
||||
* Remove support for Python 3.4
|
||||
* Allow to update record when importing data
|
||||
|
||||
@@ -435,6 +435,15 @@ class Field(object):
|
||||
'sortable': hasattr(model, 'search'),
|
||||
}
|
||||
|
||||
# Add id to on_change's if they are not cached
|
||||
# Not having the id increase the efficiency of the cache
|
||||
for method in ['on_change', 'on_change_with']:
|
||||
changes = definition[method]
|
||||
if changes:
|
||||
method_name = method + '_' + self.name
|
||||
if not model.__rpc__[method_name].cache:
|
||||
changes.append('id')
|
||||
|
||||
name = '%s,%s' % (model.__name__, self.name)
|
||||
for attr, ttype in [('string', 'field'), ('help', 'help')]:
|
||||
definition[attr] = ''
|
||||
|
||||
@@ -603,7 +603,12 @@ class ModelView(Model):
|
||||
|
||||
change = cls.__change_buttons[button_name]
|
||||
if change:
|
||||
element.set('change', encoder.encode(list(change)))
|
||||
change = list(change)
|
||||
# Add id to change if the button is not cached
|
||||
# Not having the id increase the efficiency of the cache
|
||||
if cls.__rpc__[button_name].cache:
|
||||
change.append('id')
|
||||
element.set('change', encoder.encode(change))
|
||||
if not is_instance_method(cls, button_name):
|
||||
element.set('type', 'class')
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user